我知道这是很多问题之一,但在涉及更多技术问题时,我不是最精明的网页设计师。问题是:在我的网站www.imago-graphics.com上,来自联系部分的电子邮件不会出现在任何地方:我的iPage收件箱,也不是我的Google Apps电子邮件。我知道这可能是mail.php的一个问题,但我不确定它是什么。这是php(我已经离开了我希望它在脚本中输入的实际电子邮件地址(mariano@imago-graphics.com),但是取出了密码;另外,该地址是Google Apps电子邮件地址,我是认为可能是问题的一部分:
<?
require("class.phpmailer.php");
//form validation vars
$formok = true;
$errors = array();
//sumbission data
$ipaddress = $_SERVER['REMOTE_ADDR'];
$date = date('d/m/Y');
$time = date('H:i:s');
//form data
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$mail = new PHPMailer();
$mail->IsSMTP(); // send via SMTP
$mail->Host = "smtp.gmail.com"; // SMTP server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "mariano@imago-graphics.com"; // SMTP username
$mail->Password = "xxxxx"; // Password
$mail->From = "mariano@imago-graphics.com"; // SMTP username again
$mail->AddAddress("mariano@imago-graphics.com"); // Your Adress
$mail->Subject = "New mail from IMAGO Graphics";
$mail->IsHTML(true);
$mail->CharSet = 'UTF-8';
$mail->Body = "<p>You have recieved a new message from the enquiries form on your website.</p>
<p><strong>Name: </strong> {$name} </p>
<p><strong>Email Address: </strong> {$email} </p>
<p><strong>Subject: </strong> {$subject} </p>
<p><strong>Message: </strong> {$message} </p>
<p>This message was sent from the IP Address: {$ipaddress} on {$date} at {$time}</p>";
if(!$mail->Send())
{
echo "Mail Not Sent <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Mail Sent";
?>
答案 0 :(得分:0)
您需要设置几个参数才能从Gmail帐户发送。请查看您需要使用的最新SMTP设置的文档。
这些是你必须要做的几件事:
$mail->Username = "mariano@imago-graphics.com";
$mail->Password = "xxxxx";
$mail->SMTPSecure = "tls";
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
在测试期间启用调试模式,以便您可以查看是否有错误:
$mail->SMTPDebug = 2;