我在函数中有下面的代码..但是它从不将附件添加到电子邮件中。电子邮件很好,但没有附件。
但是,如果我从函数中删除代码并向其中添加一个单独的文件(没有函数部分)并且在同一目录中它可以正常工作。
为什么在函数中不添加附件?
function resendOrder()
{
//global $siteEmailFrom, $siteEmailName, $dir;
require_once('OrderMailer/class.phpmailer.php');// need this to send email
$mail = new PHPMailer();
// Now you only need to add the necessary stuff
// HTML body
$body = "Testing";
// And the absolute required configurations for sending HTML with attachement
$mail->From = "mark@******.co.uk";
$mail->AddAddress("mark@******.co.uk", "My-webpage Website");
$mail->Subject = "test for phpmailer-3";
$mail->MsgHTML($body);
$mail->AddAttachment("ploxy.jpg");
if(!$mail->Send()) {
echo "There was an error sending the message";
exit;
}
else{
echo "Message was sent successfully";
}
}