我在这里问是因为我没有得到 OVH(我的主机)的答复。问题是:如果我将 $mail->MsgHTML($msg) 替换为 $mail->MsgHTML($_POST['message']),我会立即收到带有标题、名称、电子邮件、主题和消息的邮件。但是当我输入 $msg 时,我没有收到任何邮件。
$msg='Name:'.$_POST['name'].'<br />
Email:'.$_POST['email'].'<br />
Subject: '.$_POST['subject'].'<br />
IP:'.$_SERVER['REMOTE_ADDR'].'<br /><br />
Message:<br /><br />
'.nl2br($_POST['message']).'
';
整个 PHP(来自 FancyAJAXForm):
<?php
/* config start */
$emailAddress = 'my mail address';
/* config end */
require "class.phpmailer.php";
foreach($_POST as $k=>$v)
{
if(ini_get('magic_quotes_gpc'))
$_POST[$k]=stripslashes($_POST[$k]);
$_POST[$k]=htmlspecialchars(strip_tags($_POST[$k]));
}
$msg='Name:'.$_POST['name'].'<br />
Email:'.$_POST['email'].'<br />
Subject: '.$_POST['subject'].'<br />
IP:'.$_SERVER['REMOTE_ADDR'].'<br /><br />
Message:<br /><br />
'.nl2br($_POST['message']).'
';
$mail = new PHPMailer();
$mail->IsMail();
$mail->AddReplyTo($_POST['email'], $_POST['name']);
$mail->AddAddress($emailAddress);
$mail->SetFrom($_POST['email'], $_POST['name']);
$mail->Subject = "Contact Form: ".mb_strtolower($_POST['subject'])." from ".$_POST['name']."";
$mail->MsgHTML($msg);
$mail->Send();
?>