我一直在使用此脚本向某些员工发送电子邮件,但由于我的系统发生更改,我现在必须随电子邮件发送附件,并且我尝试了多个代码来完成此操作,但没有成功......我仍然收到电子邮件但没有附件,这在这种情况下毫无意义,我已将我正在使用的脚本放在下面
我删除了我使用的真实地址和 smtp 服务器
require("PHPMailer/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "SMTP.SErver.com";
$mail->From = "From@email.com";
$mail->FromName = "HCSC";
$mail->AddAddress("To@email.com", "Example");
$mail->AddReplyTo("Reply@email.com", "Hcsc");
$mail->WordWrap = 50;
$mail->IsHTML(false);
$mail->Subject = "AuthSMTP Test";
$mail->Body = "AuthSMTP Test Message!";
$mail->AddAttachment("matt.txt"); //this is basicly what i am trying to attach as a test but will be using excel spreadsheets in the production
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
我还尝试了其他一些附加文件的方法,但似乎没有任何帮助,非常感谢