search
HomeBackend DevelopmentPHP TutorialFrequently Asked Questions about PHPmailer Mass Sending to Gmail_PHP Tutorial
Frequently Asked Questions about PHPmailer Mass Sending to Gmail_PHP TutorialJul 13, 2016 am 10:30 AM
web developmentEnterprise securityinformation Technologysecurity softwaredatabasemobile developmentsystem securityWebsite securitycyber securitynetwork technologysoftware development

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 the three files in the php folder: php_openssl.dll, ssleay32.dll, libeay32.dll 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.
# Download to the /var/www/php5 directory
cd /var/www/php5
wget http://mirrors.sohu.com/php/php-5.2.14.tar.gz
# Unzip
tar zxvf php-5.2.14.tar.gz
# Enter the PHP openssl extension module directory
cd php-5.2.14/ext/openssl/
/var/www/php5/bin/phpize # Here is your own phpize path. If you can’t find it, use whereis phpize to find it
# After execution, an error was found: config.m4 cannot be found, config0.m4 is config.m4. Rename directly
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
# After the installation is completed, a directory of .so files (openssl.so) will be returned. Copy the openssl.so file in this directory to the extension_dir you specified in php.ini (find: extension_dir = in the php.ini file). My directory here is var/www/php5/lib/php/extensions
# Edit the php.ini file and add
at the end of the file
extension=openssl.so
# Just restart 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 add 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.
Copy code
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = 'smtp.gmail.com'; // Your business post office domain name
$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 = '***'; //Email title
$mail->Body = '***'; //Mail content
$mail->AltBody = "text/html";
$mail->AddAddress('***', "");
$mail->Is_SSL = true;
$mail->Port = 587;
if (!$mail->Send()) {
exit($mail->ErrorInfo);
}
$mail->Smtpclose();
unset($mail);
Copy code
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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/765063.htmlTechArticle1.Could not authenticate First of all, if you do not use loops, basically the account or password is wrong; if Use a loop to send messages in bulk. Remember to call Sm after the send() method ends...
Statement
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
如何在 Windows 11 上创建移动热点如何在 Windows 11 上创建移动热点Apr 17, 2023 pm 06:22 PM

当然,在Android智能手机和Windows11PC之间共享移动互联网可能很有用,尤其是在Wi-Fi不可用时。因此,当其他选项刚刚出现时,知道如何与Windows设备共享移动互联网会非常方便。就像没有Wi-Fi时iPhone可以连接到Mac一样,Android设备也允许用户通过USB和蓝牙将智能手机的互联网连接与任何Windows笔记本电脑连接。对于我们许多人来说,通过电缆连接手机和PC不是一种选择,而通过蓝牙连接互联网可能会很慢。因此,使用智能手机创建W

实用Word技巧分享:2招轻松解决多图片排版!实用Word技巧分享:2招轻松解决多图片排版!Apr 01, 2023 am 10:57 AM

多图片排版,是Word编辑文档时常见场景之一,几乎每个人都会碰到,对很多人来说仍然是一大难题。当图片数量一多,很多人都不知道图片该怎么摆放,如何快速高效地搞定一组图片? 因为没有掌握系统的套路技巧,每次制作都花费大量时间,做不出满意的效果。今天我就教大家2 招,轻松解决多图片排版!

如何在网络安全中使用AI如何在网络安全中使用AIApr 14, 2023 pm 02:10 PM

Cybersecurity Ventures的报告显示,2021年全球网络犯罪带来的损失为6万亿美元,并预计打击网络犯罪的全球支出在2025年将增至10.5万亿美元,是2015年的三倍之多(3万亿美元)。人工智能,几乎是唯一应对方案。另一家研究机构Statista认为,2020年网络安全领域的人工智能价值已超过100亿美元,并预计到2027年将达到450亿美元。IBM则认为,缺乏人工智能安全的企业,在抵御网络攻击方面的成本是部署了AI自动化防御系统的企业的三倍。来自Meticulous的研究数据

Microsoft Edge 102.0.1245.41 带来安全修复和 PDF 打印错误解决方案Microsoft Edge 102.0.1245.41 带来安全修复和 PDF 打印错误解决方案May 06, 2023 pm 07:37 PM

微软在周末为其Edge浏览器发布了两个小更新。该公司在周五和今天发布了另一个安全更新。虽然周五的更新修复了影响Edge浏览器的安全问题,但今天的更新解决了影响所有基于Chromium的网络浏览器的安全问题。此外,该更新似乎解决了通过Edge浏览器访问PDF文件时无法打印的问题。稳定版本通道的Edge102.0.1245.41被标记为修复了多个漏洞的维护更新。Microsoft尚未更新发行说明。不过,该公司此前已告知Chromium和Edge浏览器存在以下漏洞:

从“微软安全的下一步”数字活动中可以期待什么从“微软安全的下一步”数字活动中可以期待什么Apr 19, 2023 am 10:46 AM

Microsoft数字活动的下一步安全计划将于太平洋时间(UTC-8)时间2月24日上午9:00至上午10:30举行。随着无处不在的威胁不断增长,为他们的公司寻找有效安全解决方案的各种组织希望在这次活动中找到一些有价值的技巧和知识。Microsoft的安全下一步计划将强调全面的安全方法对业务增长的重要性。它将欢迎不同的安全专家讨论最新的创新和技术,以减少最新的威胁风险。一些演讲者包括VasuJakkal(微软公司安全、合规和身份副总裁)和JeffPollard(F

人工智能聊天机器人在网络安全领域的发展趋势如何?人工智能聊天机器人在网络安全领域的发展趋势如何?Apr 22, 2023 pm 11:13 PM

OpenAI公司推出的聊天机器人ChatGPT有很多很好的用途,但就像任何新技术一样,有些人会利用ChatGPT用于罪恶的目的。从编写电子邮件等相对简单的任务,到撰写论文或编译代码等更复杂的工作,OpenAI公司的人工智能驱动的自然语言处理工具ChatGPT自从推出以来就引起了人们的极大兴趣。当然,ChatGPT并不完美——众所周知,当它误解了从中学习的信息时就会犯错,但许多人将它和其他人工智能工具视为互联网的未来。OpenAI公司在ChatGPT的服务条款中加入了禁止生成恶意软件的条目,其中包

Zerodium 宣布为 Microsoft Outlook 零点击 RCE 安全漏洞支付 400,000 美元Zerodium 宣布为 Microsoft Outlook 零点击 RCE 安全漏洞支付 400,000 美元Apr 29, 2023 pm 09:28 PM

<ul><li><strong>点击进入:</strong>ChatGPT工具插件导航大全</li></ul><figureclass="imageimage--expandable"><imgsrc="/uploads/2023041

微软在 Windows 10 和 11 上的 Windows Defender 中引入了易受攻击的驱动程序阻止列表微软在 Windows 10 和 11 上的 Windows Defender 中引入了易受攻击的驱动程序阻止列表Apr 17, 2023 am 11:52 AM

MicrosoftWindowsDefender收到的升级将使Windows10、Windows11和WindowsServer2016或更高版本受益。引入到Defender的Microsoft易受攻击的驱动程序阻止列表功能将允许阻止具有安全漏洞的驱动程序在设备上运行。微软操作系统安全和企业副总裁大卫韦斯顿于3月27日发布了更新公告。Defender的Microsoft易受攻击的驱动程序阻止列表功能对于用户来说是可选的,因为它可以打开和关闭,并且它对于每个人来说都是

See all articles

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 agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)