Symfony Google Mailer
Gmail SMTP transport bridge for Symfony Mailer, configured through a single DSN.
Repository Health
Technical Analysis
Symfony Google Mailer is a small bridge package that plugs Gmail’s SMTP servers into Symfony Mailer as a first-class transport. Rather than manually configuring an SMTP transport with Gmail’s host, port, and TLS settings, developers set MAILER_DSN=gmail+smtp://USERNAME:APP-PASSWORD@default and Symfony Mailer routes mail through smtp.gmail.com:465 automatically.
It’s one of many symfony/*-mailer bridge packages (alongside Mailgun, Postmark, SendGrid, etc.) that let applications swap mail providers by changing a DSN string instead of transport wiring code.
What You Get
GmailTransportFactoryrecognizinggmail,gmail+smtp, andgmail+smtpsDSN schemesGmailSmtpTransportpre-wired tosmtp.gmail.com:465with implicit TLS- Drop-in integration with Symfony Mailer’s existing
MAILER_DSNconfiguration convention - Optional PSR-14 event dispatcher and PSR-3 logger wiring inherited from
EsmtpTransport
Common Use Cases
- Symfony applications that want to send transactional or notification email through a personal or Workspace Gmail account
- Small projects or internal tools that don’t warrant a dedicated transactional email provider
- Swapping between Gmail and another provider by changing only the
MAILER_DSNenvironment variable
Under The Hood
Architecture — The bridge follows Symfony Mailer’s transport-factory pattern: GmailTransportFactory extends AbstractTransportFactory and implements getSupportedSchemes() plus create(), which builds a GmailSmtpTransport from the DSN’s username/password. GmailSmtpTransport itself is a thin subclass of EsmtpTransport, hard-coding the Gmail SMTP host, port 465, and implicit TLS in its constructor, then delegating everything else — message building, envelope handling, connection management — to the parent ESMTP implementation.
Tech Stack — PHP 8.4+, PSR-4 autoloaded under Symfony\Component\Mailer\Bridge\Google. Its only hard dependency is symfony/mailer (^7.4|^8.0); symfony/http-client is a dev-only dependency used for the factory’s test suite.
Code Quality — A single test file, Tests/Transport/GmailTransportFactoryTest.php, covers scheme recognition and transport creation via PHPUnit. The actual SMTP transport logic is inherited from Symfony Mailer’s well-tested EsmtpTransport, so this package’s own footprint is small and low-risk by design.
API Design — Zero code changes are required to adopt it beyond installing the package and setting a DSN string — gmail+smtp://USERNAME:APP-PASSWORD@default — which Symfony Mailer resolves automatically via its transport factory registry. The password field expects a Gmail App Password rather than the account password, consistent with Google’s SMTP authentication requirements.