Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActionMailer emails "sent" in development.log, but not received

I'm having problems actually sending via ActionMailer in development, on my localhost, with Rails 2.3.2 and Ruby 1.8.6. The development.log shows that it has "sent" the email with no errors, but the email is not received. I have tried multiple email addresses for sending and receiving and have tried multiple configs and plugins, but cannot get the email to send. Any help would be much appreciated - I feel like I'm dancing around a bunch of versions of solutions for different versions of rails and ruby and can't nail it down. I would much appreciate any comments. Thanks!

Plugins:

  • action mailer optional tls
  • smtp_tls

Different email configs:

  ActionMailer::Base.smtp_settings = {
    :enable_starttls_auto => true, #works in ruby 1.8.7 and above
    :address => 'smtp.gmail.com',
    :port => 587,
    :domain => 'example.com',
    :authentication => :plain,
    :user_name => 'testacct',
    :password => 'secret'
  }

  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    :tls => :true,
    :address => 'smtp.gmail.com',
    :port => 587,
    :authentication => :plain,
    :user_name => '[email protected]',
    :password => 'secret'
    #:enable_starttls_auto => true # for rails >= 2.2 && ruby >= 1.8.7
  }
  config.action_mailer.perform_deliveries = :true #try to force sending in development 
  config.action_mailer.raise_delivery_errors = :true 
  config.action_mailer.default_charset = "utf-8"

Development.log:

Sent mail to [email protected]

Date: Fri, 18 Dec 2009 00:27:06 -0800
From: Test Email Acct <[email protected]>
To: [email protected]
Subject: Signup
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=mimepart_4b2b3cda9088_634334302a5b7


--mimepart_4b2b3cda9088_634334302a5b7
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ww=
w.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang=3D'en' xml:lang=3D'en' xmlns=3D'http://www.w3.org/1999/xhtml'>=

  <head>
    <meta content=3D'text/html;charset=3DUTF-8' http-equiv=3D'content-typ=
e' />
  </head>
  <body>
    Welcome Email
    <p>
      user name:
      lfglkdfgklsdf
      activation link:
      http://localhost:3000/login
    </p>
  </body>
</html>

--mimepart_4b2b3cda9088_634334302a5b7--
like image 676
user117046 Avatar asked Dec 18 '09 08:12

user117046


2 Answers

Put the following in config/environments/development.rb

config.action_mailer.perform_deliveries = true 
config.action_mailer.raise_delivery_errors = true

It will override the settings in config/environment.rb

Also for rails 2.X you'll need to setup:

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  :enable_starttls_auto => true,  
  :address        => "smtp.gmail.com",
  :port           => 587,
  :domain         => "domain.com",
  :user_name      => "[email protected]",
  :password       => "secret_passsword",
  :authentication => :plain
}
like image 186
Justin Tanner Avatar answered Oct 11 '22 11:10

Justin Tanner


You need to use true and not :true.

:tls => true
...
config.action_mailer.perform_deliveries = true #try to force sending in development 
config.action_mailer.raise_delivery_errors = true 
like image 27
sarahhodne Avatar answered Oct 11 '22 09:10

sarahhodne