Ask A Question

Notifications

You’re not receiving notifications from this thread.

Sending emails with Mandrill Discussion

Edmundo Ramirez Edmundo Ramirez

Excellent tutorial. Congrats.

Reply

Hey Chris, would you recommend gem 'mandrill-rails' too? or is gem "madrill-api" better?

Reply

Hey Angelo! I believe the mandrill-rails gem only supports Mandrill's inbound email webhooks.

The primary goal of Mandrill::Rails is to make supporting Mandrill web hooks as easy and Rails-native as possible.

The mandrill-api gem should be for accessing their REST API which you can find here: https://mandrillapp.com/api...

Reply
ronnie_bermejo ronnie_bermejo

Thank you. Very complete tutorial.
(I would use it in companion of the dotenv gem to avoid adding the the api-key on the configuration files and prevent committing it into the repository.)

Reply

Why I can not sign up on Mandrill, when I signed up , it just returned "Error 417"

Reply

Not sure if I am watching this wrong. I was trying to follow along adding a functioning mailer to an application I'm already working on. It seems like this tutorial begins in the middle of something else, with more features added than I was told in the video.

I was expecting the tutorial to go from being a basic app with no functioning mailer to being a basic app with a functioning mailer

Reply

Check out the handful of episodes just before this one to get the bigger picture.

Reply

Just wondering what are benefits to use Mandrill over the simple mail() method that you mentioned apart from the flexibility of templates manipulation out of code?

Reply

Basically, you need to run a mail server somewhere in either case. Mandrill serves as that whether you just use it for SMTP or you hit their API instead to send the emails without using SMTP.

Reply

It also seems Mandrill does much of the legwork with ISPs and Email services to give you a better chance of your mail actually getting delivered — and not flagged as spam.

Reply
Kohl Kohlbrenner Kohl Kohlbrenner

Don't you usually put the ActionMailer smtp settings and everything else in the environment files?

Reply
Kohl Kohlbrenner Kohl Kohlbrenner

these are Devise email templates right?

Reply

Yes, because usually I'll have a separate account between development (often disabled or a test account that's a free plan) and production.

Reply

I want to pass in specific information from the form through the request parameter url. How can I do that. For example a user submits a project for bidding in a form, and the project has a project title, how do I pass the project's title to the mail sent?

Reply

You can pass in the object into the mailer as an argument. Just set that to an instance variable and render it in your mailer view. If you're using Mandrill templates, you can pass the values over as merge variables instead.

Reply

To help out future rookies who will find this:
I don't know if the mandrill gem changed but following your steps, I could not get emails to send. Turns out in the Mandrill gem docs they say "The gem assumes your API key is stored as an environment variable called MANDRILL_APIKEY." http://help.mandrill.com/en...

So I figured out foreman, and how to load an .env file etc and then it started working.

Reply
Rich Everts Rich Everts

I went through this whole process with Foreman, Unicorn, Figaro, and Resque. Is there anything you installed or did you might think I'm missing here?

Reply

Also, has anyone else seen a delay in sending emails from Mandrill to Gmail? I would see a delay of up to 15 mins sometimes. Usually it is around a minute. Checked Mandrill status, no problems there.

Reply

It depends on their SMTP system, I've seen the same delays at times. They might be queuing or batching emails behind the scenes or any multitude of things between them and GMail could be slow. I'm not quite sure.

Reply

I was seeing 5 minute+ delays and no shows - which is a problem for password resets! Chris has done the hard work so switching between providers isn't a chore. I'm testing another SMTP service and this is giving a better response time.

Reply

Thanks Chris, awesome as usual ;)

Reply
Rich Everts Rich Everts

I'm trying to pass the multiple arguments into the example new_book method, in this case a book and a user, and I can't get this to work and I'm a little frustrated. It works fine with one argument, the book, but adding multiple arguments messes it up. The after_create call gets called BEFORE the book is put in the database, so how do I access the book information to pass it? I was thinking with some kind of params call, but it doesn't seem to be accessible. Any ideas are welcome!

Reply
Rich Everts Rich Everts

I tried refactoring the new_user method as well, and the same thing happened. It goes through in the console, but nothing gets to the Mandrill servers BUT, the reset password does go through, so it doesn't seem to be an SMTP problem but something within the new_book method.

Reply

I am getting <actionmailer::base::nullmail:0x007f91f5a2e5c0> error. Why is that??

Reply
Chet Corey Work Chet Corey Work

user_name: is that the email you created the mandrill account, heroku, github, what account are you talking about. Do i make up and email address? Feeling very lost about what is going on with mailers.

Reply

When you register for Mandrill, you have to sign up with an email address. That's the email you will put into the user_name field so it knows which account is sending the emails.

Reply

How would you catch tests when using the Mandrill API and templates? At the moment I'm just skipping it using something like:

# MyMailer.rb
def new_book(book)
return if Rails.env.test?
...
end

Reply

I have a 10 day e-mail drip campaign set up in MailChimp. What's the best way to have new signups be automatically added to the list for this campagin? From what I'm reading it looks like you have to code the logic for automatic e-mails your self instead of just using mailchimp.. is this correct?

Reply

The Gibbon gem should let you do this. You can add someone to the list when they sign up. This is what I do with GoRails on registrations so that I can send the announcement emails out with Mailchimp. That *should* do the trick for you there.

Reply

Great vid, how would I get the CSS to work in the mailer.html.erb templates?

Want t to style the mailer.html.erb so that when someone get the email in their gmail or other it looks presentable - Tried styling in myself and with bootstrap but the styles don't make it with the content to the recipients email account.

Reply

Unfortunately you'll have to paste all the bootstrap styles inline into the email templates. Emails only work with limited CSS.

Reply

Nevermind - You need Inline style like this in template:<head><style> hr {color:sienna;} p {margin-left:20px;} body {background-image:url("images/back40.gif");} </style> </head>

Reply

late reply, but this can be helpful: http://foundation.zurb.com/...

Reply

Thank you very much Chris. Great video. Helped me setup up smtp for a class project.

Reply

Hello chris. I followed all the steps as you showed in this screen cast but unfortunately I am not receiving the emails. I neither setup the domain in Mandrill inbound option and all I get the response in Outbound is that Email Rejected Reason Unsigned. I don't know why. I registered to mandrill with my normal gmail account. Can you please tell me what I would be doing wrong?

Reply

It sounds like you need to verify your domain ownership. Check the note at the bottom here: https://mandrill.zendesk.co...

Reply

Thanks for the update @excid3:disqus! Yea.. wanted notify anyone else looking at this tutorial that Mandrill is a paid service after today's announcement. Perhaps a tutorial on how to set up with Amazon SES or just Gmail if the load is not heavy..? :)

Reply

That Would de great! A tutorial on either Amazon SES or Sendgrid would be highly useful!!

Reply
Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 74,071+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2023 GoRails, LLC. All rights reserved.