[英]SMTP Error: Could not connect to SMTP host ,mail sending using Gmail
Mail sending functionality is not working in QA server(local ip).The code snippet is given below 邮件发送功能在QA服务器(本地ip)中不起作用。代码段如下所示
public function Sendmail($id) {
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
$mail=New PHPMailer();
$subject = "Action Items";
$content = "<b>Dear All,</b>";
$content .= "my msg";
$content .="<br>";
$content .="Thanks and regards";
$content .="<br>";
$content .= $this->view->getactionitems[0]['Assinedby'];
$mail->IsSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = TRUE;
$mail->SMTPSecure = "ssl";
$mail->Port = 465;
$mail->Username = "test@gmail.com";
$mail->Password = "pass$";
$mail->Host = "smtp.gmail.com";
$mail->Mailer = "smtp";
$mail->SetFrom("abc@gmail.com", "Shanu");
$mail->AddReplyTo("abc@gmail.com", "Shanu");
$mail->AddAddress("user@gmail.com");
$mail->Subject = $subject;
$mail->WordWrap = 80;
$mail->MsgHTML($content);
$mail->IsHTML(true);
if(!$mail->Send())
$this->view->status = 'invalid';
else
$this->view->status = 'success';
$this->view->renderAdmin('meetings/meetings');
}
It was successfully tested in development PC.the error message as given below 它已在开发PC中成功测试。错误消息如下
SMTP Error: Could not connect to SMTP host SMTP错误:无法连接到SMTP主机
I have enabled extension=php_openssl.dll
.But same error.Any help would be appreciated. 我启用了extension=php_openssl.dll
。但是同样的错误。任何帮助将不胜感激。
If your server doesn't has SSL and you try to send mail this error might come. 如果您的服务器没有SSL,而您尝试发送邮件,则可能会出现此错误。
So for PHP you can do 因此,对于PHP,您可以
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
Hope this will help thanks. 希望这会有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.