Following is my code include("Phpmailer.php");
$phpmail = new PHPMailer();
$phpmail->Mailer = 'mail';
$phpmail->Host = 'relay-hosting.secureserver.net';
$phpmail->ClearAddresses();
$phpmail->ContentType = 'text/html';
$phpmail->From = "from@mail.com";
$phpmail->FromName = "Company";
$phpmail->Sender = "from@mail.com";
$phpmail->AddAddress("to@mail.com","Test user");
$phpmail->Subject = 'Multiple Attachment';
$mailBoddy = file_get_contents("files/example_text_file.txt");
$arrayFind = array("{ABC}","{XYZ}");
$arrayReplace = array("Test","Multiple Attachment");
$mailBoddy = str_replace($arrayFind,$arrayReplace,$mailBoddy);
$phpmail->Body = $mailBoddy;
// attachment
$phpmail->AddAttachment("files/example1.pdf","Example 1");
$phpmail->AddAttachment("files/example2.pdf","Example 2");
// send email
if(!$phpmail->Send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $phpmail->ErrorInfo;
} else {
echo 'Message has been sent';
};
Problem is that in the above code is, it only send one attachment which is first one example1 not including the second one. I want to send multiple files like "example1" and "example2" in the single email.