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