我在我的网络应用程序中发送电子邮件时遇到了一些问题。当我运行开发时,即使在控制台中显示为已发送,也不会发送电子邮件。
这是我在 config/environments/development.rb 中的设置
# Email
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: '587',
enable_starttls_auto: true,
user_name: ENV["gmail_username"],
password: ENV["gmail_password"],
authentication: :plain,
domain: 'gmail.com'
}
在我的 Controller 中,我使用这个调用发送邮件:
JobMailer.send_accept_job_mail(@app_user, @job.id).deliver
邮件在控制台中显示为“已发送”,但未发送到指定的邮件。
最佳答案
您需要使用 deliver!立即发送邮件。
只需更新代码即可
JobMailer.send_accept_job_mail(@app_user, @job.id).deliver!
-- 根据评论,编辑为使用 deliver!
方法。
关于ruby-on-rails - ActionMailer 不在开发 Rails 5 中发送邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42952193/