SendGrid with Symfony: Mailer DSN over SMTP
In .env:
MAILER_DSN=smtp://smtp.sendgrid.net:587
Set the DSN username to the literal string apikey and the DSN password to your SendGrid API key (at least Mail permissions) via your env management; in a real .env that looks like smtp://apikey value YOUR_KEY_AT_smtp.sendgrid.net:587. Never commit the real value.
Then send with a verified from address:
use Symfony\Component\Mime\Email;
$email = (new Email())
->from('[YOUR_VERIFIED_SENDER]') // verified sender
->to('[RECIPIENT_EMAIL]')
->subject('subject here')
->text('plain body');
$mailer->send($email);
Checklist:
1. Username apikey, not your email. Wrong username is the standard auth failure.
2. Port 587 with TLS. Symfony picks TLS for the smtp:// scheme on 587.
3. The from address must be verified in SendGrid.
4. In dev, use a null or file transport so you do not send real mail.