网站电子邮件表单(PHP)问题
我知道这是一个经常被问到的问题,但当涉及到更多的技术问题时,我并不是最精明的网页设计师。问题在于:在我的网站www.imago-graphics.com上,联系人部分的电子邮件不会发送到任何地方:不会发送到我的iPage收件箱,也不会发送到我的Google Apps电子邮件。我知道这可能是mail.php的问题,但我不确定它是什么。这是php(我在脚本中留下了我希望它进入的实际电子邮件地址(mariano@imago-graphics.com),但删除了密码;而且,该地址是谷歌应用程序的电子邮件地址,我认为这可能是问题的一部分:网站电子邮件表单(PHP)问题,php,email,webmail,Php,Email,Webmail,我知道这是一个经常被问到的问题,但当涉及到更多的技术问题时,我并不是最精明的网页设计师。问题在于:在我的网站www.imago-graphics.com上,联系人部分的电子邮件不会发送到任何地方:不会发送到我的iPage收件箱,也不会发送到我的Google Apps电子邮件。我知道这可能是mail.php的问题,但我不确定它是什么。这是php(我在脚本中留下了我希望它进入的实际电子邮件地址(mariano@imago-graphics.com),但删除了密码;而且,该地址是谷歌应用程序的电子邮件
<?
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";
?>
您还需要设置一些参数才能从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;
你确定谷歌是你的smtp主机吗?你在使用谷歌应用程序吗?设置
$mail->SMTPDebug
将帮助你跟踪smtp错误,这对收集你需要的所有线索非常有帮助。马特:是的,我在使用谷歌应用程序,上面的电子邮件是谷歌应用程序地址。我知道这可能是问题的根源,但正如我所说的,我更喜欢一个图形设计师而不是程序员。谢谢你的回复!谢谢,我会调查的。你确定你的服务器可以为imago graphics.com
发送(中继)电子邮件吗?