获取错误SMTP connect()失败phpmailer与本地主机 [英] Getting error SMTP connect() failed phpmailer with localhost
问题描述
我收到错误SMTP连接()失败phpmailer与本地主机:
I'm getting error SMTP connect() failed phpmailer with localhost:
2015-09-10 09:34:48连接:打开ssl://smtp.gmail.com:587,
timeout = 300,options = array()2015-09-10 09:34:48 SMTP错误:失败
连接到服务器:(0)2015-09-10 09:34:48 SMTP connect()失败。
https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting 消息
无法发送。邮件错误:SMTP connect()失败。
https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
- 是否phpmailer无法在localhost上运行?
- 如果我想在localhost上运行,我该怎么改代码?
- 我尝试使用mailto功能为我工作,但我想改变整个事情。
-
可以提出任何建议。我真的想学习
- Is it phpmailer cannot run at localhost?
- If I want really run at localhost how can I change the code?
- I tried using mailto function is work for me but I want change whole thing.
can give any suggestion. I really want to learn it.
这是github的代码:
require'PHPMailer / PHPMailerAutoload.php';
This is the code from github: require 'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 4; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'mygmail@gmail.com'; // SMTP username
$mail->Password = 'mygmailpassword'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
//$mail->Host = 'tls://smtp.gmail.com:587';
$mail->From = 'ikramlim@gmail.com';
$mail->FromName = 'Mailer';
$mail->addAddress('ikramlim@gmail.com', 'Joe User'); // Add a recipient
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
推荐答案
PHPMailer通常适用于所有系统。
PHPMailer is normally working on all systems.
我认为您有一个旧的openssl扩展名,或者您的扩展名未启用。如果启用了openssl,请检查 phpinfo()
。
I think you have an old openssl extension or your extension is not enabled. Check that with a phpinfo()
if there is openssl enabled.
如果没有,请在您的 php.ini
中启用。
If not then enable it in your php.ini
.
另一方面,Google似乎有一些问题。当我尝试发送电子邮件时,我也有连接问题与雷鸟。我必须尝试一下连接到Gmail。
And the other way is that it seems that Google has some problems. When i try to send an Email at the moment i have connection problems with Thunderbird, too. I have to try it some times to connect to gmail.
这篇关于获取错误SMTP connect()失败phpmailer与本地主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!