Gmail SMTP 与 Rails 3
我正在尝试使用 Gmail 帐户发送确认电子邮件。我环顾四周,没有什么明显的东西。没有错误或任何东西,它只是不发送
我将其作为初始化器:
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:user_name => "<address>@gmail.com",
:password => "<password>",
:authentication => "plain",
:enable_starttls_auto => true
}
ActionMailer::Base.default_url_options[:host] = "localhost:3000"
I am trying to get a confirmation email sending using a gmail account. I have looked around and there is nothing that is obvious. There is no errors or anything, it just dosn't send
I have this as the initalizer:
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:user_name => "<address>@gmail.com",
:password => "<password>",
:authentication => "plain",
:enable_starttls_auto => true
}
ActionMailer::Base.default_url_options[:host] = "localhost:3000"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
至少在 Rails 3.2 中,您不再需要
tlsmail
gem这已经足够了
来自全能指南 gmail 的 ActionMailer 配置
You don't need
tlsmail
gem anymore at least with Rails 3.2This will be sufficient
From the all-mighty-guide ActionMailer configuration for gmail
将 tlsmail 添加到 gemfile
run :
将这些设置添加到 config/envirnoments/development.rb 文件
add tlsmail to gemfile
run :
add these settings to config/envirnoments/development.rb file
您应该检查[电子邮件受保护] 是否已实际上发送了电子邮件。过去,我们在通过 Gmail 的 SMTP 服务器发送验证电子邮件时遇到过此问题,因为批量发送最终根本无法发送。
我建议您登录[email protected]并验证是否没有问题并且电子邮件已发送。
如果没有,您可能需要尝试使用 Send Grid 等服务来发送外发电子邮件。
或者,您可以查看您的服务器。或者,如果您正在进行开发,请查看
log/development.log
。我很确定您可以在日志中看到它实际上正在尝试发送邮件。问题是 Google 不信任您的本地 IP 地址,因此您的邮件不会被发送(甚至不会发送到垃圾邮件目录)。除了使用白名单服务器之外,没有其他方法可以解决此问题。
您可以通过将应用程序部署到 Heroku 等生产服务器中并在那里进行测试来尝试这一点。
You should check that [email protected] has actually sent the email. We have had issues with this in the past when sending verification emails out through Gmail's SMTP server, since sending in bulk end up not sending at all.
I suggest you log into [email protected] and verify that there are no problems and that the emails are sent.
If not, you may want try a service like Send Grid to send outgoing emails.
Alternatively, you can look into your server. Or if you are in development, have a look at
log/development.log
. I'm pretty sure that you can see in your logs that it's actually trying to send the mail.The problem is that Google doesn't trust your local IP address and your mails won't get delivered (not even to the spam directory). There is no way to work around this but using a white-listed server.
You can try this out by deploying your app into a production server like Heroku and test it there.
的意思是填写你的真实用户名?
也是如此The
<username>
means to fill in your real username? So does the<password>