Phpmailer发送附件,但不是身体

我有一个表单,我试图通过PHPmailer通过电子邮件提交.出于某种原因,phpmailer发送电子邮件的附件,但不发送正文/消息.继承人我的phpmailer文件..

$name = "Purchase Form";
$email_subject = "New Purchase Ticket";

$body = "geg";

foreach ($_REQUEST as $field_name => $value){
if (!empty($value)) $body .= "$field_name = $value\n\r";
}
$Email_to = "jonahkatz@yahoo.com"; // the one that recieves the email
$email_from = "No reply!";
//
//==== PHP Mailer With Attachment Func ====\\
//
function SendIt() {
//
global $attachments,$body,$name,$Email_to,$email_subject,$email_from;
//
$mail = new PHPMailer();
$mail->IsQmail();// send via SMTP
$mail->From = $email_from;
$mail->FromName = $name;
$mail->AddAddress($Email_to);
$mail->AddReplyTo($email_from);
$mail->WordWrap = 50;// set word wrap
$mail->IsHTML = true;
$mail ->MsgHTML($body);
$mail->AltBody = 'to view blah';
foreach($_FILES as $key => $file){
$target_path = "uploads/";
$target_path = $target_path .basename($file['name']);

if(move_uploaded_file($file['tmp_name'], $target_path)) {
echo "the file ".basename($file['name'])." has been uploaded";
}else {
 echo "there was an error";
}
$mail->AddAttachment($target_path);
}

$mail->Subject = $email_subject;
if(!$mail->Send())
{
}
//
{echo "Message has been sent";}


foreach($_FILES as $key => $file){
$target_path = "uploads/";
$target_path = $target_path .basename($file['name']);
unlink($target_path);}
}


SendIt();




}




?>

有什么输入?谢谢.

解决方法:

– > MsgHTML()不设置正文.它返回带有inlined-img urls的修改版本以及诸如此类和DOES将AltBody设置为HTML的文本版本.你还需要做

$mail->Body = $body;
上一篇:php – pdf不作为附件发送


下一篇:PHPMailer挂起发送邮件