ruby-on-rails – 535-5.7.8用户名和密码不被接受错误
发布时间:2020-12-17 02:24:49 所属栏目:百科 来源:网络整理
导读:我使用动作邮件程序通过我的Gmail帐户发送邮件时收到此错误. Net::SMTPAuthenticationError in SweepstakesController#show 535-5.7.8 Username and Password not accepted. Learn more at: ParticipantMailer.winner_confirmation(@result).deliver_now! 我
我使用动作邮件程序通过我的Gmail帐户发送邮件时收到此错误.
我已经仔细检查了我的电子邮件和密码,我已经重新启动了我的服务器,我也在这里完成了所有与此错误相关的问题并实施了每个答案,但无济于事. config.action_mailer.default_url_options = { host: 'localhost',port: 3000} ActionMailer::Base.delivery_method= :smtp ActionMailer::Base.smtp_settings = { :address =>"smtp.gmail.com",:port => 587,:domain => "gmail.com",:user_name => "my_email@gmail.com",:password => "my_password",:authentication => 'plain',:openssl_verify_mode => 'none' } 控制器中的逻辑: def show @sweepstake = Sweepstake.find(params[:id]) @participant = Participant.where(:sweepstake_id => @sweepstake.id ) b = @sweepstake.winner_count @result = Array.new b.times do @result << @participant[rand(@participant.count)] end ParticipantMailer.winner_confirmation(@result).deliver_now! end participant_mailer.rb文件: class ParticipantMailer < ApplicationMailer default from: 'rajesh010794@gmail.com' def winner_confirmation(result) @result = result @url = 'http://example.com/login' Rails.logger.info(@result.inspect) @result.each do |i| mail(to: i.participant_email,subject: 'Congratulation') end end end 解决方法
我找到了答案Goto config / initializers / setup_mail.rb检查那里的配置是否与development.rb文件中编写的配置相匹配.它应该在两个文件中看起来如下所示:
config.action_mailer.smtp_settings = { :address =>"smtp.gmail.com",:user_name => "my_mail@gmail.com",:password => "**********",:enable_starttls_auto => true,:openssl_verify_mode => 'none' } 这解决了我的问题. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |