我正在使用PHPMailer库每隔5分钟发送100封电子邮件给我的客户。发送成功。但是当我发送了大约800封电子邮件时,gmail因为垃圾邮件或发送不需要的内容而禁用了我的帐户。我向每个客户发送不同的电子邮件。现在,我担心还有什么要发送太多电子邮件以进行电子邮件营销的。这是我的代码
$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;
}
}
请帮助我知道有什么可以发送到许多电子邮件的,而不会被电子邮件服务提供商禁用。谢谢