简体   繁体   English

邮件无法发送通过动作邮件栏

[英]mail not send througth action mailer rails

I am trying implementing send mail through action mailer in rails related code are.. 我正在尝试在Rails相关代码中通过Action Mailer实现发送邮件..

development.rb development.rb

 config.action_mailer.default_url_options = { host: 'localhost', port: 9292}

 config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
   :address     =>"smtp.gmail.com",
    :domain      =>"gmail.com",
   :port        => 587,
   :user_name   =>"Debasis",
   :password    =>"************",
   :authentication =>"plain",
   :enable_starttls_auto =>true
   }

my mailers/user_mailer.rb 我的mailers / user_mailer.rb

class UserMailer < ActionMailer::Base
    default :from => "bkdebasish90@gamil.com"
    def registration_confirmation(user)
    mail(:to=>user.email, :subject =>"Registered")
   end
end

users.controller is users.controller是

  def create
   @user = User.new(user_params)
   respond_to do |format| 
if @user.save
  UserMailer.registration_confirmation(@user).deliver_now
  format.html { redirect_to @user, notice: 'User was successfully created.'       
}
  format.json { render :show, status: :created, location: @user }
     else
  format.html { render :new }
  format.json { render json: @user.errors, status: :unprocessable_entity }
    end
     end
    end  

but my email is not sent...what can i do? 但是我的电子邮件没有发送...我该怎么办?

I ca see you are using Gmail, so assuming you are using 2-factor authentication, you need to create an app specific password to put into config, rather than your own. 我可以看到您使用的是Gmail,因此假设您使用的是2要素身份验证,则需要创建一个应用专用密码才能放入配置,而不是您自己的密码。

Try setting config.action_mailer.raise_delivery_errors = true in your development environment file to see any errors that happen 尝试在开发环境文件中设置config.action_mailer.raise_delivery_errors = true以查看发生的任何错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM