我试图在依赖phpexcel生成电子表格的脚本上使用phpmailer。
它完美地保存了电子表格,我没有收到phpmailer错误,但它没有发送。我不确定如果它不发送
或
显示错误。
以下是保存excel并生成邮件程序的部分:
$writer = PHPExcel_IOFactory::createWriter($phpExcel, "Excel2007");
$writer->save('Coaching Report - Test.xlsx');
$mail = new PHPMailer(true);
//$address = "s";
$address = "omitted";
$date = date("D M d, Y");
try{
$mail->setFrom("omitted");
$mail->addAddress($address);
$mail->AddAttachment($writer,"Coaching Report $date.xlsx");
$mail->isHTML(true);
$mail->Subject = "Weekly Coaching Report";
$mail->Body = "Attached is the weekly coaching report for " . $date;
$mail->Send();
echo 'message sent';
} catch (Exception $e){
echo 'message failed';
echo 'mail error:' . $mail->ErrorInfo;
}
mysqli_close($conn);