Please image below. The sender is the same subject is the same email address of the sender is the same but they always go into separate email and not in one email thread as it should.
Below is my PHP mailer script.
use PHPMailerPHPMailerPHPMailer;
use PHPMailerPHPMailerSMTP;
use PHPMailerPHPMailerException;
//Load Composer's autoloader
require 'vendor/autoload.php';
function send_mail($to,$subject,$body,$from = '', $host = "[email protected]"){
//Create an instance; passing `true` enables exceptions
$mail = new PHPMailer(true);
try {
//Server settings
// $mail->SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output
$mail->isSMTP(); //Send using SMTP
$mail->Host = 'mail.privateemail.com'; //Set the SMTP server to send through
$mail->SMTPAuth = true; //Enable SMTP authentication
$mail->Username = '[email protected]'; //SMTP username
$mail->Password = 'xxxxx'; //SMTP password
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption
$mail->Port = 465; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
//Recipients
$mail->setFrom($host, $from);
// $mail->addAddress($to, 'Subscriber'); //Add a recipient
$mail->addAddress($to); //Name is optional
// $mail->addReplyTo('[email protected]', 'Sensored Support');
//$mail->addCC('[email protected]');
$mail->addBCC('[email protected]');
//Attachments
// $mail->addAttachment('/var/tmp/file.tar.gz'); //Add attachments
// $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); //Optional name
//Content
$mail->isHTML(true); //Set email format to HTML
$mail->Subject = $subject;
$mail->Body = $body;
//$mail->AltBody = ' ';
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
}
