以下是我的代码 包括(" Phpmailer.php&#34);
$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';
};
问题在于,在上面的代码中,它只发送一个附件,这是第一个示例1,不包括第二个附件。我想发送多个文件,如" example1"和" example2"在单个电子邮件中。