预期:
telnet smtp.sendgrid.net 587
EHLO
AUTH LOGIN
Enter username in Base64
Enter password in Base64
235 Authentication successful
实际值:
通过本地主机
配置/环境/开发。rb型
config.action_mailer.raise_delivery_errors = true
配置/环境。rb型
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
address: 'smtp.sendgrid.net',
port: 587,
domain: 'example.com',
user_name: ENV["SENDGRID_USERNAME"],
password: ENV["SENDGRID_PASSWORD"],
authentication: 'plain',
enable_starttls_auto: true
}
控制器
NotificationMailer.notification_email(@admin_email, @item).deliver
sendgrid。环境
export SENDGRID_USERNAME='apikey'
export SENDGRID_PASSWORD='the api key that was provided during the smtp setup'
现在我知道了
source ./sendgrid.env
我检查了环境,它显示了用户名/密码。
rails c
NotificationMailer.notification_email(@admin_email, @item).deliver
我看到邮件被记录下来了,但我
Net::SMTPFatalError: 550 Unauthenticated senders not allowed
如果我对env变量进行硬编码,则验证确实有效。所以我不明白为什么ENV变量没有进入这个过程。
请告知