【问题标题】:using phpmailer with google apps将 phpmailer 与谷歌应用程序一起使用
【发布时间】:2015-08-08 13:25:06
【问题描述】:

谁能帮我找出问题所在。我做了很多搜索,并且做了我发现没有成功的事情。

这是我的错误,phpmailer 是最新版本


2015-08-08 13:15:03 Connection: opening to ssl://smtp.mysite.com:465, timeout=300, options=array ( ) 2015-08-08 13:15:04    SMTP ERROR: Failed to connect to server: Connection refused (111) 2015-08-08 13:15:04   SMTP connect() failed. 

这是我的代码。

$m = new PHPMailer;
//Setup
$m->isSMTP();
$m->SMTPAuth = true;
//authentication
$m->Host = 'smtp.gmail.com';
$m->Username = 'info@example.com';
$m->Password = 'password';
$m->SMTPSecure = 'ssl';
$m->Port = 465;
$m->SMTPDebug  = 3;    
//from
$m->AddReplyTo($email, $name);
$m->SetFrom('info@example.com', $name);
//to
$m->addAddress('ari@example.com','guy johnson');
$m->addCC('joe@example.com','Joe johnson');
//message
$m->Subject = $subject;
$m->Body = $message;


if(!$m->Send()) {
echo"<script type=\"text/javascript\">".
                "alert('A Error Occured, Please Try Again.');".
                "</script>";
} else {
echo"<script type=\"text/javascript\">".
                "alert('Message Sent. Please allow atleast 24-hours for a response');".
                "window.location='http://example.com';".
                "</script>";
}

提前致谢!

【问题讨论】:

  • 你确定端口正确吗?
  • @ajon 这就是它所说的放在我看过的任何地方。

标签: php email google-apps


【解决方案1】:

您的错误消息在错误中显示 smtp.example.com,但您的代码显示 smtp.gmail.com。你试过25端口吗? Google 文档建议尝试使用 SSL。

【讨论】:

  • 1) 是的,我尝试了所有 3 个端口。 2) smtp.gmail.com 是用于邮件和/或谷歌应用程序的 gmails 服务器,这意味着 example.com 是我的谷歌应用程序电子邮件。 (这是正确的代码)3)这应该作为评论而不是答案发布。
猜你喜欢
  • 2014-10-20
  • 2014-10-14
  • 1970-01-01
  • 2015-08-03
  • 1970-01-01
  • 1970-01-01
  • 2012-08-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多