0

I use ActionMailer to send my email through Rails, but I can't receive anything.

My development.log said:

Sent mail to mymail@gmail.com (2107ms)
Date: Wed, 07 Dec 2011 17:14:30 +0800
From: no-reply
To: mymail@gmail.com
Message-ID: <4edf2e765a139_147105390c874e3@raincole-laptop.mail>
Subject: Reset password instructions
Mime-Version: 1.0
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

<p>
  Hello mymail@gmail.com!
</p>
<p>Someone has requested a link to change your password, and you can do this through the link below.</p>
<p><a href="http://starfish.dev/users/password/edit?reset_password_token=vHtzByZmDPcS4FhcwUPP">Change my password</a></p>
<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>

But there is nothing new in my inbox or spam box.

I have set:

ruby-1.9.2-p290 :008 > Rails.application.config.action_mailer[:raise_delivery_errors]
 => true 

So, how can I see the real error logs to debug?

Edit:

I write a email.yml:

development:
  reply: "no-reply"
  host: "starfish.dev"
  smtp: 
    address: "smtp.gmail.com"
    port: 587
    domain: "starfish.dev"
    authentication: "plain"
    user_name: "mymail@gmail.com"
    password: "mypassword"
    enable_starttls_auto: true

Then in application.rb:

$EMAIL_CONFIG = ActiveSupport::HashWithIndifferentAccess.new YAML.load(File.open("#{Rails.root}/config/email.yml"))[Rails.env]
config.action_mailer.smtp_settings = $EMAIL_CONFIG[:smtp].symbolize_keys if !$EMAIL_CONFIG[:smtp].nil?

in development.rb:

config.action_mailer.delivery_method = :smtp
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true

But, it still just sends to log file, no to real address.

Lai Yu-Hsuan
  • 27,509
  • 28
  • 97
  • 164
  • Have you gave smtp settings?? – shajin Dec 07 '11 at 09:25
  • No. I just want to know how debug when SMTP settings are wrong or the SMTP server crashes. – Lai Yu-Hsuan Dec 07 '11 at 09:32
  • I think there's a mailer log that is different to the normal logs. Have you looked in RAILS_ROOT/logs to see what's there? Otherwise you may need to go and look at the smtp log (which will depend on your machine, so google it) – Taryn East Dec 07 '11 at 11:20

2 Answers2

0

have you tried telnet smtp.yoursite.com 587?
if there's no responding, please check your firewall.

Siwei
  • 19,858
  • 7
  • 75
  • 95
0

The development and test environments don't use real mailers (unless you specifically configure them). By default it just does exactly what you have noticed: it goes through all the motions of sending an email... but then doesn't actually send it, just logs the email that would have been sent.

EDIT: note that this is a reply to the original question, which did not contain any smtp settings.

Taryn East
  • 27,486
  • 9
  • 86
  • 108
  • How to configure it? I have set `config.action_mailer.perform_deliveries` and `config.action_mailer.raise_delivery_errors`. – Lai Yu-Hsuan Dec 07 '11 at 09:27
  • No - that's not what I mean. What I mean is you have to configure it to *use smtp* (or whatever mailer you use). google for "configure rails for smtp". However - I don't know why you actually need to use it. There is obviously no problem with your mailer. It works exactly as you want. Right now your mailer *is* delivering. it's delivering to the log just like it should for dev env. – Taryn East Dec 07 '11 at 09:37
  • And I have set `config.action_mailer.delivery_method = :smtp`, but, still, it sends mail to my log. – Lai Yu-Hsuan Dec 07 '11 at 09:42
  • and what about the smtp_settings ? – Taryn East Dec 07 '11 at 09:48
  • It's my smtp_settings: Rails.application.config.action_mailer.smtp_settings => {:address=>"smtp.gmail.com", :port=>587, :domain=>"starfish.dev", :authentication=>"plain", :user_name=>"mymail@gmail.com", :password=>"mypassword", :enable_starttls_auto=>true} – Lai Yu-Hsuan Dec 07 '11 at 09:56
  • Ok... would have been good to add that to the question to begin with... from your initial question it sounded like you hadn't set up smtp at all. – Taryn East Dec 07 '11 at 11:19