【发布时间】:2016-02-23 21:42:33
【问题描述】:
我知道这是经常被问到的问题之一,但在涉及更多技术问题时,我并不是最精明的网页设计师。问题是这样的:在我的网站 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";
?>
【问题讨论】:
-
您确定 google 是您的 smtp 主机吗?你在使用谷歌应用吗?
-
设置
$mail->SMTPDebug将帮助您从 SMTP 跟踪错误,非常有助于收集您需要的所有线索。 -
Matt:是的,我使用的是 Google Apps,上面的电子邮件是 Google Apps 地址。我知道这可能是问题的根源,但就像我说的,我更像是一名平面设计师而不是编码员。感谢您的回复!
-
MackieeE:谢谢,我会调查的。
-
您确定您的服务器可以为
imago-graphics.com发送(中继)电子邮件吗?