Home Backend Development PHP Tutorial ping“smtp.gmail.com”可以通,为什么PHPMAILer却报错

ping“smtp.gmail.com”可以通,为什么PHPMAILer却报错

Jun 13, 2016 pm 01:16 PM
gmail gt mail quot smtp

ping“smtp.gmail.com”可以通,为啥PHPMAILer却报错
在CMD里ping一下GMAIL的SMTP服务器可以通,

可是在网页里面做的发送email的程序,却总是报错:
SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host.


咋回事呢:

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
<?php include("phpmailer/class.phpmailer.php"); 
$mail             = new PHPMailer(); 
$body             = "TEST_TEST"; 
 
$mail->IsSMTP(); 
$mail->SMTPAuth   = true;                  // enable SMTP authentication 
$mail->SMTPSecure = "ssl";                 // sets the prefix to the servier 
$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server 
$mail->Port       = 465;                   // set the SMTP port for the GMAIL server 
 
$mail->Username   = "xxx@gmail.com";  // GMAIL username 
$mail->Password   = "xxx";            // GMAIL password 
 
 
$mail->From       = "xxx@gmail.com"; 
$mail->FromName   = "xxx"; 
 
$mail->Subject    = "subject 111"; 
 
//$mail->Body       = "Hi,<br>This is the HTML BODY<br>";                      //HTML Body 
$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test 
$mail->WordWrap   = 50; // set word wrap 
 
$mail->MsgHTML($body); 
 
$mail->AddAddress("xxx@gmail.com", "xxx"); 
 
$mail->IsHTML(true); // send as HTML 
 
if(!$mail->Send()) { 
    echo "Mailer Error: " . $mail->ErrorInfo; 
} else { 
    echo "Message sent!"; 
} 
     
?>

Copy after login


------解决方案--------------------
探讨

会不会是空间商做了限制呢?

我在本地测试,用163的邮箱可以发邮件;用GMAIL的也是显示这个错误,开启PHPMAILER的调试模式显示:
SMTP -> ERROR: Failed to connect to server: Unable to find the socket transport "ssl" - did you forget to enable it when you ……
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to add a hyperlink to text or image in Gmail How to add a hyperlink to text or image in Gmail May 06, 2023 pm 06:07 PM

No matter how many instant messaging apps have come and gone, email always has a completely different feel to it. Mailing is truly synonymous with Gmail. Not to mention a professional front desk, Gmail is unavoidable, just unavoidable! Since Gmail is used so frequently, no matter what, you have to know how to make your Gmail experience the smoothest and most efficient. You will most likely need to add a lot of web links in the body of your email, and it will definitely look unwieldy if you have so many links. But links are definitely necessary, even if long links will definitely make your email look ugly. So is there a way out? What about hyperlinks? How do you hide a link in text or an image? Sound cool? Oh yes, Gmail is

What are the differences between Huawei GT3 Pro and GT4? What are the differences between Huawei GT3 Pro and GT4? Dec 29, 2023 pm 02:27 PM

Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

How to remove Boomerang from Gmail on PC or mobile How to remove Boomerang from Gmail on PC or mobile Apr 14, 2023 pm 10:46 PM

How to Remove Boomerang from Gmail Find below our step-by-step guide to remove Boomerang from your Gmail account on your PC or mobile phone. To remove Boomerang from Gmail on PC, open Google Chrome browser on your computer. In Google Chrome, click the three-dot icon in the upper right corner of the screen. Select More Tools from the drop-down menu. Click Extensions from the next drop-down menu. On the Extensions screen, look for

Fix: Snipping tool not working in Windows 11 Fix: Snipping tool not working in Windows 11 Aug 24, 2023 am 09:48 AM

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

How to remove autocomplete email addresses in Gmail How to remove autocomplete email addresses in Gmail Apr 21, 2023 am 10:46 AM

Gmail is the most popular web-based email server from Google, and it comes with many powerful features that are helpful when browsing, editing, and sending emails. One such feature is the autocomplete list, which allows users to view a list of email addresses saved as contacts before finishing entering the full address. This feature is really useful but sometimes it may not be a good approach as there may be some email addresses that are no longer valid or may have been deleted by the user. For example, someone who leaves an organization no longer has access to a company email address. But there is a way to remove those email addresses that are highlighted in Gmail's autocomplete list. If you also want to remove emails from Gmail autocomplete list

Google Gemini now in the Gmail app: Smart email search via AI on Android devices Google Gemini now in the Gmail app: Smart email search via AI on Android devices Aug 31, 2024 am 09:54 AM

Google is expanding its Gmail app at Android with an AI-powered Q&A function which was already available in the web version of Gmail and is powered by Google's Gemini AI assistant. Users can now search their inbox more efficiently by asking speci

How to use Gmail on iPhone to find and recover archived emails How to use Gmail on iPhone to find and recover archived emails Apr 26, 2023 am 10:52 AM

On your iPhone, are you trying to find old emails archived in Gmail but are unable to do so? You are not alone, so don't worry. Many people face difficulties finding and recovering old emails on their mobile devices. In this blog post, we will walk you through the process of finding and recovering archived emails in Gmail on iPhone. We'll also provide tips and tricks to help you keep your inbox organized and find important emails more easily in the future. So whether you're trying to retrieve important business emails or sentimental messages from loved ones, you'll learn how to easily access and recover archived emails. Archive your emails in Gmail Step 1: On iP

How to set Gmail to delete instead of archive in the Mail app on iPhone and iPad How to set Gmail to delete instead of archive in the Mail app on iPhone and iPad Apr 13, 2023 pm 02:34 PM

Have you noticed that when you try to delete a message in Gmail on iOS, you only see the archive option? Read on to learn how to delete Gmail on iPhone without archiving it in the Mail app. The setting to change the default option for archiving Gmail emails using the Mail app on iPhone and iPad is completely hidden in Settings, but it can be changed quickly once you know where to go. Keep in mind that this tutorial is for people using Gmail through the Apple Mail app on iPhone and iPad. Another option is to use the Gmail app on your iPhone/iPad. you even

See all articles