多人邮箱发送

如有问题,请联系    1184139881@qq.com

email.php

<?php
 header("Content-type:text/html;charset=utf-8");
 require 'phpmail/PHPMailerAutoload.php';
 $dsn = 'mysql:host=127.0.0.1;dbname=library;port=3306;charset=utf8';
 $pdo = new \PDO($dsn,'root','root');
 $sql = "select * from email where is_no=0 and nub<=3";
 $data = $pdo->query($sql)->fetchAll(\PDO::FETCH_ASSOC);
// var_dump($data);exit;
 $mail = new PHPMailer();
 $email = new myemail();
// 719305759@qq.com
 // 1290528913@qq.com
 foreach ($data as $k => $v) {
      $url = $v["email_url"];
      $aa = $email->email($mail,$url);
       echo $aa."<br>";
 }


class myemail{
    public $host='smtp.qq.com';
    public $username='1184139881@qq.com';
    public $smtpsecure= 'xxx';
    public  function email($mail,$youname){
    

    
    //var_dump($mail );exit;

    $mail->isSMTP();                                      // Set mailer to use SMTP
    $mail->Host = $this->host;  // Specify main and backup SMTP servers
    $mail->SMTPAuth = true;                               // Enable SMTP authentication
    $mail->Username = $this->username;                 // SMTP username
    $mail->Password = 'znvkwgmopzndcbaa';                           // SMTP 授权码
    $mail->SMTPSecure = $this->smtpsecure;                            // Enable TLS encryption, `ssl` also accepted
    $mail->Port = 465;                                    // TCP port to connect to

    $mail->setFrom($this->username, 'Mailer');
    $mail->addAddress($youname, 'Joe User');     // Add a recipient
    // $mail->addAddress('1142165466@qq.com');               // Name is optional


    $mail->addAttachment('http://easyread.ph.126.net/f4GyETZyCBST24wxevNgrw==/7916587074082229398.jpg');         // Add attachments

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

    $mail->Subject = '渲染';
    $mail->Body    = ' 大家好<img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1503070900379&di=0c0648c40e2941f161e26fc04a29875d&imgtype=0&src=http%3A%2F%2Fpic5.qiyipic.com%2Fcommon%2F20130524%2F7dc5679567cd4243a0a41e5bf626ad77.jpg%3Fsrc%3Dfocustat_4_20130527_7" style="width:100px;height:100px;"><a href="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1503070900379&di=0c0648c40e2941f161e26fc04a29875d&imgtype=0&src=http%3A%2F%2Fpic5.qiyipic.com%2Fcommon%2F20130524%2F7dc5679567cd4243a0a41e5bf626ad77.jpg%3Fsrc%3Dfocustat_4_20130527_7">查看这个图片</a>';
    // $mail->AltBody = '哈哈哈哈哈^=^<a href="192.168.1.245">确认激活<a>';

    if(!$mail->send()) {
        echo 'Message could not be sent.';
        echo 'Mailer Error: ' . $mail->ErrorInfo;
    } else {
        $mail->clearAddresses();
        $mail->clearAttachments();//如果有附件,附件也clear一下
        echo   1 ;//'消息已sentnull';
    }
}
}
?>

此外,还需下载三个文件,class.phpmailer.php,  class.phpmaileroauth.php,   class.smtp.php



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值