// Load the PHPMailer library use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; // Create a new PHPMailer instance $mail = new PHPMailer(); // Add a recipient to the BCC field $mail->addBCC('bcc@example.com'); // Clear out the BCC recipients $mail->clearBCCs(); // Set the email subject and body $mail->Subject = 'Test Email'; $mail->Body = 'This is a test email'; // Send the email if (!$mail->send()) { echo 'Error sending email'; } else { echo 'Email sent successfully'; }
// Load the PHPMailer library require_once 'path/to/PHPMailer/src/PHPMailer.php'; require_once 'path/to/PHPMailer/src/SMTP.php'; require_once 'path/to/PHPMailer/src/Exception.php'; // Create a new PHPMailer instance $mail = new PHPMailer(); // Add a recipient to the BCC field $mail->addBCC('bcc@example.com'); // Clear out the BCC recipients $mail->clearBCCs(); // Set the email subject and body $mail->Subject = 'Test Email'; $mail->Body = 'This is a test email'; // Send the email if (!$mail->send()) { echo 'Error sending email'; } else { echo 'Email sent successfully'; }This example uses require_once to load the PHPMailer library, adds and clears BCC recipients, and sends the email. In conclusion, the PHPMailer library is used to send emails via SMTP servers and provides various features including ClearBCCs to remove blind carbon copy recipients.