PHPMailer使用Gmail来发送邮件的连接smtp服务器错误

我们在使用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~成功发送。

波比源码 – 精品源码模版分享 | www.bobi11.com
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 本站源码并不保证全部能正常使用,仅供有技术基础的人学习研究,请谨慎下载
8. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!

波比源码 » PHPMailer使用Gmail来发送邮件的连接smtp服务器错误

160 评论

  1. buy dutasteride sale zofran oral order zofran generic

  2. buy generic indomethacin 75mg cefixime tablet amoxicillin 500mg us

  3. order clonidine online cheap catapres us buy tiotropium bromide 9 mcg generic

  4. oral isosorbide isosorbide cost order telmisartan 80mg online

  5. order zyban 150 mg for sale cheap strattera order generic seroquel 50mg

  6. order colchicine for sale blackjack online online casino games real money

  7. buy fluconazole 200mg pills fluconazole drug viagra 50mg tablet

  8. casino games online real money generic cialis 5mg tadalafil 20mg for sale

  9. no deposit free spins casino slots meaning tadalafil 40mg us

  10. order clarithromycin 250mg generic antivert pills generic antivert

  11. Thank you for great information. Hello Administ . Metropol Halı Karaca Halı Öztekin ve Selçuklu Halı Cami Halısı ve Cami Halıları Türkiye’nin En Büyük Cami Halısı Fabrikasıyız…

  12. Good info. Lucky me I reach on your website by accident, I bookmarked it. Metropol Halı Karaca Halı Öztekin ve Selçuklu Halı Cami Halısı ve Cami Halıları Türkiye’nin En Büyük Cami Halısı Fabrikasıyız…

  13. Nice article inspiring thanks. Hello Administ . Metropol Halı Karaca Halı Öztekin ve Selçuklu Halı Cami Halısı ve Cami Halıları Türkiye’nin En Büyük Cami Halısı Fabrikasıyız…

  14. Hi, just required you to know I he added your site to my Google bookmarks due to your layout. But seriously, I believe your internet site has 1 in the freshest theme I??ve came across.Metropol Halı Karaca Halı Öztekin ve Selçuklu Halı Cami Halısı ve Cami Halıları Türkiye’nin En Büyük Cami Halısı Fabrikasıyız…

  15. buy ropinirole 2mg without prescription labetalol pills buy trandate 100mg online

  16. buy levaquin online cheap zyban 150 mg cheap order bupropion without prescription

  17. buy provigil pills for sale prednisone cost prednisone 40mg sale

  18. accutane generic amoxil for sale order azithromycin 500mg generic

  19. buy plavix 150mg generic plavix uk ketoconazole pill

  20. Hi, just required you to know I he added your site to my Google bookmarks due to your layout. But seriously, I believe your internet site has 1 in the freshest theme I??ve came across. Click on the Keyword to Enter the Website. Bahsegel

  21. bystolic ca buy clozaril order clozaril 100mg without prescription

  22. tadalafil 10mg cheap tadalafil ca cheap sildenafil without prescription

  23. order avodart generic buy zantac order meloxicam for sale

  24. buy propecia 1mg online cheap sildenafil brand viagra 50mg canada

  25. buy fexofenadine 180mg sale buy glimepiride 1mg glimepiride 4mg over the counter

  26. buy ciprofloxacin generic purchase lincocin buy cefadroxil medication

  27. where to buy epivir without a prescription order accupril sale purchase accupril generic

  28. buy frumil 5mg online cheap zovirax price acyclovir generic

评论已关闭

Hi, 如果你对这款模板有疑问,可以跟我联系哦!

联系站长
赞助VIP 享更多特权,建议使用 QQ 登录
喜欢我嘛?喜欢就按“ctrl+D”收藏我吧!♡