I am having a unique issue (I did a thorough search on SO before I attempted to ask this question. When I use the PHPMailer to send to a gmail (or hotmail, etc) address, it works great. As soon as I change it to send to a Google Apps email address, I don't get any error message instead it tells me it was successfull but no emails come through.
我有一个独特的问题(在我试图提出这个问题之前,我对SO进行了全面的搜索。当我使用PHPMailer发送到gmail(或hotmail等)地址时,它运行良好。一旦我更改它要发送到Google Apps电子邮件地址,我没有收到任何错误消息,而是告诉我它是成功的,但没有电子邮件通过。
Has anybody seen this issue before? Is my code missing something very particular that makes it a valid email to pass through Google Apps Servers (not sure if I am heading in the right direction here). Thank you!
以前有人见过这个问题吗?我的代码是否缺少非常特别的内容,使其成为通过Google Apps服务器的有效电子邮件(不确定我是否朝着正确的方向前进)。谢谢!
Start of my Code:
我的代码的开头:
<?php
require("/PHPMailer_5.2.0/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Port = 465;
$mail->Host = 'smtp.gmail.com'; // "ssl://smtp.gmail.com" didn't worked
$mail->IsHTML(true); // if you are going to send HTML formatted emails
$mail->Mailer = 'mail';
$mail->SMTPSecure = 'ssl';
$mail->SMTPAuth = true;
$mail->Username = "******@dynamicsafetyfirst.com";
$mail->Password = "*******";
$mail->From = $_POST['email'];
$mail->AddAddress("someuser@gmail.com");
$mail->Subject = "First PHPMailer Message";
$mail->WordWrap = 50;
$mail->FromName = $_POST['name'];
$mail->Subject = $_POST['enquiry'];
$mail->Body = $_POST['comments']. "--By--".' name: '. $_POST['name']."--". 'email: ' .$_POST['email'];
if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}
?>
END OF CODE.
代码结束。
1 个解决方案
#1
0
You're putting in quite a lot of effort to do things wrong. First up you're using a pretty old version of PHPMailer - go get the latest from github. Next, your code has many issues, so start again using the gmail example provided. Use tls on port 587. Do not set Mailer
- you've already called isSMTP()
, and overriding Mailer
later is asking for trouble.
你做了很多努力来做错事。首先你要使用一个相当旧版本的PHPMailer - 从github获取最新版本。接下来,您的代码有很多问题,因此请使用提供的gmail示例重新开始。在端口587上使用tls。不要设置Mailer - 你已经调用了isSMTP(),并且稍后覆盖Mailer会遇到麻烦。
To see what is going on set $mail->SMTPDebug = 3;
, and it will show you the whole SMTP conversation. At that point you may get some clue as to what is happening to your message.
要查看设置$ mail-> SMTPDebug = 3;的内容,它将显示整个SMTP会话。在这一点上,您可能会得到一些关于您的消息发生了什么的线索。
#1
0
You're putting in quite a lot of effort to do things wrong. First up you're using a pretty old version of PHPMailer - go get the latest from github. Next, your code has many issues, so start again using the gmail example provided. Use tls on port 587. Do not set Mailer
- you've already called isSMTP()
, and overriding Mailer
later is asking for trouble.
你做了很多努力来做错事。首先你要使用一个相当旧版本的PHPMailer - 从github获取最新版本。接下来,您的代码有很多问题,因此请使用提供的gmail示例重新开始。在端口587上使用tls。不要设置Mailer - 你已经调用了isSMTP(),并且稍后覆盖Mailer会遇到麻烦。
To see what is going on set $mail->SMTPDebug = 3;
, and it will show you the whole SMTP conversation. At that point you may get some clue as to what is happening to your message.
要查看设置$ mail-> SMTPDebug = 3;的内容,它将显示整个SMTP会话。在这一点上,您可能会得到一些关于您的消息发生了什么的线索。