简体   繁体   English

SMTP错误:无法连接到SMTP主机,使用Gmail发送邮件

[英]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
     )
  );

SSL verify peer make them false more SSL验证对等方使它们更加 虚假

Hope this will help thanks. 希望这会有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 即时消息使用hotmail地址发送成功的电子邮件,但使用gmail即时消息:SMTP错误:无法连接到SMTP主机 - Im sending emails with sucess using a hotmail adress, but with gmail Im getting: SMTP Error: Could not connect to SMTP host xampp + PHPMailer + Gmail = SMTP错误:无法连接到SMTP主机 - xampp + PHPMailer + Gmail = SMTP Error: Could not connect to SMTP host PHPMailer 使用 Gmail 作为 SMTP 服务器。无法连接到 SMTP 主机。 邮件程序错误:SMTP 错误:无法连接到 SMTP 主机 - PHPMailer to use Gmail as SMTP server.Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host SMTP错误:无法使用PHPMailer连接到SMTP主机 - SMTP Error: Could not connect to SMTP host using PHPMailer SMTP错误:无法连接到SMTP主机。 - SMTP Error: Could not connect to SMTP host. PHPMailer,SMTP错误无法连接到smtp主机 - PHPMailer,SMTP Error Could not connect to smtp host PHPMailer:SMTP 错误:无法连接到 SMTP 主机 - PHPMailer: SMTP Error: Could not connect to SMTP host SMTP 错误:无法连接到 SMTP 主机 - SMTP Error: Could not connect to SMTP host SMTP错误:无法连接到SMTP主机。邮件程序错误:SMTP错误:无法连接到SMTP主机 - SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host PHPMailer() + IIS + SMTP = SMTP 错误:无法连接到 SMTP 主机 - PHPMailer() + IIS + SMTP = SMTP Error: Could not connect to SMTP host
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM