【发布时间】:2012-12-23 09:51:28
【问题描述】:
我无法在appfog 上托管的应用程序中发送电子邮件 我正在使用以下代码,它在 localhost 上运行良好,但在 appfog 上失败。 JPhpMailer 扩展类.PhpMailer.php
$mailer = new JPhpMailer(true);
$mailer->IsSMTP();
$mailer->Mailer = "smtp";
//$mailer->SMTPSecure == 'tls';
$mailer->Host = 'ssl://smtp.gmail.com';
$mailer->Port = '465';
$mailer->SMTPAuth = true;
//$mailer->SMTPSecure = true;
$mailer->Username = 'me@gmail.com';
$mailer->Password = 'zzzzzzz';
$mailer->SetFrom($to['from'], $to['from_name']);
$mailer->AddAddress($to['to'],$to['to_name'] );
$mailer->Subject = $to['subject'];
$mailer->Body = $to['body'];
$mailer->Send();
这是 phpMailer 中执行失败的行`if ($tls) { if (!$this->smtp->StartTLS()) { throw new phpmailerException($this->Lang('tls')); }
//We must resend HELO after tls negotiation
$this->smtp->Hello($hello);
}
$connection = true;
if ($this->SMTPAuth) {
if (!$this->smtp->Authenticate($this->Username, $this->Password)) {
**strong text throw new phpmailerException($this->Lang('authenticate')); ** }
}
}
$index++;
if (!$connection) {
throw new phpmailerException($this->Lang('connect_host'));
}
【问题讨论】:
-
您的服务器上是否安装了 Open SSL?做一个 PHPInfo 来找出答案。
-
感谢 Gavin,openssl 没有安装在我的托管服务器上,但也没有安装在我的本地主机上,但它运行良好
-
尝试 tls 而不是 ssl
标签: php smtp gmail phpmailer appfog