((I've found similar questions to mine, but they are specific to a 3rd party mandrill gem, or Heroku. I'm not using any of those, just the mandrill-api itself.))
I'm trying to use email confirmation (we use Devise) for account creation. I've set up confirmable, everything with that works well. Initially, I used the basic Devise emails for everything, and it was fine and sending - but then I tried to switch it to our MailChimp/Mandrill account, and emails won't send. I've tried everything I can think of, and I'm stuck.
Note that it seems to communicate with Mandrill - when I delete the confirmation-instructions template from MailChimp, or don't send it over to Mandrill, I get a template not found error. But when I create the template, it never actually sends.
The only thing in the logs is:
NotificationMailer#confirmation_instructions: processed outbound mail in 5676.4ms
The mailer:
class NotificationMailer < ActionMailer::Base
require 'mandrill'
default from: "XXXXXXXXX <[email protected]>"
def mandrill_client
@mandrill_client ||= Mandrill::API.new MANDRILL_API_KEY
end
def confirmation_instructions(record, token, opts={})
template_name = "confirmation-instructions"
template_content = []
message = {
to: [{email: record.email}],
subject: "Confirmation Instructions",
var_user_email: record.email,
merge_vars: [
{rcpt: record.email,
vars: [
{name: "USER_EMAIL", content: record.email},
{name: "CONFIRMATION_LINK", content: user_confirmation_url(confirmation_token: token)}
]
}]
}
mandrill_client.messages.send_template template_name, template_content, message
end
end
Development.rb file relative parts:
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = { host: '192.168.33.111' }
config.action_mailer.smtp_settings = {
address: "smtp.mandrillapp.com",
port: 587,
enable_starttls_auto: true,
user_name: "XXXXXXXXXXXXXXXXX",
password: "XXXXXXXXXXXXXXXXXX",
authentication: "login",
}
I also tested it from the console, and it gave no errors there either. There seem to be no errors at all, but the email never sends. Any ideas?
So after much pain, I'm still not entirely sure what was wrong with the mailer format originally, but I changed it a little basing it on other websites approaches, to the following, and it worked. I changed nothing else.
Note that the
field isn't used, I'm still tweaking it - just wanted to post this so others may be spared the pain I was from MailChimp/Mandrill's rediculously tedious formatting and terrible documentation.
And just for info, the only gem i used was the mandrill-api gem: