PHPMailer addCC() adds no CC recipient
addCC() returns falseShort answer
addCC() returns false when it rejects the address, and PHPMailer then sends without that CC. The documented reasons are an address that is invalid, such as the Name <address> form, or one already used on the message. In a loop, clear recipients after each send. Always check the return value.
Fix it fast
1Find out which cause you have
Print what addCC() returns and turn on server debugging. A false means PHPMailer refused the address before anything was sent.
<?php use PHPMailer\PHPMailer\SMTP; $mail->SMTPDebug = SMTP::DEBUG_SERVER; var_dump($mail->addCC('cc@example.com')); echo $mail->ErrorInfo;2Match what you see, then jump to its fix
- 1
addCC() returns false for a value like Joe User <joe@example.com>The address is not a bare addressFix - 2
addCC() returns false for an address that looks validThe address is already on the messageFix - 3
In a loop, a CC address gets a message meant for someone else, or a new CC is refused as already usedRecipients from the previous message are still on the objectFix
- 1
What does the error look like?
addCC() returns falseThe mail arrives for the To address but not for the CC addressThe CC address receives a message meant for a previous recipient
Cause 1 of 3
The address is not a bare address
1Check
The PHPMailer troubleshooting guide says addresses must be bare. The display-name format is not accepted in the address argument; the name goes in the second argument.
<?php
var_dump($mail->addCC('Joe User <joe@example.com>'));
var_dump($mail->addCC('joe@example.com', 'Joe User'));2Fix
Split the value into an address and a name before calling addCC().
<?php
$mail->addCC('joe@example.com', 'Joe User');3Verify
Both the return value and the list of CC addresses show the recipient.
<?php
var_dump($mail->getCcAddresses());Confirmed by github.com
Cause 2 of 3
The address is already on the message
1Check
The reference says addCC() returns false if the address was already used or is invalid in some way. Adding the same person to To and CC, or calling addCC() twice with one address, triggers it.
<?php
var_dump($mail->getCcAddresses());2Fix
Add each address to one list only. If the same value comes from a form field, remove duplicates first and keep the address in To or in CC, not both.
<?php
$to = 'a@example.com';
$cc = 'a@example.com';
$mail->addAddress($to);
if ($cc !== $to) {
$mail->addCC($cc);
}3Verify
Every addCC() call you expect to work returns true.
<?php
var_dump($mail->addCC('b@example.com'));Confirmed by phpmailer.github.io
Cause 3 of 3
Recipients from the previous message are still on the object
1Check
One PHPMailer object keeps its recipients until you clear them. The sending-to-lists guide says to clear addresses after each send inside a loop, and the class has clearCCs() and clearAllRecipients() for CC and for every recipient type.
<?php
var_dump($mail->getCcAddresses());2Fix
Clear the recipients after every send, or create a fresh PHPMailer object per message.
<?php
foreach ($messages as $m) {
$mail->addAddress($m['to']);
$mail->addCC($m['cc']);
$mail->send();
$mail->clearAllRecipients();
}3Verify
Before each iteration getCcAddresses() is empty, and each CC receives only its own message.
<?php
var_dump($mail->getCcAddresses());Confirmed by github.com
How do I stop it coming back?
- Treat the boolean from addAddress(), addCC() and addBCC() as part of the call: log or stop when it is false.
- Use bare addresses and pass the display name as the second argument.
- Keep recipient lists per message, and clear them before the next message.
- Keep SMTPDebug at DEBUG_SERVER while testing so the server conversation is visible.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
PHPMailer fails with 'certificate verify failed' when connecting to the SMTP server
OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
PHPMailer checks the mail server's certificate and the check failed.
3 causes, each with a fixCodeIgniter email does not send and shows no error message
$email->printDebugger() prints an empty result
CodeIgniter signals a failed email only by send() returning false, with no exception.
4 causes, each with a fixLaravel tries to send mail to mailpit:1025 instead of your real SMTP server
Symfony\Component\Mailer\Exception\TransportException
Laravel is still using the development mail host from the starter .env, mailpit on port 1025, which only exists inside Laravel Sail.
3 causes, each with a fixLaravel mail fails because an address does not comply with RFC 2822
Email "Jane Doe <jane@example.com>" does not comply with addr-spec of RFC 2822.
Symfony Mailer checks every address when the Address object is created.
3 causes, each with a fixLaravel says the email was sent, but nothing arrives
Mail::to($user)->send() returns normally
Mail::send returns without an error when the message was accepted by the configured mailer, not when it was delivered.
3 causes, each with a fixLaravel mail fails with 'Unable to connect with STARTTLS' and SSL operation failed with code 1
stream_socket_enable_crypto(): Peer certificate verification failed
The mail server offered STARTTLS, but PHP could not verify the certificate it presented.
3 causes, each with a fix