// Include the PHPMailer library require_once('path/to/PHPMailer/src/PHPMailer.php'); // Create a new instance of PHPMailer $mail = new PHPMailer\PHPMailer\PHPMailer(); // Set the recipient's email address $mail->addAddress('john@example.com', 'John Doe'); // Send the email if ($mail->send()) { echo 'Message sent successfully!'; } else { echo 'Failed to send message. Error: ' . $mail->ErrorInfo; }
// Include the PHPMailer library require_once('path/to/PHPMailer/src/PHPMailer.php'); // Create a new instance of PHPMailer $mail = new PHPMailer\PHPMailer\PHPMailer(); // Set the first recipient's email address $mail->addAddress('john@example.com', 'John Doe'); // Set the second recipient's email address $mail->addAddress('jane@example.com', 'Jane Smith'); // Send the email if ($mail->send()) { echo 'Message sent successfully!'; } else { echo 'Failed to send message. Error: ' . $mail->ErrorInfo; }The addAddress method is provided by the PHPMailer package/library.