Coder Social home page Coder Social logo

Comments (16)

safetymonkey avatar safetymonkey commented on August 17, 2024 31

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.

thinkingserious avatar thinkingserious commented on August 17, 2024 7

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.

christianroy avatar christianroy commented on August 17, 2024 2

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.

christianroy avatar christianroy commented on August 17, 2024 2

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.

safetymonkey avatar safetymonkey commented on August 17, 2024 2

Ah. I'm glad it helped!

from sendgrid-ruby.

itsameandrea avatar itsameandrea commented on August 17, 2024 2

@safetymonkey - thanks a lot for your help! You saved me a lot of troubleshooting :)

from sendgrid-ruby.

senyoAsamoah avatar senyoAsamoah commented on August 17, 2024 1

@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.

pieterb82 avatar pieterb82 commented on August 17, 2024 1

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.

thinkingserious avatar thinkingserious commented on August 17, 2024

Hello @safetymonkey,

Could you please let me know what the return value of mail.to_json is? Thanks!

from sendgrid-ruby.

safetymonkey avatar safetymonkey commented on August 17, 2024
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.

safetymonkey avatar safetymonkey commented on August 17, 2024

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.

safetymonkey avatar safetymonkey commented on August 17, 2024

I'm happy to try and help if you can provide more info on exactly what you're seeing.

from sendgrid-ruby.

VictorAcatrinei avatar VictorAcatrinei commented on August 17, 2024

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.

thinkingserious avatar thinkingserious commented on August 17, 2024

Great idea @VictorAcatrinei,

We will get it added to the TROUBLESHOOTING.md document.

from sendgrid-ruby.

thedanotto avatar thedanotto commented on August 17, 2024

@safetymonkey never woulda figured it out with you!!! Can't believe this hasn't been updated in their documentation

from sendgrid-ruby.

thinkingserious avatar thinkingserious commented on August 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.