Comments (17)
I'm pretty sure it works now, I think it's not an issue anymore.
from sendgrid-ruby.
It is just adding our replacements in our email templates. Where we are doing add_substitution calls there and such. Not sure if this helps but here is a stripped down version.
class SomeHeaderBuilder
def build_header(recipients)
header_factory = HeaderFactory.new(recipients)
header_factory.add_param(":welcome_message", "hey, how are ya?")
header_factory.add_template_id(template_id)
header_factory.header
end
private
def template_id
"12345"
end
end
class HeaderFactory
attr_reader :header
def initialize(recipients, header = Smtpapi::Header.new)
@recipients = recipients
@header = header
@header.add_to recipients if @header.to.empty?
end
def add_param(key, value)
header.add_substitution(key, Array.new(@recipients.size, value))
end
def add_template_id(template_id)
header.add_filter("templates", "enable", 1) # necessary for each time the template engine is used
header.add_filter("templates", "template_id", template_id)
end
end
from sendgrid-ruby.
Its still not working @matt-hu . We ran a test just now.
from sendgrid-ruby.
We have not been able to get this to work either @matt-hu . Both cc and bcc. We have tried switching on the bcc flag in our account settings as well and it doesn't seem to be the issue.
from sendgrid-ruby.
@thinkingserious please see above.
from sendgrid-ruby.
Are you using the new library? https://github.com/sendgrid/sendgrid-ruby/tree/v3beta
In either case, could you provide me with the code (credentials and sensitive data redacted)?
Thanks!
from sendgrid-ruby.
No I am on version 1.1.6.
def build_email(recipients, header_builder, files = {})
attachments = files.map do |key, value|
{name: key, file: value}
end
mail = SendGrid::Mail.new do |m|
m.to = recipients
m.bcc = "[email protected]"
m.from = from_address
m.subject = " "
m.html = "<body></body>"
m.attachments = attachments
end
mail.smtpapi = header_builder.build_header(recipients)
mail
end
then call client.send(mail) where ever we are using this.
Everything else is working as expected.
from sendgrid-ruby.
Thank you @davidsavoya,
We will take a look.
Also, could you show us the code for the header_builder?
from sendgrid-ruby.
my code is :
@mail = SendGrid::Mail.new do |m|
m.to = @email
m.from = "<#{ENV['SMTP_DEFAULT_FROM_EMAIL']}>"
m.subject = (I18n.t 'invite_project_user.welcome_title', project_name: @project_name)
m.bcc = ENV['BCC_MAIL'].to_s if @info['first']
m.html = template.result(binding)
end
It works for me.
from sendgrid-ruby.
BTW, I am on v1.1.6, too.
The mail function works fine these days.
And I can't tell what's wrong with your code, sorry.
I suggest you debug into SendGrid::Mail.new
when you call it, to see what just happens. @davidsavoya
from sendgrid-ruby.
When I build the mail object, I can see that '@bcc' gets built to be the string I want and when I call send on an the sendgrid client, the mail that I call it with has '@bcc' with the string email address I want.
Is there anything on the response back that would give any clues?
from sendgrid-ruby.
Is there anything in my account settings with SendGrid that needs to be adjusted?
from sendgrid-ruby.
Playing around with this, I can remove my 'to' assignment from the mail class since I pass my recipients to
mail.smtpapi = header_builder.build_header(recipients)
which is building a Smtpapi::Header. It seems that who I am sending mail to is a result of who I add to the 'to' of the Smtpapi::Header. I don't see a way to add a bcc or cc to this class.
from sendgrid-ruby.
Hey guys, I was able to get this working by adding a bcc filter on the header. I appreciate y'all looking into this.
header.add_filter("bcc", "enable", 1) # necessary for each time the template engine is used
header.add_filter("bcc", "email", "[email protected]")
from sendgrid-ruby.
Do you think
def smtpapi_json
if !template.nil? && template.is_a?(Template)
template.add_to_smtpapi(smtpapi)
end
smtpapi.to_json
end
In SendGrid::Mail could do something similar with the bcc by adding to the smtpapi json? If so, I would be happy to give it a go at home. LMK or feel free to close
from sendgrid-ruby.
@davidsavoya glad you find the work around.
for your last question, In SendGrid::Mail could do something similar with the bcc by adding to the smtpapi json?
I digged into this before (just because my project only used stmpapi before and PM got the bcc requirement, OMG ). it seems there is no way to make it right with using stmpapi.
from sendgrid-ruby.
Hello @matt-hu,
The new version of this library has come out of beta yesterday. It uses our new v3 /mail/send endpoint, which includes the SMTPAPI functionality without an external dependency.
from sendgrid-ruby.
Related Issues (20)
- Duplicate checking when adding email to personalization is not accurate HOT 6
- Request: Make it possible to pass http_options config when initialize API HOT 1
- Ruby 3 support HOT 2
- Is sendgrid-ruby still ruby 2.2. compatible? HOT 2
- Unable to verify signature for testing purposes HOT 6
- [BUG] Filter all messages does not work as described in documentation HOT 5
- How to add/remove contacts to a list via new marketing API? HOT 5
- Adding SendGrid addon on Heroku uses Basic Authentication with Username and Password HOT 4
- How to substitute \n or carriage returns HOT 1
- SendGrid::DuplicatePersonalizationError HOT 1
- BaseInterface class should be inside a module HOT 1
- Bad username / password HOT 5
- EML files turning into multiple attachments when using Inbound Parse HOT 5
- Personalization causes duplicate `to` email and sometimes causes multiple emails HOT 1
- Dynamic Templates overwritting list styles HOT 2
- Priority of sent emails HOT 1
- Helpers do not have all properties HOT 1
- The link to be notified of releases and breaking changes is returning a 500 from Heroku HOT 1
- Multiple Emails HOT 3
- uninitialized constant SendgridService::Personalization HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sendgrid-ruby.