0

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.

andrew
  • 9,313
  • 7
  • 30
  • 61
  • 1
    Possible duplicate of [How to send multiple attachment in single mail in php](https://stackoverflow.com/questions/27296361/how-to-send-multiple-attachment-in-single-mail-in-php) – andrew Aug 08 '17 at 12:45
  • Check the return values of the `addAttachment` calls. – Synchro Aug 08 '17 at 12:49
  • return value shows no error. when i see the object of phpmailer then it shows the array of attachment – Muhammad Wasim Khan Aug 09 '17 at 04:29

0 Answers0