简体   繁体   English

动作邮件程序不发送电子邮件

[英]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.

相关问题 Rails Action Mailer不发送邮件 - Rails Action Mailer doesn't send mails Rails 3 +动作邮件程序 - 无法循环发送电子邮件 - Rails 3 + action mailer - Cannot loop to send emails Mailer不发送电子邮件。 Rails 5. Hostgator邮件服务器 - Mailer doesn't send emails. Rails 5. Hostgator mail server 使用动作邮件发送大量电子邮件的基于性能的方法是什么? - what is a performance oriented method to send mass emails using action mailer? 在Rails中,如何使用mdaemon邮件服务器通过Action Mailer发送电子邮件? - In rails, How to send emails with action mailer using mdaemon mail server? Ruby Action Mailer:我如何发送每日电子邮件? - Ruby Action Mailer: How can I send daily emails? 在heroku上使用Action Mailer安排电子邮件 - Scheduling emails with Action Mailer on heroku Rails Action Mailer:电子邮件中的图像 - Rails Action Mailer: images in emails 使用动作邮件发送电子邮件时,有没有办法使内嵌图像响应? - is there a way to make inline images responsive when using action mailer to send emails? 如果没有针对所有域的 IAM 策略设置,则无法使用 AWS SES 和 Rails 的 Action Mailer 发送电子邮件 - Cannot send emails using AWS SES and Rails' Action Mailer without IAM Policy settings for all domains
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM