0
我在我的服務器上保存了excel文件夾(注意excel正在保存在服務器中),我試圖發送帶有保存在我的服務器上的excel附件的電子郵件,但是我沒有' t收到附件的電子郵件(即:我收到沒有附件的電子郵件),下面是我的代碼,請指導我如何做到這一點。如何發送帶有excel附件的電子郵件
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('/data/data/www/ms/pricelists/newxcelexample.xls');
$my_path ="/data/data/www/ms/pricelists/newxcelexample.xls";
include "class.phpmailer.php"; // include the class file name
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
//$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = "mail.xichlomobile.com";
$mail->Port = "25"; // or 587
$mail->IsHTML(true);
$mail->Username = "************";
$mail->Password = "**********";
$mail->SetFrom("**************");
$mail->Subject = Test;
$mail->Body = "Test";
$mail->AddAddress("*********");
$mail->AddAttachment($my_path);
if(!$mail->Send()){
echo "Mailer Error: " . $mail->ErrorInfo;
}
else{
echo "<span style='font-size:45px;color:#000000;'>Message has been sent</span><br><br>";
}