[英]Sendgrid returns SMTP-AUTH requested but missing user name
I am new to ruby on rails and I follow the book Learn-ruby-on-rails by Daniel Kehoe. 我是铁路上的红宝石新手,并且我遵循Daniel Kehoe撰写的《沿路学习红宝石》一书。 I have set up my sengrid login details correctly on the Ubuntu enviroment.
我已经在Ubuntu环境中正确设置了我的Sengrid登录详细信息。 echo $ SENDGRID_USERNAME returns my username correctly.
echo $ SENDGRID_USERNAME正确返回我的用户名。
However, I still get "SMTP-AUTH requested but missing user name" error when I submit the contact form. 但是,当我提交联系表时,仍然出现“请求SMTP-AUTH但缺少用户名”的错误。 I have tried to hardcode the login details and I still get the same errors.
我尝试对登录详细信息进行硬编码,但仍然出现相同的错误。 my configuration settings i smtp.sendgrid.net on port 587 and I allow send mails in development.
我的配置设置是在端口587上的smtp.sendgrid.net,并且允许在开发中发送邮件。
Please what am I not doing right. 请我做错了什么。 Thanks a lot.
非常感谢。
My user_mailer.rb is as shown: 我的user_mailer.rb如下所示:
class UserMailer < ActionMailer::Base
#default :from => "do-not-reply@example.com"
def contact_email(contact)
@contact = contact
mail( to: => Rails.application.secrets.owner_email, from: => @contact.email, subject: => "Website Visit")
end
end 结束
while the contacts_controller.rb is shown below: 而contacts_controller.rb如下所示:
class ContactsController < ApplicationController
def new
@contact = Contact.new
end
def create
@contact = Contact.new(secure_params)
if @contact.valid?
UserMailer.contact_email(@contact).deliver_now
#TODO send message
flash[:notice] = "Message sent from #{@contact.name}."
redirect_to root_path
else
render :new
end
end
private
def secure_params
params.require(:contact).permit(:name, :email, :content)
end
end 结束
The problem arose from an omission in the config/enviroments/development.rb file I replaced 问题是由我替换的config / enviroments / development.rb文件中的遗漏引起的
user_name: Rails.application.secrets.email_provider
with: 与:
user_name: Rails.application.secrets.email_provider_username
and the problem was solved 问题解决了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.