邮件不通过操作邮件轨道发送



>我正在尝试在 rails 中实现通过操作邮件发送邮件相关代码是..

发展.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
   }

我的邮件/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 是

  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  

但是我的电子邮件没有发送...我能做什么?

我看到您正在使用Gmail,因此假设您使用的是2因素身份验证,则需要创建一个特定于应用程序的密码以放入配置中,而不是您自己的密码。

尝试在开发环境文件中设置config.action_mailer.raise_delivery_errors = true以查看发生的任何错误

最新更新