All contributions

PHPMailer/PHPMailer

PHPMailer

The classic PHP library for sending email, used by WordPress and many other systems.

Language
PHP
GitHub stars
22,347
Merged changes
3

What we changed

The QUIT command no longer ends up in the body of an interrupted message, long address headers are folded, and S/MIME signatures have normalised CRLF line breaks.

What this work shows

  • SMTP session states
  • S/MIME signing with OpenSSL
  • RFC 5322 header folding
  • CRLF line endings in email
What was broken

QUIT became a line of the message

When the process was stopped during DATA, for example by SIGTERM, the destructor closed the connection with quit(). The server took QUIT as another line of the email and never replied, and the connection only ended when it timed out with a 421.

How we fixed it

quit() checks the connection state

The SMTP class remembers the last command it sent, and in the DATA state quit() just closes the connection without sending QUIT. The testQuitDuringData test checks that no QUIT goes out and the connection is closed.

#3362

What was broken

Signed emails rejected for bare LF

openssl_pkcs7_sign() returns its headers and body with bare LF line breaks, and createBody() copied them as they were. Every S/MIME signed email went out with bare LFs, and servers that enforce RFC 5321 line endings rejected it with 550 5.6.11 SMTPSEND.BareLinefeedsAreIllegal.

How we fixed it

OpenSSL output goes through normalizeBreaks()

The headers and body from OpenSSL now go through the existing normalizeBreaks(), as DKIM_Sign() already does. The signature still verifies, because S/MIME canonicalises to CRLF before digesting, and testSigning() checks that the message has no bare LFs.

#3358

What was broken

A long address list on one line

addrAppend() put every address on a single line. A large To, Cc or Bcc list could go past the 998-character limit for a header line.

How we fixed it

The header folds between addresses

addrAppend() moves the next address to a new line when it would no longer fit, and short lists come out as before. A test with a hundred recipients checks every line's length and that unfolding gives back the original list.

#3361

Merged changes 3

  1. #3362 Don't send QUIT while DATA is in progress Merged 4 October 2026
  2. #3361 Fold long address headers Merged 4 October 2026
  3. #3358 Normalise line breaks in S/MIME signed messages Merged 10 September 2026

What it taught us

Mail sending breaks at the level of RFC 5321 and 5322: in SMTP session states, line endings in S/MIME signatures and the 998-character header line limit. We back each such fix with a test.

More about this technology: PHP

Other projects we write code for

Describe your project.

A free quote comes back within an hour during working hours.