[英]Action mailer doesn't send emails
whith this noitifier 这个提神剂
class Notifier < ActionMailer::Base
default_url_options[:host] = "url"
def deliver_password_reset_instructions(user)
@user = user
@subject = 'Password reset instructions.'
@sent_on = Time.now
#default host is defined in development.rb configuration file
@edit_password_reset_url = url_for :controller => 'password_reset', :action => 'edit'
@edit_password_reset_url += "?id=#{user.perishable_token}"
mail to: user.email
end
end
and with this configuration on config/environments/development.rb 并在config / environments / development.rb上使用此配置
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_url_options = {
:host => 'localhost',
:port => '3000'
}
# Options: :smtp, :test
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => 'smtp.gmail.com',
:port => 587,
:domain => 'gmail.com',
:user_name => 'mymail',
:password => 'mypassword',
:authentication => :plain,
:enable_starttls_auto => true }
It doesn't send nothing ,what is wrong? 它什么都不发送,怎么了?
Setup action mailer as in this post Actionmailer not working when I change gmail password 如本文中所述,设置操作邮件程序, 当我更改gmail密码时,Actionmailer无法正常工作
Edit notifier as:- 将通知程序编辑为:-
class Notifier < ActionMailer::Base
default from: "test@example.com"
def deliver_password_reset_instructions(user)
@user = user
@sent_on = Time.now
#default host is defined in development.rb configuration file
@edit_password_reset_url = url_for :controller => 'password_reset', :action => 'edit'
@edit_password_reset_url += "?id=#{user.perishable_token}"
mail to: user.email, :subject => "Password reset instructions."
end
end
In password_reset_controller:-- 在password_reset_controller中:
def create
#send email as
Notifier.deliver_password_reset_instructions(user)
end
In app/views/notifier/ create a page named as deliver_password_reset_instructions.html.erb and put the content which is sent in the mail. 在app / views / notifier /中,创建一个名为delivery_password_reset_instructions.html.erb的页面,然后将发送的内容放入邮件中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.