Reputation: 6907
First, let me specify that I am aware that ActionMailer does NOT send emails by default in development mode.
Also, I took a look at similar questions, and none of them was relevant to my situation.
So, here we go:
I am following this Site Point tutorial by Ilya Bodrov-Krukowski, from March 26, 2015 in order to install and setup Devise on my Rails 4 app.
Because we activated Devise's confirmable
module, I need to send emails in development to allow users who signup to activate their account and login.
Whenever I create a new user (through http://localhost:3000/users/sign_up
), I do get the following alert:
A message with a confirmation link has been sent to your email address. Please follow the link to activate your account.
——————————
UPDATE
In my development.log file, I can see that the email was "sent":
Devise::Mailer#confirmation_instructions: processed outbound mail in 172.1ms
Sent mail to [email protected] (54.4ms)
Date: Tue, 25 Aug 2015 12:15:15 -0700
From: [email protected]
Reply-To: [email protected]
To: [email protected]
Message-ID: <[email protected]>
Subject: Confirmation instructions
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
<p>Welcome [email protected]!</p>
<p>You can confirm your account email through the link below:</p>
<p><a href="http://localhost:3000/users/confirmation?confirmation_token=ZsL_iQVxfDQd7mB1RkGf">Confirm my account</a></p>
[1m[35m (0.8ms)[0m commit transaction
Redirected to http://localhost:3000/
Completed 302 Found in 560ms (ActiveRecord: 1.7ms)
And, when I copy and paste the link from the log into my browser, then I get the following alert:
Signed in successfully.
So, it seems the only thing that is not working is the actual sending / receiving of the email.
——————————
As recommended in the tutorial, I followed Rails documentation regarding ActionMailer configuration and here is what I have in my config/environments/development.rb file
:
config.action_mailer.delivery_method = :sendmail
# Defaults to:
# config.action_mailer.sendmail_settings = {
# location: '/usr/sbin/sendmail',
# arguments: '-i -t'
# }
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_options = {from: '[email protected]'}
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
Obviously, I am missing something, but I cannot figure out what (I am very, very junior with Rails).
Any idea?
Upvotes: 3
Views: 2421
Reputation: 34336
Mail is not sent in development by default. To enable this you have to set config.action_mailer.perform_deliveries = true
in development.rb
file which I see you already have.
You may also have to enable config.action_mailer.raise_delivery_errors = true
to raise delivery errors. That way, you will be able to see if there are any errors in the email delivery process.
Also, double check your default from
if that has a valid email.
Also try switching the delivery method to sendmail
:
config.action_mailer.delivery_method = :sendmail
This should solve your issue.
Upvotes: 4
Reputation: 658
You need a mail server for Action Mailer to send emails. such as MailGun which has a free account and a gem which makes set up easy. mailgun_rails
Upvotes: 0