gpt4 book ai didi

ruby-on-rails - Rails Devise 发送邮件

转载 作者:行者123 更新时间:2023-12-04 06:08:28 25 4
gpt4 key购买 nike

我是通过 Rails 发送邮件的新手。我已经在我的项目中实现了设计,现在我想发送一封欢迎电子邮件和/或一封密码重置电子邮件。我需要在 Devise View 中进行哪些更改?没有显示任何错误,但我仍然没有收到任何电子邮件。

我点击了这些链接,最后我的 devise.rb、development.rb 和 production.rb 文件如下:

===设计.rb ===

 config.mailer_sender = "xxx@gmail.com"

===development.rb==

  config.action_mailer.raise_delivery_errors = false

config.action_dispatch.best_standards_support = :builtin

config.active_support.deprecation = :notify
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = false
config.action_mailer.raise_delivery_errors = true

config.action_mailer.default :charset => "utf-8"


config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.active_support.deprecation = :log

config.action_mailer.smtp_settings ={
:enable_starttls_auto => true,
:address => 'smtp.gmail.com',
:port => 587,
:tls => true,
:domain => 'gmail.com',
:authentication => :plain,
:user_name => 'xxx@gmail.com',
:password => 'xxxxxx'
}

=====production.rb===
config.action_mailer.default_url_options = { :host => 'gmail.com' }

config.active_support.deprecation = :notify
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors =false
config.action_mailer.default :charset => "utf-8"

config.action_mailer.smtp_settings = {
:enable_starttls_auto => true,
:address => 'smtp.gmail.com',
:port => 587,
:tls => true,
:domain => 'gmail.com',
:authentication => :plain,
:user_name => 'xxx@gmail.com',
:password => 'xxxxxx'
}

最佳答案

尝试像这样设置 raise_delivery_errors = true:

config.action_mailer.perform_deliveries = true # Set it to false to disable the email in dev mode
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = { :host => "localhost:3000" }


ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:authentication => :plain,
:user_name => "user@gmail.com",
:password => "password"
}

关于ruby-on-rails - Rails Devise 发送邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6993245/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com