Skip to main content

Sending Emails with SMTP and Sendgrid Discussion

General • Asked by Chris Oliver

jajajaj Chris Your the man. I was just switching from my simple gmail account to using sendgrid and now this episode show up. :) very very happy.

Let's pretend I planned that. 😉

Hi Chris, you are a cool dude, keep up the good work

Thanks man! :)

can we use mailer to send message like in a web contact form without saving the message into the database?

So grateful for this help. Thank you!

You're the man Chris! Thanks for this

You're welcome! 🎉

Could you show us how you would tie this into a contact form?

Thanks, I'll check it out

Where do I need to customize the email layout and whats the best practice to design email's layouts? In order to send my logo and maybe some links and so on! I want my emails look pretty instead of just plain text!

Unfortunately, styling emails is still pretty nasty these days. You generally will see people using tables to do layouts because email applications don't generally support the full CSS suite of features for various reasons (including security). Lots to find if you google "html emails" or "email layouts".

As for images, Rails lets you include them as normal, but you have to specify the asset host: http://edgeguides.rubyonrai...

Ok but I just want only a few styles not to much! Where do I need to create my templates files on my Rails app?

Hi Chris. First of all, thanks for putting this out, GoRails has been a great resource to implement new features and learn.

I've got a file in my model that gets upload with Shrine to S3 (works perfectly) and I was wondering how can I attach that file when sending email with a Mailer?

Adding an attachment in your mailers is just as simple as doing:

attachments['file-name.jpg'] = @model.upload

The right side should just a be a File-like object that Rails then assign to the filename in the email.

Hi Chris i am getting uninitialized constant NotificationMailer , not sure why

irb(main):001:0> NotificationMailer.welcome.deliver_now
Traceback (most recent call last):
        1: from (irb):1
NameError (uninitialized constant NotificationMailer)

i am using rails 6,

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 22,346+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.