多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > php開源 > php教程 > PHPMailer使用Gmail來發送郵件的連接smtp服務器錯誤

PHPMailer使用Gmail來發送郵件的連接smtp服務器錯誤

來源:程序員人生   發布時間:2013-11-22 01:14:13 閱讀次數:4813次

我們在使用PHPMailer使用Gmail來發送郵件的連接smtp服務器錯誤提示:smtp error could not connect to smtp host !了,這個是因為extension=php_openssl.dll未開啟導致的哦。

使用的PHPMailer版本:5.2.1,以下是PHPMailer的example文件夾里給出的:test_gamil_basic.php的部分代碼,代碼如下:

  1. $mail = new PHPMailer();  
  2.     $body = file_get_contents('contents.html'); //$body = $_POST['body'];  
  3.     $body = eregi_replace("[]",'',$body);  
  4.     $mail->IsSMTP(); // telling the class to use SMTP  
  5.     $mail->SMTPDebug = 2; // enables SMTP debug information (for testing)  
  6.     // 1 = errors and messages  
  7.     // 2 = messages only  
  8.     $mail->SMTPAuth = true; // enable SMTP authentication  
  9.     $mail->SMTPSecure = "ssl"// sets the prefix to the servier  
  10.     $mail->Host = "smtp.gmail.com"// sets GMAIL as the SMTP server or ssl://smtp.gmail.com  
  11.     $mail->Port = 465; // set the SMTP port for the GMAIL server  
  12.     $mail->Username = "yourusername@gmail.com"// GMAIL username  
  13.     $mail->Password = "yourpassword"// GMAIL password  
  14.     $mail->SetFrom('name@yourdomain.com''First Last');  
  15.     $mail->AddReplyTo("name@yourdomain.com","First Last");  
  16.     $mail->Subject = "PHPMailer Test Subject via smtp (Gmail), basic";  
  17.     $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"// optional, comment out and test  
  18.     $mail->MsgHTML($body);  
  19.     $address = "whoto@otherdomain.com";  
  20.     $mail->AddAddress($address"John Doe");  
  21.     $mail->AddAttachment("images/phpmailer.gif"); // attachment  
  22.     $mail->AddAttachment("images/phpmailer_mini.gif"); // attachment  
  23.     if(!$mail->Send()) {  
  24.     echo "Mailer Error: " . $mail->ErrorInfo;  
  25.     } else {  
  26.     echo "Message sent!";  
  27.     } 

按照這個例子給出的代碼操作,我遇到了以下錯誤:

提示您 smtp error could not connect to smtp host !的錯誤提示,google了下,發現是需要開啟PHP的openssl擴展:

extension=php_openssl.dll //去掉最前面的分號,重啟apache或nginx服務器。

HoHo~成功發送。

生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 黄色网一级片 | 欧美极品尤物在线播放一级 | 欧美伊人久久大香线蕉在观 | 亚洲欧美视频一区二区三区 | 成人国产欧美精品一区二区 | 国产一区二区三区成人久久片 | 国产中文欧美 | 日韩一级一片 | 欧美精品国产一区二区三区 | 在线观看视频免费入口 | 亚洲高清一区二区三区 | 国产精品一级二级三级 | 国产在线日韩在线 | xxxx免费大片| 最近最新中文字幕大全免费7 | 性色影院| 欧美精品第一页 | 欧美18毛片 | 综合网小说图片区 | 欧美高清性 | xxx性欧美在线观看 xxx性日本 | 日韩欧美色 | 国产精品亚洲欧美一级久久精品 | 国产一级淫片免费大片 | 性欧美超高清hd | 亚洲视频在线网站 | 另类天堂| 国产91精品一区二区 | 日韩国产免费一区二区三区 | 久久艹综合 | a免费视频 | 动漫美女毛片 | 免费视频网站在线看视频 | 最近免费中文字幕4 | 亚洲精品老司机 | 一区二区三区四区五区 | 看片久久 | 亚洲a级毛片 | 在线播放免费人成毛片乱码 | 美国人成毛片在线播放 | 国产91久久精品一区二区 |