Skip to content

Migrate Mailer from PHPMailer to Symfony Mailer (Doppar 4.x) - #298

Merged
rrr63 merged 2 commits into
doppar:4.xfrom
techmahedy:techmahedy-4.x
Aug 29, 2026
Merged

rrr63 merged 2 commits into
doppar:4.xfrom
techmahedy:techmahedy-4.x

Conversation

@techmahedy

@techmahedy techmahedy commented Aug 29, 2026 •

Copy link
Copy Markdown
Member

Migrate Mailer from PHPMailer to Symfony Mailer (Doppar 4.x)

Summary

Doppar 3.x sent mail through PHPMailer via a driver-per-transport architecture (SmtpMailDriver, SendmailMailDriver, QmailMailDriver, MailMailDriver). This PR replaces that with Symfony Mailer for 4.x, keeps the existing Mailable authoring style (subject() / content() / attachment()) completely unchanged.

doppar/framework

Mailable.php — rebuilt as a documented, readable base class (previously a bare DTO with all email-building logic bolted on as cramped one-liners). Public API:

  • to, from, cc, bcc, attachments, subject, body (unchanged, still duck-typed against subject()/content()/attachment() on subclasses)
  • New fluent helpers: html(), text(), replyTo(), header(), tag(), metadata(), priority(), attach(), embed()
  • toEmail() builds a Symfony\Component\Mime\Email from all of the above; build(Email $email) is a subclass override hook for anything the helpers don't cover
  • Fixed: Address construction no longer throws on a null recipient name

MailService.php — orchestrates sending via Symfony Mailer:

  • to(), cc(), bcc() — recipient bookkeeping (unchanged signatures)
  • send() / deliver() (alias) — builds the Email, applies DKIM/S-MIME signing if configured, resolves a transport, and sends via Envelope::create($email)
  • Fixed a real delivery bug: the old envelope only ever listed the primary "to" address, so CC/BCC recipients got the headers but were never actually handed to the SMTP server as RCPT TO targets. Now derived from the message's own headers via Envelope::create().
  • driver(TransportInterface|string $transport) — new escape hatch to send through a one-off Symfony transport or raw DSN, replacing the old MailDriverInterface pattern with Symfony's own contract
  • resolveDsn() — assembles a DSN from mail.php's smtp parts (host/port/username/password/encryption/local_domain) when no explicit dsn is set, or passes through a literal DSN (including failover(...) / roundrobin(...) compound DSNs) when one is
  • timeout applied post-construction via SmtpTransport::getStream()->setTimeout() (Symfony has no DSN key for it)
  • applySigning() — wraps the built message in DkimSigner / SMimeSigner when enabled in config, signers lazily built and cached per-instance

Removed: MailDriverInterface and its four PHPMailer-backed drivers (Smtp/Sendmail/Qmail/MailMailDriver) — Symfony's DSN-driven Transport::fromDsn() already covers what these existed for; the driver() method above is the direct replacement extension point.

Facades/Mail.php — @method docblock updated to match the real MailService surface (to, cc, bcc, driver, send, deliver) with correct types; was previously missing driver()/deliver() and had a wrong to() signature.

composer.json — phpmailer/phpmailer removed, symfony/mailer: ^8.1 added.


@techmahedy
techmahedy requested a review from rrr63 August 29, 2026 06:25
@rrr63

rrr63 commented Aug 29, 2026

Copy link
Copy Markdown
Member

tried local, everythings looks fine to me, thank you @techmahedy

@rrr63
rrr63 merged commit 663391a into doppar:4.x Aug 29, 2026
14 checks passed
@techmahedy

Copy link
Copy Markdown
Member Author

@rrr63 great, your are welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants