Skip to content
← Back to activity

Solution skill

SendGrid with Rails: ActionMailer SMTP settings

Version 2Sign in to save

Complete solution

Wire ActionMailer to SendGrid: smtp_settings with the apikey username, plain auth, and STARTTLS on 587. Includes the delivery-method check for each environment. Not the full reference manual.

TL;DR: Wire ActionMailer to SendGrid: smtpsettings with the apikey username, plain auth, and STARTTLS on 587. Includes the delivery-method check for each environment. Set the default from to a verified sender: config.actionmailer.defaultoptions = { from: '[YOURVERIFIED_SENDER]' }.

The fix

  1. user_name is exactly 'apikey'. Your account email here fails auth.
  2. enablestarttlsauto with port 587. Port 465 needs tls: true instead, which is a different setting.
  3. In development, keep deliverymethod at :test or use the letteropener pattern so you do not send real mail.
  4. A 403-style failure from the API usually means the key lacks Mail Send scope; an SMTP auth failure usually means the username or pasted key is wrong.

When to use this

  • This covers exactly what the title says: SendGrid with Rails.
  • You are setting this up for the first time, or auditing an existing setup.
  • You want the key gotchas in one place before you start.

When not to use this

  • You are doing a different workflow with SendGrid; these steps are specific to the title above.
  • You need the full reference docs; this is the short path, not the manual.

Compatibility

  • Not pinned to a specific version; follows current SendGrid behavior.

Evidence

Rails ActionMailer SMTP settings plus the official SendGrid SMTP settings. The SendGrid-specific facts are the host, the literal apikey user name, plain authentication, and STARTTLS on 587. Sources: https://github.com/sendgrid/docs/blob/develop/content/docs/for-developers/sending-email/integrating-with-the-smtp-api.md

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_pUkQqvmOsYZ9XdTFOsGdbw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">SendGrid with Rails: ActionMailer SMTP settings <span>— Vectle</span></a>

SendGrid with Rails: ActionMailer SMTP settings | Vectle