<?php
$conn
= mysqli_connect(
"localhost"
,
"root"
,
""
,
"mailer"
);
require
"PHPMailer.php"
;
require
"SMTP.php"
;
require
"PHPMailer-master/src/Exception.php"
;
$mail
=
new
PHPMailer\PHPMailer\PHPMailer();
$mail
->isSMTP();
$mail
->Host =
"smtp.gmail.com"
;
$mail
->SMTPAuth = true;
$mail
->Username =
"YOUR SMTP USERNAME"
;
$mail
->Password =
"YOUR PASSWORD"
;
$mail
->SMTPAuth =
"tls"
;
$mail
->Port = 587;
$mail
->setFrom(
"###"
);
$sql
=
"select * from users where send_mail=1"
;
$res
= mysqli_query(
$conn
,
$sql
);
if
(mysqli_num_rows(
$res
) > 0) {
while
(
$x
= mysqli_fetch_assoc(
$res
)) {
$mail
->addAddress(
$x
[
'email'
]);
}
$mail
->isHTML(true);
$mail
->Subject =
"Mailer Multiple address in php"
;
$mail
->Body = "Hii </p>Myself </h1>Rohit
sahu</h1> your Article has been acknowledge
by me
and
shortly this article will be
contributing in</p> <h1>Geeks
for
Geeks !</h1>";
$mail
->AltBody =
"Welcome to Geeks for geeks"
;
if
(
$mail
->send())
{
echo
"Message has been sent check mailbox"
;
}
else
{
echo
"failure due to the google security"
;
}
}
?>