expected:
telnet smtp.sendgrid.net 587
EHLO
AUTH LOGIN
Enter username in Base64
Enter password in Base64
235 Authentication successful
Actual:
Via localhost
config/environments/development.rb
config.action_mailer.raise_delivery_errors = true
config/environment.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
}
controller
NotificationMailer.notification_email(@admin_email, @item).deliver
sendgrid.env
export SENDGRID_USERNAME='apikey'
export SENDGRID_PASSWORD='the api key that was provided during the smtp setup'
now I do
source ./sendgrid.env
I check the ENV, it's shows the username/password.
rails c
NotificationMailer.notification_email(@admin_email, @item).deliver
I see the email gets logged, but I get
Net::SMTPFatalError: 550 Unauthenticated senders not allowed
If I hardcode the env variables, the authentication does work. So I don't understand why the ENV variables are not getting into the process.
Please advise