最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

44郵件使用(視頻里的樣本)

2023-06-26 11:52 作者:平凡也要閃光  | 我要投稿

問(wèn)題描述

1.發(fā)送郵件,如果發(fā)送成功,記錄一下;


實(shí)現(xiàn)描述

1.定義一個(gè)send_mail的接口,如果發(fā)送成功,需要記錄一下為成功;

2.使用接口

dlb_mail.php?

<?php

use PHPMailer\PHPMailer\PHPMailer;

use PHPMailer\PHPMailer\SMTP;

use PHPMailer\PHPMailer\Exception;


require './vendor/autoload.php';


require_once './vendor/phpmailer/phpmailer/src/Exception.php';

require_once './vendor/phpmailer/phpmailer/src/PHPMailer.php';

require_once './vendor/phpmailer/phpmailer/src/SMTP.php';


//返回?cái)?shù)組$toResult的位置:[i]

function getIndexByEmail($toResult,$mail){


? ?foreach($toResult as $k=>$v){

? ? ? ?if($v['mail'] == $mail ){

? ? ? ? ? ?return $k; //找到

? ? ? ?}

? ?}

? ?return -1; //未找到

}


//$sendto為發(fā)送給誰(shuí)的郵件地址,類(lèi)型為string, 比如:'1405533012@qq.com'

//&$toResult,類(lèi)型為二緯數(shù)組,比如: array(0=>array('mail'=>'1405533012@qq.com', 'result'=>0));

//如果sendto發(fā)送成功,則更新該地址的'result'為1


function send_mail($sendto, &$toResult){

? ?$mail = new PHPMailer(true);


? ?try {

? ?//Server settings

? ?$mail->ConfirmReadingTo='140****@qq.com';

? ?//

? ?$mail->SMTPDebug = 0; //SMTP::DEBUG_SERVER; ? ? ? ? ? ? ? ? ? ? ?//Enable verbose debug output

? ?$mail->isSMTP(); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//Send using SMTP

? ?$mail->Host ? ? ? = 'smtp.qq.com'; ? ? ? ? ? ? ? ? ? ? //Set the SMTP server to send through

? ?$mail->SMTPAuth ? = true; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //Enable SMTP authentication

? ?$mail->Username ? = '140********@qq.com'; ? ? ? ? ? ? ? ? ? ? //SMTP username

? ?$mail->Password ? = '******'; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //SMTP password

? ?$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; ? ? ? ? ? ?//Enable implicit TLS encryption

? ?$mail->Port ? ? ? = 465; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`


? ?//Recipients

? ?$mail->setFrom('1405533012@qq.com', 'Mailer');


? ?$mail->addAddress($sendto);


? ?//$mail->addAddress('qblibo@qq.com', 'qbLibo User'); ? ? //Add a recipient

? ?//$mail->addAddress('1405533012@qq.com'); ? ? ? ? ? ? ? //Name is optional

? ?//$mail->addReplyTo('info@example.com', 'Information');

? ?//$mail->addCC('cc@example.com');

? ?//$mail->addBCC('bcc@example.com');


? ?//Attachments

? ?//$mail->addAttachment('/var/tmp/file.tar.gz'); ? ? ? ? //Add attachments

? ?//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); ? ?//Optional name


? ?//Content

? ?$mail->isHTML(true); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//Set email format to HTML

? ?$mail->Subject = "dlb subject";

? ?$mail->Body ? ?= "dlb body";

? ?$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';


? ?$mail->action_function = static function ($result, $to, $cc, $bcc, $subject, $body) {

? ? ? ?global $toResult;

? ? ? ?

? ? ? ?if ($result) {

? ? ? ? ? ?echo "<br/>";

? ? ? ? ? ?$index = getIndexByEmail($toResult, $to[0][0]);

? ? ? ? ? ?if( $index != -1 ){

? ? ? ? ? ? ? ?$toResult[$index]['result']++;

? ? ? ? ? ?}

? ? ? ? ? ?echo "<br/>";

? ? ? ?} else {

? ? ? ? ? ?echo "Message send failed\n";

? ? ? ?}

? ?};


? ?$mail->send();

? ?echo 'Message has been sent';

? ?} catch (Exception $e) {

? ? ? ?echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";

? ?} ?


? ?print_r($mail);

}


?>



//send mail test?

<?php

require_once "dlb_mail.php";


$toStr='qblibo**********@qq.com,1405533012@qq.com';

$toAry = explode(',',$toStr);


foreach($toAry as $k=>$v)

{

? ?$toResult[$k]['mail'] = $v;

? ?$toResult[$k]['result']=0;

}


foreach($toResult as $k=>$v){

? ?send_mail($v['mail'], $toResult);

? ?echo "call send_mail....<br/>";

? ?sleep(1);

}

print_r($toResult);


?>




44郵件使用(視頻里的樣本)的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
阿城市| 东乌珠穆沁旗| 甘泉县| 郁南县| 江川县| 新河县| 渭源县| 黄梅县| 仲巴县| 大丰市| 大安市| 志丹县| 黔江区| 广河县| 平和县| 凌海市| 卢湾区| 呼伦贝尔市| 宁远县| 淮滨县| 京山县| 玉屏| 台南市| 巴彦淖尔市| 冷水江市| 类乌齐县| 建德市| 车致| 青岛市| 抚宁县| 常宁市| 三河市| 远安县| 新田县| 阳朔县| 玛曲县| 五家渠市| 闵行区| 长海县| 枣庄市| 若尔盖县|