Ruby on rails 新用户使用Desive注册时不发送电子邮件
我有我的用户模型,是用户设计的,我还添加了一个邮件器,当用户注册时给自己发送电子邮件。当我运行我的代码时,我没有得到任何错误。在命令行中,它说电子邮件已经发送,但我什么也没有收到。你认为这是什么原因 我的欢迎信(mailer):Ruby on rails 新用户使用Desive注册时不发送电子邮件,ruby-on-rails,devise,Ruby On Rails,Devise,我有我的用户模型,是用户设计的,我还添加了一个邮件器,当用户注册时给自己发送电子邮件。当我运行我的代码时,我没有得到任何错误。在命令行中,它说电子邮件已经发送,但我什么也没有收到。你认为这是什么原因 我的欢迎信(mailer): class WelcomeMailer < ApplicationMailer default :from => "jasonbig@gmail.com" def welcome_send(user) @user = us
class WelcomeMailer < ApplicationMailer
default :from => "jasonbig@gmail.com"
def welcome_send(user)
@user = user
mail to: "jasonbig@gmail.com", subject: "New user added", from: "jasonbig@gmail.com"
end
end
这些是我仅有的与ActionMailer相关的文件。如果我需要添加更多文件或更改某些内容,请告诉我
我的命令行电子邮件发送确认:尝试:
config.action_mailer.smtp_settings = {
:address => 'smtp.gmail.com',
:port => 587,
:domain => 'gmail.com',
:authentication => :login,
:user_name => 'jasonbig',
:password => 'I have entered my actual password here'
:enable_starttls_auto => true
}
以下:
看看你是否在gmail中启用了2F认证
:authentication => :plain,
此外,如果您的Gmail帐户具有双重身份验证,您需要遵循本文档中的说明:
替换
:password => LESS_SECURE_APP_GMAIL_PASSWORD,
当您尝试发送电子邮件时,它会记录一些消息吗?在命令行上,它会显示welcome_send.html.erb content。使用日志更新您的问题。对于电子邮件内容,它可能会显示有关它的信息…并添加此配置:
config.action\u mailer.perform\u deliveries=true
噢,gmail使用端口587 e认证,请参阅:相同的问题。你看到他们还有其他问题吗?在我的代码中,消息的主体是如何发送的?(我问这个问题是因为我通过一个教程得到了这个代码):身份验证=>:很简单,你收到过一封邮件,上面写着“一个不太安全的应用程序正在试图访问你的电子邮件帐户”?嘿,蒂亚戈,我如何检查我在gmail中是否有2F auth?我知道了。谢谢你的帮助
Rails.application.configure do
config.cache_classes = false
config.eager_load = false
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_mailer.delivery_method = :smtp
# these options are only needed if you choose smtp delivery
config.action_mailer.smtp_settings = {
:address => 'smtp.gmail.com',
:port => 25,
:domain => 'gmail.com',
:authentication => :login,
:user_name => 'jasonbig',
:password => 'I have entered my actual password here'
}
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.active_support.deprecation = :log
config.active_record.migration_error = :page_load
config.assets.debug = true
config.assets.digest = true
config.assets.raise_runtime_errors = true
end
config.action_mailer.smtp_settings = {
:address => 'smtp.gmail.com',
:port => 587,
:domain => 'gmail.com',
:authentication => :login,
:user_name => 'jasonbig',
:password => 'I have entered my actual password here'
:enable_starttls_auto => true
}
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'example.com',
user_name: '<username>',
password: '<password>',
authentication: 'plain',
enable_starttls_auto: true
}
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
:authentication => :plain,
:password => LESS_SECURE_APP_GMAIL_PASSWORD,