服务器指出电子邮件被发送到正确的地址,但我不会在我的收件箱收到消息。
我为setup_mail.rb文件
ActionMailer::Base.smtp_settings ={
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:user_name => "[email protected]",
:password => "my_password",
:authentication => "Plain",
:enable_starttls_auto => true
}
我development.rb
文件是:
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true #default value
config.action_mailer.delivery_method = :smtp #default value
我test.rb
文件是:
config.action_mailer.delivery_method = :smtp
我曾尝试多种变化和很失落。我在Windows 7计算机上运行。我运行的Ruby 1.8.7和Rails 3.0.7
任何人都可以帮忙吗?
下面是我创建的方法:
def create
@user = User.new(params[:user])
if @user.save
UserMailer.registration_confirmation(@user).deliver
sign_in @user
redirect_to @user, :flash => { :success => "Welcome to the Sample App!" }
else
@title = "Sign up"
render 'new'
end
end
我user_mailer.rb类UserMailer <::的ActionMailer基地
default :from => "[email protected]"
def registration_confirmation(user)
mail(:to => user.email, :subject => "Thanks for registering")
end
end
看看你的服务器。我敢肯定,你可以在你的日志,它的实际上是试图发送邮件看到的。
问题是,谷歌不信任你的本地IP地址和您的邮件不会递送(甚至没有到垃圾邮件目录)。有没有办法来解决这一点,但使用列入白名单的服务器。
如果您尝试在生产中你的应用程序这应该正常工作,例如部署应用的Heroku进行测试。
尝试在年底投入.deliver
。这固定我这个问题:
mail(:to .....).deliver!
尝试从字符串到符号改变认证。
ActionMailer::Base.smtp_settings ={
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:user_name => "[email protected]",
:password => "my_password",
:authentication => :plain,
:enable_starttls_auto => true
}
你应该检查[email protected]实际上已经发送的电子邮件。通过Gmail的SMTP服务器发送的验证邮件的时候了,因为在批量发送最终没有发送所有我们过去有问题,与此有关。
我建议你登录到[email protected]并确认不存在任何问题,而且电子邮件被发送。
如果没有,你可能想尝试像Send Grid服务来直接发送邮件。
我有同样的问题,我能看到,在我的控制台邮件被发送,但在收件箱中什么也没出现,有一件事是,你可以像Heroku的白名单的服务器上部署应用程序,或者如果你想看到只是用于测试目的通过当地刚刚启用浏览器的安全性较低的应用程序,你应该能够看到邮件在收件箱中https://myaccount.google.com/lesssecureapps