国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術(shù)|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務(wù)器之家 - 編程語言 - PHP教程 - 匯總PHPmailer群發(fā)Gmail的常見問題

匯總PHPmailer群發(fā)Gmail的常見問題

2020-12-22 18:12依夢為馬 PHP教程

這篇文章主要匯總了PHPmailer群發(fā)Gmail的常見問題,整理了一個phpmailer發(fā)送gmail郵件實例,感興趣的小伙伴們可以參考一下

大家在PHPmailer群發(fā)Gmail時會遇到許多常見問題,下面為大家總結(jié)了一些常見問題,希望對大家的學(xué)習(xí)有所幫助。

1.Could not authenticate

首先,如果你沒有使用循環(huán)的話,基本上就是賬號或者密碼錯了;

如果使用循環(huán)來群發(fā),send()方法結(jié)束之后記得調(diào)用Smtpclose(),發(fā)一次關(guān)一次,否則就會出現(xiàn)只能發(fā)一封郵件,第二次就崩潰的情況。

2.Gmail

首先,開啟php的ssl權(quán)限

php開啟openssl的方法,大多數(shù)情況下openssl是沒有開啟的,要想啟用需要進行下簡單的設(shè)置:

windows下開啟方法:

1: 首先檢查php.ini中;extension=php_openssl.dll是否存在, 如果存在的話去掉前面的注釋符‘;', 如果不存在這行,那么添加extension=php_openssl.dll。

2: 講php文件夾下的: php_openssl.dll, ssleay32.dll, libeay32.dll 3個文件拷貝到 WINDOWS\system32\  文件夾下。

3: 重啟apache或者iis

至此,openssl功能就開啟了。

Linux下開啟方法:

我使用的是錦尚數(shù)據(jù)的云主機,PHP版本:5.2.14

下面方案就以我的主機為例講解為PHP添加openssl模塊支持。

網(wǎng)上一些答案說要重新編譯PHP,添加configure參數(shù),增加openssl的支持。這里講一個不需要重新編譯的方法。

如果服務(wù)器上存在PHP安裝包文件最好,如果已經(jīng)刪除,去下載和phpinfo頁面顯示版本一樣的PHP安裝文件,我這里是 php-5.2.14.tar.gz

推薦去搜狐鏡像下載,網(wǎng)易鏡像沒有找到。地址為: http://mirrors.sohu.com/php/

用ssh工具連接到主機。

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# 下載到/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
 
# 進入PHP的openssl擴展模塊目錄
 
cd php-5.2.14/ext/openssl/
 
/var/www/php5/bin/phpize # 這里為你自己的phpize路徑,如果找不到,使用whereis phpize查找
 
# 執(zhí)行后,發(fā)現(xiàn)錯誤 無法找到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
 
# 安裝完成后,會返回一個.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

好了,現(xiàn)在就成功添加openssl支持。 

但是,Gmail麻煩的地方可不止這樣,Gmail現(xiàn)在的smtp和pop3都是ssl加密的

Step1. php openssl module(extension) support
Step2. download phpmailer library
Step3. change code 'class.phpmailer.php' and 'class.smtp.php'

1.phpmailer和smtp里加property Is_SSL

?
1
public $Is_SSL = false;

2.phpmailer里的SmtpConnect方法里傳遞給smtp對象

?
1
$this->smtp-> Is_SSL = $this-> Is_SSL ;

3.smtp里的Connect方法在fsockopen調(diào)用前加上

?
1
if($this->is_ssl){ $host = 'ssl://'.$host; }
 

最后是使用方法,記得調(diào)用phpmailer類哦,代碼里沒有。

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$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);

代碼部分就這些,還有不要忘記在gmail中做好相應(yīng)的設(shè)置哦。

以上三步完成,就可以自由的用phpmailer來發(fā)送gmail郵件了。

再為大家分享一個phpmailer發(fā)送gmail郵件實例:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<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>

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助。

延伸 · 閱讀

精彩推薦
Weibo Article 1 Weibo Article 2 Weibo Article 3 Weibo Article 4 Weibo Article 5 Weibo Article 6 Weibo Article 7 Weibo Article 8 Weibo Article 9 Weibo Article 10 Weibo Article 11 Weibo Article 12 Weibo Article 13 Weibo Article 14 Weibo Article 15 Weibo Article 16 Weibo Article 17 Weibo Article 18 Weibo Article 19 Weibo Article 20 Weibo Article 21 Weibo Article 22 Weibo Article 23 Weibo Article 24 Weibo Article 25 Weibo Article 26 Weibo Article 27 Weibo Article 28 Weibo Article 29 Weibo Article 30 Weibo Article 31 Weibo Article 32 Weibo Article 33 Weibo Article 34 Weibo Article 35 Weibo Article 36 Weibo Article 37 Weibo Article 38 Weibo Article 39 Weibo Article 40
主站蜘蛛池模板: 高清中文字幕av | 亚洲精品欧美在线 | 久久免费看少妇a高潮一片黄特 | 久久九九免费 | 国产精品成人3p一区二区三区 | 欧美日韩视频在线第一区 | 99看| 日日夜夜精品视频 | 91av免费 | 在线观看免费黄色小视频 | 午夜精品视频 | 国产精品自拍视频网站 | 国产精品久久久久久久久久ktv | 日韩一区二区三区在线视频 | 亚洲黄色在线 | 黄色高清视频在线观看 | 在线观看亚洲 | 日韩精品无码一区二区三区 | av网址在线播放 | 韩国毛片在线观看 | 国产电影一区二区 | 欧美日韩成人 | 久久综合伊人77777蜜臀 | 欧美日韩国产在线观看 | 久久综合久久综合久久综合 | 天操天天干 | 久久99精品久久久久婷婷暖91 | 九九热精品在线 | 精品国产91乱码一区二区三区 | 久草热8精品视频在线观看 久久亚洲精品中文字幕 | 高清久久| 色综合天天天天做夜夜夜夜做 | 亚洲激情一区 | 日本精品视频在线观看 | 亚洲欧洲日韩 | 久久窝 | 欧美一级欧美三级在线观看 | 亚洲精品国产成人 | 久久精品国产一区二区三区不卡 | 欧美国产精品一区二区三区 | 久久精热 |