doubianxian6557 2019-02-08 10:15
浏览 193

gmail禁用了我的帐户,通过PHPMailer库发送了太多电子邮件

I'm using PHPMailer library to send 100 emails to my customers after every 5 mints. It was sending successfully. but when i had sent about 800 emails, gmail disabled my account because spamming or sending unwanted content. I was sending different email to every customer. Now i'm worried is there anything else to send too many emails for email marketing. here is my code

$sql="SELECT * FROM send_user_link LIMIT 100";
$result=$conn->query($sql);
while($row=$result->fetch_assoc()){

    $email=$row['email'];
    $name=$row['name'];
    $id=$row['id'];
    $code=$row['code'];


    $e_subject="Support";
    $msg="<h5>how are you doing??</h5>";

    send_email_to_users($conn, $id, $email, $e_subject, $msg, $name);

}

function send_email_to_users($conn, $user_id, $to_email, $subject, $msg, $name){

    $mail = new PHPMailer();                              // Passing `true` enables exceptions
    //Server settings
    $mail->SMTPDebug = 2;                                 // Enable verbose debug output
    $mail->isSMTP();                                      // Set mailer to use SMTP
    $mail->Host = 'smtp.gmail.com';  // Specify main and backup SMTP servers
    $mail->SMTPAuth = true;                               // Enable SMTP authentication
    $mail->Username = 'myacount@gmail.com';                 // SMTP username
    $mail->Password = '*******';                           // SMTP password
    $mail->SMTPSecure = 'ssl';                            // Enable TLS encryption, `ssl` also accepted
    $mail->Port = 465;                                    // TCP port to connect to

    //Recipients
    $mail->setFrom('myaccount@gmail.com', 'Support');
    $mail->addAddress($to_email, $name);     // Add a recipient

    //$mail->addAddress('ellen@example.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 = $subject;
    $mail->Body    = $msg;
    $mail->AltBody = 'how are you doing??';

    $user_id = mysqli_real_escape_string ($conn, $user_id );

    if ($mail->send()) {

        echo 'Message has been sent';

    }
    else{

        echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
    }

}

Please help me to know is there anything to send to many emails without getting disabled from email service providers. Thank you

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?
    • ¥15 matlab(相关搜索:紧聚焦)
    • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计