Reputation: 2908
Actionmailer won't send emails in development, even though they say 'sent' in the console.
gemlist:
gem 'send_grid'
development.rb:
config.action_mailer.perform_deliveries = true
config.action_mailer.default_url_options = { :host => "localhost:3000" }
setup_mail.rb:
ActionMailer::Base.smtp_settings = {
:address => "smtp.sendgrid.net",
:port => '587',
:domain => "heroku.com",
:user_name => "[email protected]",
:password => "asdfasdfasdf",
:authentication => :plain,
:enable_starttls_auto => true
}
app/mailers/user_mailer.rb:
class UserMailer < ActionMailer::Base
include SendGrid
def registration_confirmation(user)
@user = user
mail(:to => user.email, :subject => "Registered", :from => "[email protected]")
end
end
app/views/user_mailer/registration_confirmation.html.haml:
Confirm your email address please!
= accept_invitation_users_url(email_token: @user.email_token)
console:
Sent mail to [email protected] (656ms)
Date: Tue, 11 Feb 2014 13:35:11 -0500
From: [email protected]
To: [email protected]
Message-ID: <[email protected]>
Subject: Registered
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
X-SMTPAPI: {}
Confirm your email address please!
http://localhost:3000/users/accept_invitation?email_token=_JL8DQ2GItxl
Redirected to http://localhost:3000/
Completed 302 Found in 1396ms (ActiveRecord: 192.2ms)
Upvotes: 1
Views: 3280
Reputation: 987
Put this before your smtp settings:
config.action_mailer.raise_delivery_errors = true
Add ".deliver" at the end where you are calling the email method i.e.:
UserMailer.welcome_email(@user).deliver
It will raise exception that will help you to find the failure cause.
If you are using background job to send email, You can put this snippet in exception block and use ExceptionNotification gem to send email with details which will help you to catch and find the reason of failure easily.
Upvotes: 0
Reputation: 93
Add config.action_mailer.raise_delivery_errors = true
to production.rb or development.rb and restart your app to make the changes working
Upvotes: 1
Reputation: 6786
you can try setting:
config.action_mailer.raise_delivery_errors = true
to see if it raises any error on delivery. Otherwise try using other email or check it in you junk folder
Or try this in development mode to check if there is any issues there(it seems fine as you can see the confirmation in the console)
https://github.com/ryanb/letter_opener
Upvotes: 1