Hey Chris, would you recommend gem 'mandrill-rails' too? or is gem "madrill-api" better?
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.
mandrill-api gem should be for accessing their REST API which you can find here: https://mandrillapp.com/api...
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.)
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
Check out the handful of episodes just before this one to get the bigger picture.
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?
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.
Don't you usually put the ActionMailer smtp settings and everything else in the environment files?
This isn't Devise, but Devise's emails work the same way. It uses your ActionMailer config so it will send them as well.
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?
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.
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.
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.
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.
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.
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!
Ok, after all of this, it seems that in my particular app, in the AdminMailer.rb file, the “default from: 'xxxxx'" under ”Class AdminMailer < ActionMailer::Base" does not work when attempting to send a template designed in Mandrill. You need to specifically add a "from_email" call in the new_book(book) function for it work.
Also, in order to get the two arguments passed, I had to make things look like this:
user = self.user
def new_event(book, user)
Hope this helps someone out there.
Glad you got it working! As an aside, one great way to test all this is to manually create and test your emails from the Rails console. It can help you poke around and find bugs like this quicker than going through the browser.
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.
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.
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?
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.
Hi Chris, I am reading gibbon gem but unsure on what it is exactly for? Would you describe how you are using it for gorails to illustrate?
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.
Unfortunately you'll have to paste all the bootstrap styles inline into the email templates. Emails only work with limited CSS.
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?
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..? :)
I'm getting uninitialized constant AdminMailer::MANDRIL_API_KEY on rspec test, how can i add the mailers to my rspec tests?
Join 31,353+ developers who get early access to new screencasts, articles, guides, updates, and more.