SMTP connect()failed.PHPmailer
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了SMTP connect()failed.PHPmailer,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1673字,纯文字阅读大概需要3分钟。
内容图文
![SMTP connect()failed.PHPmailer](/upload/InfoBanner/zyjiaocheng/749/f8fdbc32b71149578b008779eeef24f5.jpg)
我一直在尝试使用PHPMailer从我的本地主机发送电子邮件,但我无法修复此错误
SMTP connect()失败.
我知道有这种错误的建议,但我试过的似乎对我有用.这是我的设置
$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);
}
我尝试过端口587和465它们似乎都没有工作,但当我telnet到任一端口我得到连接没有错误
我在php.ini中启用了openssll.dill
我已经在我的Mac和Ubuntu 12.04中的MAMP中尝试了这个设置,但我仍然得到相同的错误
任何输入将提前感谢
解决方法:
您的连接配置中需要完整的电子邮件地址:
$mail->Username = 'username@gmail.com';
如果使用TLS安全协议,您需要使用:
$mail->SMTPSecure = "tls";
$mail-> Port = 587;
...
或SSL(已弃用状态):
$mail->SMTPSecure = "ssl";
$mail-> Port = 465;
...
内容总结
以上是互联网集市为您收集整理的SMTP connect()failed.PHPmailer全部内容,希望文章能够帮你解决SMTP connect()failed.PHPmailer所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。