ela*_*key 28 actionmailer ruby-on-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"
Run Code Online (Sandbox Code Playgroud)
bru*_*cat 64
tlsmail
至少在Rails 3.2中你不再需要gem了
这就足够了
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => 'baci.lindsaar.net',
:user_name => '<username>',
:password => '<password>',
:authentication => 'plain',
:enable_starttls_auto => true }
Run Code Online (Sandbox Code Playgroud)
来自all-mighty-guide的针对gmail的ActionMailer配置
将tlsmail添加到gemfile
gem 'tlsmail'
Run Code Online (Sandbox Code Playgroud)
跑 :
bundle install
Run Code Online (Sandbox Code Playgroud)
将这些设置添加到config/envirnoments/development.rb文件中
YourApplicationName::Application.configure do
require 'tlsmail'
Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
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",
:enable_starttls_auto => true,
:authentication => :login,
:user_name => "<addreee>@gmail.com",
:password => "<password>"
}
config.action_mailer.raise_delivery_errors = true
Run Code Online (Sandbox Code Playgroud)
您应该检查my_user_name@gmail.com是否实际发送了电子邮件.我们在过去通过Gmail的SMTP服务器发送验证电子邮件时遇到了这方面的问题,因为批量发送最终根本不发送.
我建议你登录my_user_name@gmail.com并确认没有问题并且发送了电子邮件.
如果没有,您可能需要尝试发送网格等服务来发送外发电子邮件.
或者,您可以查看您的服务器.或者,如果您正在开发中,请查看log/development.log
.我很确定您可以在日志中看到它实际上是在尝试发送邮件.
问题是Google不信任您的本地IP地址,并且您的邮件将无法发送(甚至不会发送到垃圾邮件目录).没有办法解决这个问题,但使用列入白名单的服务器.
您可以通过将应用程序部署到像Heroku这样的生产服务器并在那里进行测试来尝试这一点.
归档时间: |
|
查看次数: |
31571 次 |
最近记录: |