配置设计发送电子邮件
问题描述:
我写了一个自定义邮件程序,每当用户收到通知时都会发送一封电子邮件。 由于某些原因自定义邮件工程,但内置的设计邮件不起作用。 我无法发送确认电子邮件配置设计发送电子邮件
在我的配置中缺少某些东西吗?
-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?
答
我认为,寻找到
配置/初始化/ devise.rb
会做t他欺骗了你:
config.mailer = “制定::梅勒”
你可以取消它!
答
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"]
}
答
我今天遇到问题,我花了5个小时。 当confirmation_token关系列为空时,Devise的确认电子邮件无法工作。那么,当列是空的,它运作良好。
#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 => ''
希望帮助都抓住这个问题当U。〜
什么错误/异常你好吗? – 2011-04-03 07:33:10
没有,开发日志写道,电子邮件已发送,但我从来没有收到它 – Gady 2011-04-03 08:41:08
它最终在哪里?系统是否通过网络与'smtp.gmail.com'交谈?你能否以某种方式增加错误记录级别? – 2011-04-03 08:43:06