How to implement Sendgrid with Rails 6 using credentials

877 Views Asked by At

I'm having difficulties integrating Sendgrid with Rails 6, and I'm a bit lost at the moment because according to my terminal, emails are being sent to the corresponding email address.

OrderMailer#receipt: processed outbound mail in 17.9ms
Delivered mail [email protected] (8.1ms)
Date: Sun, 12 Jul 2020 17:28:07 +0200
From: [email protected]
To: *******@gmail.com
Message-ID: <[email protected]>
Subject: Thank you for ordering from AnotherPin!
Mime-Version: 1.0
Content-Type: multipart/alternative;
 boundary="--==_mimepart_5f0b2c075ceb9_c10148702043a";
 charset=UTF-8
Content-Transfer-Encoding: 7bit


----==_mimepart_5f0b2c075ceb9_c10148702043a
Content-Type: text/plain;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

Thank you for your order!
-------------------------

Order ID: 148


Name: John Doe


Total price: $18.00


Thanks for your support!


----==_mimepart_5f0b2c075ceb9_c10148702043a
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

However, when I check the test email inbox, the messages are never received, even checking the spam folder.

I'm puzzled, because I'm not receiving any error messages in my rails console.

Here is what I've included in my development.rb:

  config.action_mailer.smtp_settings = {
  address:              'smtp.sendgrid.net',
  port:                 587,
  domain:               '[email protected]',
  user_name:             'apikey',
  password:              Rails.application.credentials[Rails.env.to_sym][:sendgrid_username],
  authentication:       'plain',
  enable_starttls_auto: true }

I know that as of April 2020, Sendgrid requires the verification of senders to use any of their services, so I've succesfully proceeded with doing so. Still, it appears that my messages are not being sent to the test email inbox's.

Does any have any idea why it might be that I see them being sent in my terminal, but not in my actual inbox.

0

There are 0 best solutions below