配置设备发送电子邮件

发布于 2024-10-28 19:08:46 字数 914 浏览 1 评论 0原文

我编写了一个自定义邮件程序,每当用户收到通知时就会发送电子邮件。 由于某种原因,自定义邮件程序可以工作,但内置的设备邮件程序无法工作。 我无法发送确认电子邮件,

是我的配置中缺少某些内容吗?

-devise.rb:

 config.mailer_sender = "[email protected]"

-setup_mail.rb:

require "development_mail_interceptor"

ActionMailer::Base.smtp_settings = {
  :address              => "smtp.gmail.com",
  :port                 => 587,
  :domain               => "gmail.com",
  :user_name            => "usename",
  :password             => "pass",
  :authentication       => "plain",
  :enable_starttls_auto => true
}



ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.register_interceptor(DevelopmentMailInterceptor) if Rails.env.development?

I wrote a custom mailer that sends an email whenever a user receives a notification.
for some reason the custom mailer works but the built in devise mailer doesn't work.
I'm not able to send confirmation emails

is something missing in my configuration ?

-devise.rb:

 config.mailer_sender = "[email protected]"

-setup_mail.rb:

require "development_mail_interceptor"

ActionMailer::Base.smtp_settings = {
  :address              => "smtp.gmail.com",
  :port                 => 587,
  :domain               => "gmail.com",
  :user_name            => "usename",
  :password             => "pass",
  :authentication       => "plain",
  :enable_starttls_auto => true
}



ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.register_interceptor(DevelopmentMailInterceptor) if Rails.env.development?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

冷清清 2024-11-04 19:08:46

我相信,调查

config/initializers/devise.rb

将为您解决问题:

config.mailer = "设计::Mailer"

你可以取消注释它!

I believe that looking into

config/initializers/devise.rb

will do the trick for you:

config.mailer = "Devise::Mailer"

you can uncomment it!

一袭白衣梦中忆 2024-11-04 19:08:46
This can be helpful. After r&D, the final complete text is below:

# ActionMailer Config in development/production rb file
  config.action_mailer.default_url_options = { :host => 'localhost:3000' }
  config.action_mailer.delivery_method = :smtp
  # change to true to allow email to be sent during development
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.default :charset => "utf-8"

  config.action_mailer.smtp_settings = {
    address: "smtp.gmail.com",
    port: 587,
    domain: "mail.google.com",####important
    authentication: "plain",
    enable_starttls_auto: true,
    user_name: ENV["GMAIL_USERNAME"],
    password: ENV["GMAIL_PASSWORD"]
  }
This can be helpful. After r&D, the final complete text is below:

# ActionMailer Config in development/production rb file
  config.action_mailer.default_url_options = { :host => 'localhost:3000' }
  config.action_mailer.delivery_method = :smtp
  # change to true to allow email to be sent during development
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.default :charset => "utf-8"

  config.action_mailer.smtp_settings = {
    address: "smtp.gmail.com",
    port: 587,
    domain: "mail.google.com",####important
    authentication: "plain",
    enable_starttls_auto: true,
    user_name: ENV["GMAIL_USERNAME"],
    password: ENV["GMAIL_PASSWORD"]
  }
轻拂→两袖风尘 2024-11-04 19:08:46

我今天发现一个问题,花了 5 个小时来解决。
当确认令牌关系列为空时,设计的确认电子邮件无法工作。当列为空时,效果很好。

#this works well
add_column :users, :confirmation_token, :string
add_column :users, :confirmed_at, :datetime
add_column :users, :confirmation_sent_at, :datetime
add_column :users, :unconfirmed_email, :string

#But this cannot work !!!
add_column :users, :confirmation_token, :string, :null => false, :default => ''
add_column :users, :confirmed_at, :datetime, :null => false, :default => '1970-01-01'
add_column :users, :confirmation_sent_at, :datetime, :null => false, :default => '1970-01-01'
add_column :users, :unconfirmed_email, :string, :null => false, :default => ''

希望在遇到这个问题时对您有所帮助。〜

I catch an issue today and I spend 5 hours on it.
Devise 's confirmation email cannot work when the confirmation_token relational columns is blank. Well when the columns is null it works well.

#this works well
add_column :users, :confirmation_token, :string
add_column :users, :confirmed_at, :datetime
add_column :users, :confirmation_sent_at, :datetime
add_column :users, :unconfirmed_email, :string

#But this cannot work !!!
add_column :users, :confirmation_token, :string, :null => false, :default => ''
add_column :users, :confirmed_at, :datetime, :null => false, :default => '1970-01-01'
add_column :users, :confirmation_sent_at, :datetime, :null => false, :default => '1970-01-01'
add_column :users, :unconfirmed_email, :string, :null => false, :default => ''

hope help U when catching this issue alike.~

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文