0

我有以下表格:

<form action="" method="post" enctype="multipart/form-data">

<input required="required" name="name" type="text" placeholder="Name" /><br /><br />
<input required="required" name="email" type="text" placeholder="Email" /><br /><br />
<input required="required" name="phone" type="text" placeholder="Phone Number" /><br /><br />
<input required="required" name="website" type="text" placeholder="URL to blog / website" /><br /><br />
<input type="file" name="file" /><br /><br />
<textarea name="message" cols="" rows="10" placeholder="Message (optional)"></textarea><br /><br />
<input name="send_form" type="submit" value="Submit" style="float:right; width:200px;" />
</form>

这是我的 php:

$mail             = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->Host       = "xxxxxx"; // sets the SMTP server
$mail->Username   = "xxxxxxx";// SMTP account username
$mail->Password   = "xxxx";        // SMTP account password
$mail->From = $_REQUEST['email'];
$mail->FromName = $_REQUEST['name'];    
$mail->IsHTML(true);
$mail->Subject = "CV Upload";

$body = 'Name:'.$_REQUEST['name'].'<br /><br />Email:'.$_REQUEST['email'].'<br /><br />Email:'.$_REQUEST['website'].'<br /><br />Message:'.$_REQUEST['message'].'<br /><br />'; 

$mail->Body    = $body;
$mail->AltBody = $text_body;
$mail->AddAddress("danyob@rbh.co.uk");
$mail->AddAttachment($_FILES['file']['tmp_name'], $_FILES['file']['name']);
if($mail->Send()){
    $success = true;        
}else{
    $success = false;
}//if($mail->Send()){}

由于某种原因,我收到的电子邮件中没有显示内容的正文。主题行和其他一切都有效。以上有什么问题吗?

4

1 回答 1

0

$mail->Body在您做之前检查结果是什么,并使用启用 HTML 的$mail->Send()邮件客户端检查您的邮件。请注意,它充满了您提供的代码中未定义的变量内容。它可能是空的,如果您使用纯文本邮件客户端,您将看不到任何文本。您可以尝试做简单的测试并尝试这些代码行来查看您的邮件客户端中可以看到哪些内容:$mail->AltBody$text_body

$mail->Body    = '<h1>HTML</h1>';
$mail->AltBody = 'Plain text';
于 2014-05-23T09:06:13.160 回答