Rails 4 Sendgrid 集成出错 - 不允许未经身份验证的发件人 [英] Rails 4 Sendgrid integration giving error - Unauthenticated senders not allowed

查看:63
本文介绍了Rails 4 Sendgrid 集成出错 - 不允许未经身份验证的发件人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Rails 4 服务器上集成了 Sendgrid 设置.这些设置适用于开发环境.但这在生产环境中会出错.

I have integrated Sendgrid settings on a Rails 4 server. These settings work fine for development environment. But this is giving error on production environment.

Net::SMTPFatalError (550 Cannot receive from specified address <simmi@mydomain.com>: Unauthenticated senders not allowed)

config/initializers/email_setup.rb

config/initializers/email_setup.rb

ActionMailer::Base.smtp_settings = {
   :address              => "smtp.sendgrid.net",
   :domain               => DOMAIN,
   :user_name            => ENV['SENDGRID_USERNAME'],
   :password             => ENV['SENDGRID_PASSWORD'],
   :authentication       => "plain",
   :enable_starttls_auto => true
}

config/initializers/devise.rb

config/initializers/devise.rb

config.mailer_sender = 'simmi@mydomain.com'

config/environments/production.rb

config/environments/production.rb

# Default URL
config.action_mailer.default_url_options = { host: 'mysite.mydomain.com' }

DOMAIN = 'mysite.mydomain.com'

推荐答案

根据 sendgrid 支持团队的说法,当用户名或密码不正确时会出现此错误.我尝试通过 telnet 手动登录到 smtp 服务器,它工作正常.

According to sendgrid support team, this error comes when username or password are incorrect. I tried logging manually into the smtp server through telnet and it was working.

在我的服务器命令行上,我按照以下步骤操作:

On my server commandline, I followed these steps:

telnet smtp.sendgrid.net 587
EHLO
AUTH LOGIN
Enter username in Base64
Enter password in Base64

将文本转换为 Base64 的链接 - http://www.opinionatedgeek.com/dotnet/tools/base64encode/

Link to convert text into Base64 - http://www.opinionatedgeek.com/dotnet/tools/base64encode/

ENV 变量在我的生产环境中以某种方式不起作用.作为一种解决方法,我尝试直接添加用户名和密码并且成功了.

The ENV variables were somehow not working on my production environment. As a workaround, I tried adding the username and password directly and it worked.

这篇关于Rails 4 Sendgrid 集成出错 - 不允许未经身份验证的发件人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆