---
title: "PHPMailer: SMTP, S/MIME and email headers in PHP | VulCode"
description: "In PHPMailer we stopped QUIT being sent during DATA, folded long address headers and normalised line breaks in S/MIME signed messages, in PHP."
url: "https://vulcode.com/en/opensource/contributions/phpmailer"
lang: "en"
---

[All contributions](https://vulcode.com/en/opensource/contributions)

PHPMailer/PHPMailer

# PHPMailer

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

[See the repository](https://github.com/PHPMailer/PHPMailer) [All contributions](https://vulcode.com/en/opensource/contributions)

- **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](https://github.com/PHPMailer/PHPMailer/pull/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](https://github.com/PHPMailer/PHPMailer/pull/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](https://github.com/PHPMailer/PHPMailer/pull/3361)

## Merged changes 3

- [#3362 Don't send QUIT while DATA is in progress Merged 4 October 2026](https://github.com/PHPMailer/PHPMailer/pull/3362)

- [#3361 Fold long address headers Merged 4 October 2026](https://github.com/PHPMailer/PHPMailer/pull/3361)

- [#3358 Normalise line breaks in S/MIME signed messages Merged 10 September 2026](https://github.com/PHPMailer/PHPMailer/pull/3358)

## 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](https://vulcode.com/en/technologies/php)

## Other projects we write code for

- [**Composer** PHP · 29,590 stars The dependency manager for PHP: it installs and updates a project's libraries from its composer.json.](https://vulcode.com/en/opensource/contributions/composer)

- [**Monolog** PHP · 21,407 stars A PHP logging library that sends records to files, sockets, inboxes, databases and web services. Symfony and Laravel use it, among others.](https://vulcode.com/en/opensource/contributions/monolog)

- [**Carbon** PHP · 16,583 stars A PHP DateTime extension for working with dates, standard in the Laravel ecosystem.](https://vulcode.com/en/opensource/contributions/carbon)

- [**Whoops** PHP · 13,231 stars A PHP library that turns uncaught exceptions into a readable error page with the stack trace, known from Laravel.](https://vulcode.com/en/opensource/contributions/whoops)

- [**ramsey/uuid** PHP · 12,642 stars A PHP library for generating universally unique identifiers (UUIDs).](https://vulcode.com/en/opensource/contributions/ramsey-uuid)

- [**Doctrine Lexer** PHP · 11,141 stars A base for lexers used by recursive descent parsers in PHP, used by Doctrine ORM among others.](https://vulcode.com/en/opensource/contributions/doctrine-lexer)

## Describe your project.

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

### Rather skip the form?

Ask in the chat or write to us directly.

Open the chat

- **Email**: [hello@vulcode.com](mailto:hello@vulcode.com)
- **Phone**: [+48 576 043 920](tel:+48576043920)
- **Discord**: [discord.gg/vulcode](https://discord.gg/vulcode)
