【发布时间】:2016-04-14 14:12:14
【问题描述】:
我正在使用 PHPMailer,它在我的服务器上运行良好,但在我的本地主机上却不行。我用来发送的函数是:
function sendEmail($mail, $toEmail, $toName, $subject, $message, $noHtmlMessage) {
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'christopherpickardco.netfirms.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'webmaster@christopherpickard.com'; // SMTP username
$mail->Password = 'myPassword'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('webmaster@christopherpickard.com', 'ChrisComposes.com'); //
$mail->addAddress($toEmail, $toName); // Add a recipient. Right now this goes to me, in the end it will go to Chris
$mail->addReplyTo('webmaster@christopherpickard.com', 'ChrisComposes.com');
$mail->Subject = "ChrisComposes.com: " . $subject;
$mail->Body = $message;
$mail->AltBody = $noHtmlMessage;
$mail->send();
}
这在我的服务器上运行良好,但在我的本地主机上出现错误:警告:stream_socket_enable_crypto(): Peer certificate CN=smtp.eigbox.net' did not match expected CN=christopherpickardco.netfirms.com' in /Users/ChristopherPickard/Web_Development/chriscomposes/includes/phpmailer /class.smtp.php 第 344 行
我该如何解决这个问题?
【问题讨论】:
-
它只能在指定的站点上工作不是很明显吗?因此,当您在 localhost 上运行它时,八盒.net 将主机名接收为 localhost 而不是 christopherpicardco.netfirms.com。所以由于安全问题,它不起作用。
-
如果这对我来说很明显,我就不会问了,但是谢谢。很多人似乎都在本地主机上工作,所以一定有办法
-
您使用哪个服务器软件作为 localhost?
-
很明显,因为这个确切的错误已经包含在文档中,所以去阅读它们。
标签: php email smtp localhost phpmailer