我想在 Windows 上简单地发送一封带有附件(带有表格)的邮件。我正在本地主机上进行测试。没关系,但是phpmailer不添加附件,邮件发送是空白的...
这是我的代码:
require_once('class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsMail();
$mail->SetFrom('contact@blabla.fr', 'H');
$mail->AddReplyTo("contact@blabla.fr",'H');
$mail->AddAddress('contact@blabla.fr', "H");
if (isset($_FILES) && count($_FILES)>0) {
foreach ($_FILES as $form) {
if ($form['error']==0) {
//$source = str_replace('\\','\\\\',$form["tmp_name"]);
$source = $form["tmp_name"];
$name = $form["name"];
if (!$mail->AddAttachment($source,$name)) {
echo "ERREUR D'ATTACHEMENT !! : "; var_dump($mail->ErrorInfo);
}
}
}
}
$mail->CharSet = 'utf-8';
$subject = "...";
$message = ' ...' ;
$mail->Subject = $subject;
$mail->MsgHTML($message);
if($mail->Send()) {
$back = array('response'=>1, 'data'=>'1');
} else {
$errors = $mail->ErrorInfo;
$back = array('response'=>0, 'errors'=>$errors, 'data'=>0);
}
在添加附件的过程中我没有错误... bt 邮件是空白的,没有附加文件:(
谢谢,法布里斯