我有一個Rails應用程序,它使用表單收集消息詳細信息並通過電子郵件將消息發送到我的gmail/yahoo帳戶。操作郵件程序錯誤:535-5.7.8用戶名和密碼不被接受
我已經加入這個在配置/初始化爲setup_mail.rb:
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:user_name => "my_user",
:password => "my_pass",
:authentication => "plain",
:enable_starttls_auto => true
}
和使用控制器,像這樣的POST路線:
def create
@message = Message.new(params[:message])
if @message.valid?
NotificationsMailer.new_message(@message).deliver!
redirect_to(root_path, :notice => "Message was successfully sent.")
else
flash.now.alert = "Please fill all fields."
redirect_to('#')
end
end
消息參數是從接受的形式乾淨像這樣:
Parameters: {"utf8"=>"✓", "authenticity_token"=>"4xgV0umvaTPzYxd18qdJq/GT7QCdXjrPTGR7D9R3AC4=", "message"=>{"name"=>"Deepak", "email"=>"[email protected]", "subject"=>"Hi", "body"=>"Hi"}, "commit"=>"Send"}
無論我使用的是Yahoo憑證還是Gmail憑證e設置,我不斷收到相同的錯誤信息。我評論了ActionMailer :: Base.smtp_settings中的所有設置,但仍然遇到此問題。這使我相信這個問題可能與此代碼之外的其他內容有關,但我不知道。
-Deepak
您是否允許外部連接在您的Google帳戶首選項中發送電子郵件? – okliv
我看不到傳出郵件的設置。我已經啓用了Gmail上的IMAP設置,但仍然是相同的錯誤。它是否正確?傳出和傳入的郵件都來自我的gmail ID。 – user2738707
當我有同樣的問題,並登錄到谷歌郵件時,我看到有人想從外部發送我的帳戶的電子郵件的頁面頂部的通知字符串。並有一個按鈕 - 允許此操作(或類似的東西),也檢查用戶名是否以'@ gmail.com'結尾 – okliv