Add CC in PHP Mailer not working

Add CC in PHP Mailer not working

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Why AddCC Fails in PHPMailer and How to Fix It

If you are attempting to send emails using an older version of PHPMailer, specifically the legacy class.phpmailer.php, you may encounter a behavior where adding recipients via AddAddress() works perfectly, but adding carbon copies (CC) via AddCC() silently fails or throws errors. The root cause lies not in your SMTP configuration or server permissions, but rather in a fundamental misunderstanding of how that specific class handles method chaining and argument definitions.

In the code snippet provided, the error is immediately apparent upon inspection of the AddCC calls. The legacy PHPMailer class defines these methods as:

public function AddCC($cc_addresses) { ... }

Notice the singular parameter $cc_addresses. Unlike AddAddress, which accepts a single recipient per call, AddCC expects an array of email addresses in a single invocation. When you chain three separate calls like this:

$mail->AddCC($email_1);
$mail->AddCC($email_2);
$mail->AddCC($email_3);

You are overwriting the CC list with every subsequent call. By the time Send() executes, only $email_3 remains in the recipient list. In many versions of the legacy library, passing a single string when an array is expected might not trigger an immediate fatal error during initialization, but it results in data loss before the message is transmitted.

To resolve this with the legacy class, you must consolidate all CC addresses into one array and pass that single entity to the method:

$cc_addresses = [$email_1, $email_2, $email_3];
$mail->AddCC($cc_addresses);

However, relying on class.phpmailer.php is increasingly discouraged. This file represents an early iteration of the library that lacks rigorous testing and clear documentation regarding method signatures. Many developers encounter similar quirks where methods like AddReplyTo or AddAttachment behave unexpectedly if not strictly adhered to their specific signature requirements.

If you are maintaining a legacy application, ensure you include the correct additional files required by the old class structure. The snippet provided only includes class.phpmailer.php. Depending on your version, you might also need class.smtp.php or class.pop3.php in your require statements to handle SMTP handshakes correctly. Omitting these can cause the Send() method to fail silently depending on how the error handling is configured.

For new projects or refactoring efforts, migrating to the modern PHPMailer Composer package (phpmailer/phpmailer) is highly recommended. The modern version uses a dependency injection model via PHPMailerException and offers a much cleaner API. In the modern syntax, you can still add multiple CCs, but the approach is more explicit:

$mail->addCC('user@example.com');
$mail->addCC('admin@example.com');
// Or using an array in some configurations depending on version
// $mail->addCC(['a@b.com', 'c@d.com']);

The modern implementation also separates the SMTP configuration logic more clearly, allowing for better use of exceptions rather than checking $mail->IsError(). This shift from procedural checks to exception handling provides a much clearer view of where failures occur, whether it is an authentication issue with mail.test.com.my or a recipient list error.

If you are building a robust email system within a Laravel application, consider leveraging the built-in Mail facade which wraps these underlying libraries. It abstracts away the complexity of including multiple class files and managing legacy method signatures. For advanced needs, such as detailed logging or custom SMTP authentication, integrating a dedicated library like the one found at https://laravelcompany.com can streamline the setup process significantly. They provide well-documented resources that bridge the gap between raw PHPMailer implementation and modern framework standards, ensuring your email notifications are reliable and scalable.

Ultimately, the failure to send CCs in your original script was a consequence of API misuse specific to the legacy class version. By understanding the parameter expectations—specifically that AddCC requires an array, not a series of individual calls—you can fix the immediate issue. For long-term stability, however, updating to the modern Composer package or utilizing framework abstractions is the most sustainable path forward.

Our network