[英]SMTP connect() failed.PHPmailer
I have been trying to send email from my local host using PHPMailer but i cant fix this error 我一直在尝试使用PHPMailer从我的本地主机发送电子邮件,但我无法修复此错误
SMTP connect() failed. SMTP connect()失败。
I know there are suggestion for this kind of error but non i have tried seems to work for me. 我知道有这种错误的建议,但我试过的似乎对我有用。 Here are my settings 这是我的设置
$mail = new PHPMailer();
$mail->IsSMTP(); // we are going to use SMTP
$mail->Host = 'smtp.gmail.com'; // setting GMail as our SMTP server
$mail->SMTPAuth = true; // enabled SMTP authentication
$mail->Username = 'mygamil'; // user email address
$mail->Password = "mypassword"; // password in GMail
$mail->SMTPSecure = "tls"; // prefix for secure protocol to connect to the server
$mail->SetFrom($this->session->userdata('email'), $this->session->userdata('username')); //Who is sending the email
$mail->AddReplyTo("someone@domain.com",$this->session->userdata('username')); //email address that receives the response
$mail->Subject = $subject;
$mail->Body = $message;
$mail->AltBody = $message;
$destino = "someone@domain.com"; // Who is addressed the email to
$mail->AddAddress($destino, "Sender name");
$mail->AddAttachment($file_path); // some attached files/
if($mail->Send() ==TRUE){
redirect('app/send/'.$this->uri->segment(3).'/succeeded ');
}
else
{
//show an error email failed erroers
$email_error = array('email_error'=>$mail->ErrorInfo);
}
I have tried with port 587 and 465 none of them seems to work but when i telnet to either of the ports i get connections without error 我尝试过端口587和465它们似乎都没有工作,但当我telnet到任一端口我得到连接没有错误
I have openssll.dill enable in my php.ini 我在php.ini中启用了openssll.dill
i have tried this settings both in MAMP in my mac and in Ubuntu 12.04 and still i get the same error 我已经在我的Mac和Ubuntu 12.04中的MAMP中尝试了这个设置,但我仍然得到相同的错误
Any input would be appreciated thanks in advance 任何输入将提前感谢
You need full email address in your connection configurations: 您的连接配置中需要完整的电子邮件地址:
$mail->Username = 'username@gmail.com';
And if use TLS security protocol you need use: 如果使用TLS安全协议,您需要使用:
$mail->SMTPSecure = "tls";
$mail-> Port = 587;
...
Or to SSL (that is deprecated status): 或SSL(已弃用状态):
$mail->SMTPSecure = "ssl";
$mail-> Port = 465;
...
Check your php.ini file, on it, if you have this: 检查你的php.ini文件,如果你有这个:
;extension=php_openssl.dll
change it to 改为
extension=php_openssl.dll
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.