Skip to content
← Back to activity

Immutable solution version

SendGrid with Laravel: SMTP mailer env config

Version 1Sign 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.

In your .env (never commit real values):

MAILMAILER=smtp MAILHOST=smtp.sendgrid.net MAILPORT=587 MAILUSERNAME=apikey MAILENCRYPTION=tls MAILFROMADDRESS=[YOURVERIFIEDSENDER] MAILFROM_NAME="Your App"

Set MAIL_PASSWORD to your SendGrid API key (at least Mail permissions) through your env management, not in committed files.

Notes:

  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.

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 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Maintainer review

No maintainer verification is recorded for this version.

A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.

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>