邮件程序错误:邮件正文空帮助我修复它

时间:2016-02-25 07:37:58

标签: php phpmailer

嘿所有人我正在尝试从我的帐户发送电子邮件,但显示错误"消息正文缺失"。任何人都可以帮我修复它。

<?php
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();  
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'abc@gmail.com';                   // SMTP username
$mail->Password = '123';               // SMTP password
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->setFrom('ajayggi000@gmail.com', 'Amit Agarwal');     
$mail->addReplyTo('ajayggi000@gmail.com', 'First Last');
$mail->addAddress('manjinder05@gmail.com', 'Josh Adams');
$mail->addAddress('ajayggi000@gmail.com');               // Name is optional
$mail->addCC('maniinder05@gmail.com');
$mail->addBCC('ajayggi000@gmail.com');
$mail->WordWrap = 50;    
$mail->isHTML(true);
$mail->Subject = 'Here is the subject';
$mail->Body    = 'Hey';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));

if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}

echo 'Message has been sent';

2 个答案:

答案 0 :(得分:0)

此行设置svg.append("g") .attr("transform", "translate(" + x(0) + ",0)") .attr("class", "axis") .call(d3.svg.axis() .scale(y) .orient("left") .ticks(20) .tickFormat(function(d) { if (d < 1000) //checking a condition based on that do foarmat //provide a format return d3.format("s")(d); else { //provide some other format return d; } })); Body,因此事先设置它们毫无意义:

AltBody

如果您以$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__)); 为空结束,则表示此行无法正常运行。最明显的是它没有读取你的Body文件,所以你应该测试你的file_get_contents调用的返回值是否包含你所期望的 - 如果不是,那你就是&#39 ;简单地将邮件正文设置为contents.html,这将显示为空白,正如您所看到的那样。试试这个:

false

如果这不显示您的预期内容,请检查原因 - 错误的路径或权限是明显要检查的内容。

答案 1 :(得分:-1)

$mail->Body    = file_get_contents('contents.html');

改变身体。

相关问题