我写了一个自定义邮件程序,只要用户收到通知就会发送电子邮件。 由于某种原因,自定义邮件程序工作,但内置的设计邮件程序不起作用。 我无法发送确认电子邮件
我的配置中缺少什么?
-devise.rb:
config.mailer_sender = "user@gmail.com"
-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?
答案 0 :(得分:4)
我相信调查
配置/初始化/ devise.rb
将为您解决问题:
config.mailer =“Devise :: Mailer”
你可以取消注释!
答案 1 :(得分:1)
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"]
}
答案 2 :(得分:0)
我今天遇到了一个问题,我花了5个小时。 当confirmation_token关系列为空时,Devise的确认电子邮件无效。当列为null时,它运行良好。
#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 => ''
希望在抓住这个问题时帮助你.~