Comments (16)
Alright, I figured it out. It's an embarrassing "LRN 2 code n00b" moment. Mail.new is being hijacked in Rails by ActionMailer. Instead of trying to figure out how to hand that back to the Sendgrid gem I can just specify SendGrid::Mail.new
and that does the trick.
Sorry for the dumb question. I'll resolve the issue.
from sendgrid-ruby.
Not dumb at all, and it's greatly appreciated that you took the time to share the solution. I'm sure you'll help someone who is having a similar issue in the future.
from sendgrid-ruby.
Hello, n00b here. :) Had a similar issue in my production environment (but worked fine in dev), this thread helped me a lot. So just confirming "you'll help someone who is having a similar issue in the future". Thanks a lot @safetymonkey.
from sendgrid-ruby.
Oh don't worry @safetymonkey, I solved my problem by specifying SendGrid::Mail.new
like you did. I was just thanking you for your documentation efforts back in June...
from sendgrid-ruby.
Ah. I'm glad it helped!
from sendgrid-ruby.
@safetymonkey - thanks a lot for your help! You saved me a lot of troubleshooting :)
from sendgrid-ruby.
@safetymonkey - thanks a lot, run into similar issue implementing sendgrid on my local dev and coming across his thread and your solution helped
from sendgrid-ruby.
Was creating a rake task to test the mailer, which gave the same error. Fixed it with adding the SendGrid:: before all the lines with New. Thanks @safetymonkey!
from sendgrid-ruby.
Hello @safetymonkey,
Could you please let me know what the return value of mail.to_json is? Thanks!
from sendgrid-ruby.
2.3.1 :013 > mail.to_json
=> "{\"body\":{\"boundary\":null,\"preamble\":null,\"epilogue\":null,\"charset\":\"US-ASCII\",\"part_sort_order\":[\"text/plain\",\"text/enriched\",\"text/html\"],\"parts\":[],\"raw_source\":\"\",\"encoding\":\"7bit\"},\"body_raw\":null,\"separate_parts\":false,\"text_part\":null,\"html_part\":null,\"errors\":null,\"header\":[{\"charset\":\"UTF-8\",\"name\":\"#\\u003cSendGrid\",\"raw_value\":\"#\\u003cSendGrid::Email:0x007f845b13e570\\u003e\",\"value\":\":Email:0x007f845b13e570\\u003e\",\"field\":{\"errors\":[],\"charset\":\"UTF-8\",\"name\":\"#\\u003cSendGrid\",\"length\":null,\"tree\":null,\"element\":null,\"value\":\":Email:0x007f845b13e570\\u003e\"}}],\"charset\":\"UTF-8\",\"defaulted_charset\":true,\"smtp_envelope_from\":null,\"smtp_envelope_to\":null,\"perform_deliveries\":true,\"raise_delivery_errors\":true,\"delivery_handler\":null,\"delivery_method\":{\"settings\":{\"address\":\"localhost\",\"port\":25,\"domain\":\"localhost.localdomain\",\"user_name\":null,\"password\":null,\"authentication\":null,\"enable_starttls_auto\":true,\"openssl_verify_mode\":null,\"ssl\":null,\"tls\":null}},\"transport_encoding\":{},\"mark_for_delete\":false,\"raw_source\":\"#\\u003cSendGrid::Email:0x007f845b13e570\\u003e\"}"
Interestingly, I was able to get the code to succeed in IRB but not in the Rails console. I suppose this points to a problem with my environment setup but the error message returned from the API was frustratingly vague.
from sendgrid-ruby.
It looks like there is something in the Rails console that is conflicting with Sendgrid that isn't happening in IRB. In the console the mail.class is Mail::Message
and in IRB it's SendGrid::Mail
.
This looks like a local setup issue so feel free to resolve, although if you have any helpful ideas I'd be all ears
from sendgrid-ruby.
I'm happy to try and help if you can provide more info on exactly what you're seeing.
from sendgrid-ruby.
Would this fix be something that can be added to the documentation or in some place that can be visible for even more people?
from sendgrid-ruby.
Great idea @VictorAcatrinei,
We will get it added to the TROUBLESHOOTING.md document.
from sendgrid-ruby.
@safetymonkey never woulda figured it out with you!!! Can't believe this hasn't been updated in their documentation
from sendgrid-ruby.
Hi @thedanotto!
Thanks for following up with some feedback!
If you don't mind, to help us improve, could you share the places you looked before you arrived here?
With Best Regards,
Elmer
from sendgrid-ruby.
Related Issues (20)
- 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 7
- [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
- Error in ruby documentation for associating authenticated domains with a subuser
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.