开发者

Phpmailer sending attachments, but not the body

I have a form that im trying to get emailed on submit using PHPmailer. For some reason, phpmailer is sending the attachments of the email, but not the body/message. Heres my phpmailer file..

$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();




}




?>

Any input? Thanks.


->MsgHTML() doesn't set the body. It returns a modified version with inlined-img urls and whatnot and DOES set the AltBody to a text-version of the HTML. You still need to do

$mail->Body = $body;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜