


Summary of common problems with PHPmailer mass sending to Gmail, phpmailer mass sending to Gmail_PHP tutorial
Jul 12, 2016 am 08:58 AMSummarize the common problems of mass sending Gmail with PHPmailer, mass sending gmail with phpmailer
Everyone will encounter many common problems when sending mass Gmail with PHPmailer. Here is a summary of some common problems for you. I hope it will help Everyone’s learning helps.
1.Could not authenticate
First of all, if you don’t use loops, it’s basically because your account or password is wrong;
If you use a loop to send mass messages, remember to call Smtpclose() after the send() method is completed, and send and close once. Otherwise, you will only be able to send one email and it will crash the second time.
2.Gmail
First, enable php’s SSL permissions
How to enable openssl in php. In most cases, openssl is not enabled. To enable it, you need to make the following simple settings:
How to open it under windows:
1: First check whether extension=php_openssl.dll exists in php.ini. If it exists, remove the previous comment character ';'. If this line does not exist, add extension=php_openssl.dll.
2: Copy php_openssl.dll, ssleay32.dll, libeay32.dll 3 files in the php folder to the WINDOWSsystem32 folder.
3: Restart apache or iis
At this point, the openssl function is enabled.
How to enable it under Linux:
I am using the cloud host of Jinshang Data, PHP version: 5.2.14
The following plan uses my host as an example to explain adding openssl module support to PHP.
Some answers on the Internet say that you need to recompile PHP, add configure parameters, and add openssl support. Here is a method that does not require recompiling.
It is best if the PHP installation package file exists on the server. If it has been deleted, download the PHP installation file with the same version as shown on the phpinfo page. Here is php-5.2.14.tar.gz
It is recommended to download the Sohu mirror, but the NetEase mirror was not found. The address is: http://mirrors.sohu.com/php/
Connect to the host using ssh tool.
# 下載到/var/www/php5目錄下 cd /var/www/php5 wget http://mirrors.sohu.com/php/php-5.2.14.tar.gz # 解壓 tar zxvf php-5.2.14.tar.gz # 進(jìn)入PHP的openssl擴(kuò)展模塊目錄 cd php-5.2.14/ext/openssl/ /var/www/php5/bin/phpize # 這里為你自己的phpize路徑,如果找不到,使用whereis phpize查找 # 執(zhí)行后,發(fā)現(xiàn)錯(cuò)誤 無法找到config.m4 ,config0.m4就是config.m4。直接重命名 mv config0.m4 config.m4 /var/www/php5/bin/phpize ./configure --with-openssl --with-php-config=/var/www/php5/bin/php-config make make install # 安裝完成后,會(huì)返回一個(gè).so文件(openssl.so)的目錄。在此目錄下把openssl.so 文件拷貝到你在php.ini 中指定的 extension_dir 下(在php.ini文件中查找:extension_dir =),我這里的目錄是 var/www/php5/lib/php/extensions # 編輯php.ini文件,在文件最后添加 extension=openssl.so # 重啟Apache即可 /usr/local/apache2/bin/apachectl restart
Okay, openssl support is now successfully added.
However, Gmail’s troubles don’t end there. Gmail’s current SMTP and POP3 are both SSL encrypted
Step1.php openssl module(extension) support
Step2. download phpmailer library
Step3. change code 'class.phpmailer.php' and 'class.smtp.php'
1.phpmailer and smtp Riga property Is_SSL
public $Is_SSL = false;
2. Pass to the smtp object in the SmtpConnect method in phpmailer
$this->smtp-> Is_SSL = $this-> Is_SSL ;
3. The Connect method in smtp adds
before the fsockopen call.if($this->is_ssl){ $host = 'ssl://'.$host; }?
The last step is the usage method. Remember to call the phpmailer class, which is not in the code.
$mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = 'smtp.gmail.com'; // 您的企業(yè)郵局域名 $mail->SMTPAuth = true; // turn on SMTP authentication $mail->SMTPSecure = "tls"; $mail->Username = '***@gmail.com'; $mail->Password = '******'; $mail->From = '***'; $mail->FromName = '***'; $mail->CharSet = 'UTF-8'; $mail->Encoding = "base64"; $mail->IsHTML(true); // send as HTML $mail->Subject = '***'; //郵件標(biāo)題 $mail->Body = '***'; //郵件內(nèi)容 $mail->AltBody = "text/html"; $mail->AddAddress('***', ""); $mail->Is_SSL = true; $mail->Port = 587; if (!$mail->Send()) { exit($mail->ErrorInfo); } $mail->Smtpclose(); unset($mail);
That’s it for the code part. Don’t forget to make the corresponding settings in gmail.
After completing the above three steps, you can freely use phpmailer to send gmail emails.
Let me share with you an example of sending gmail emails using phpmailer:
<html> <head> <title>PHPMailer - SMTP (Gmail) basic test</title> </head> <body> <?php //error_reporting(E_ALL); error_reporting(E_STRICT); date_default_timezone_set('America/Toronto'); require_once('../class.phpmailer.php'); //include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded $mail = new PHPMailer(); $body = file_get_contents('contents.html'); $body = eregi_replace("[\]",'',$body); $mail->IsSMTP(); // telling the class to use SMTP $mail->Host = "mail.gmail.com"; // SMTP server $mail->SMTPDebug = 2; // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only $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 = "***@gmail.com"; // GMAIL username $mail->Password = "***"; // GMAIL password $mail->SetFrom('****@gmail.com', 'First Last'); $mail->AddReplyTo("***@gmail.com","First Last"); $mail->Subject = "PHPMailer Test Subject via smtp (Gmail), basic"; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->MsgHTML($body); $address = "***@gmail.com"; $mail->AddAddress($address, "John Doe"); $mail->AddAttachment("images/phpmailer.gif"); // attachment $mail->AddAttachment("images/phpmailer_mini.gif"); // attachment if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; } ?> </body> </html>
The above is the entire content of this article, I hope it will be helpful to everyone’s study.
Articles you may be interested in:
- PHP to obtain 163, gmail, 126 and other email contact addresses [tested 2009.10.10]
- php simulates GMAIL, HOTMAIL ( MSN), YAHOO, 163, 126 mailbox login details
- Source code for PHP to implement mass mailing
- Detailed explanation of examples of phpmailer sending gmail emails
- java, php, C#, asp to implement SMS Methods of group sending function
- php realizes unlimited group sending of WeChat public accounts
- PHP swoole realizes simple multi-person online chat group sending
- PHP mail mass sending machine implementation code

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

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

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

In web applications, it is often necessary to send emails to multiple recipients at once. PHP is a very popular web development language, and PHPMailer is a common PHP class library for sending emails. PHPMailer provides a rich interface, making sending emails in PHP applications more convenient and easy to use. In this article, we will introduce the methods and steps on how to use PHPMailer to send emails to multiple recipients. To download PHPMailer, you first need to go to the official website (

Sending group messages to everyone on WeChat is a very convenient function that can help us deliver information quickly. If you need to send the same content to multiple friends (without creating a group), you can use the "Group Assistant" to send group messages to each friend. The editor below will introduce in detail how to send in bulk, let’s take a look! 1. Open WeChat and search for the [Group Send Assistant] function. 2. First enable the WeChat Mass Sending Assistant, and then click [Start Mass Sending] 3. Click [New Mass Sending] to enter the recipient selection page. 4. In the select recipients page, you can select all the contacts you want to send messages to by manually checking or selecting all. 5. After selecting the contact, click the "Next" button to enter the message editing interface. 6. In the message editing interface, you can

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 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

Solution: 1. Check whether the account violates Gmail's usage policies. You need to comply with these policies and wait for a period of time to restore the account; 2. Contact the Gmail customer service team for help, through the official Gmail website or the help and support page in the application Find the customer service contact information; 3. Check whether the account has been accessed without authorization or has been hacked. You need to change the password immediately and enable two-factor authentication to protect the account security; 4. Stop sending large amounts of emails and wait for a period of time to restore the account.

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
