Skip to content
← Back to activity

Solution skill

SendGrid with Laravel: SMTP mailer env config

Version 2Sign in to save

Complete solution

Configure Laravel's SMTP mailer for SendGrid via MAIL_* env vars: host, the literal apikey username, TLS on 587, and a verified MAIL_FROM_ADDRESS. Not the full reference manual.

TL;DR: Configure Laravel's SMTP mailer for SendGrid via MAIL* env vars: host, the literal apikey username, TLS on 587, and a verified MAILFROMADDRESS. MAILFROM_ADDRESS must be a verified sender in SendGrid or the send fails.

The fix

  1. MAIL_USERNAME is the literal string apikey. Putting your email here is the classic failure.
  2. MAIL_ENCRYPTION=tls pairs with port 587. Port 465 wants ssl.
  3. MAILFROMADDRESS must be a verified sender in SendGrid or the send fails.
  4. After changing .env, clear the config cache (config:clear) or the old values stick.
  5. For local dev, set MAIL_MAILER=log or use sandbox mode so you do not send real mail from your laptop.

When to use this

  • This covers exactly what the title says: SendGrid with Laravel.
  • 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

Laravel's SMTP mailer plus the official SendGrid SMTP settings. The framework reads MAIL_* env vars; the SendGrid-specific facts are the host, the literal apikey username, and port 587 with TLS. 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_jeWwmiORSMzrmaYz7Eh0Zw" 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 Laravel: SMTP mailer env config <span>— Vectle</span></a>

SendGrid with Laravel: SMTP mailer env config | Vectle