Sent mail to [email protected] (4079.1ms)
Date: Mon, 12 May 2014 09:18:25 +0800
From: [email protected]
To: [email protected]
Message-ID: <5370216129765_37673fde1b883a0414227@Williams-MacBook-Pro.local.mail>
Subject: =?UTF-8?Q?=E5=A4=A9=E5=A4=A9=E5=9C=88=E5=BB=BA=E8=AE=AE?=
Mime-Version: 1.0
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
<p>You have received the following email from test name ([email protected]):</p>
<p>This is test email!</p>
Rendered home/send_mail.html.erb within layouts/application (0.1ms)
Rendered layouts/_nav.html.erb (0.1ms)
Rendered layouts/_footer.html.erb (0.1ms)
Completed 200 OK in 4117ms (Views: 18.2ms | ActiveRecord: 0.0ms)
上面 console 的 log 应该是发送成功了 但是 Gmail 账户里没有接收到邮件!
development.rb
onfig.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => 'localhost:3000',
:user_name => 'huqius',
:password => 'huqiuspassword',
:authentication => 'plain',
:enable_starttls_auto => true }
#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
Mailer.rb
class Mailer < ActionMailer::Base
#default from: "[email protected]"
default from:"[email protected]"
def contact_email(name,email,body)
@name = name
@email = email
@body = body
mail to: "[email protected]", subject: '测试邮件'
#mail :to => user, :from => "[email protected]", :subject => "关心用户"
end
end