96 lines
4.0 KiB
PHP
96 lines
4.0 KiB
PHP
<?php
|
|
use PHPMailer\PHPMailer\PHPMailer;
|
|
require( '/var/www/vhosts/graspa.org/httpdocs/vendor/autoload.php' );
|
|
|
|
$mail = new PHPMailer;
|
|
|
|
//Enable SMTP debugging.
|
|
$mail->SMTPDebug = 3;
|
|
//Set PHPMailer to use SMTP.
|
|
$mail->isSMTP();
|
|
//Set SMTP host name
|
|
$mail->Host = "smtp.gmail.com";
|
|
//Set this to true if SMTP host requires authentication to send email
|
|
$mail->SMTPAuth = true;
|
|
//Provide username and password
|
|
$mail->Username = "steamwarebot@gmail.com";
|
|
$mail->Password = "drmfsls16";
|
|
//If SMTP requires TLS encryption then set it
|
|
$mail->SMTPSecure = "tls";
|
|
//Set TCP port to connect to
|
|
$mail->Port = 587;
|
|
|
|
$mail->From = "graspa@graspa.org";
|
|
$mail->FromName = "Administrator Graspa";
|
|
|
|
//$mail->addAddress("marco@steamware.net", "Autore");
|
|
//$mail->addAddress("name@example.com", "Recepient Name");
|
|
|
|
$mail->isHTML(true);
|
|
|
|
$mail->Subject = "Approvazione articoli Graspa";
|
|
|
|
$username="graspa";
|
|
$password="7ZRAf2#pa8";
|
|
$hostname = "localhost";
|
|
|
|
//connection string with database
|
|
$dbhandle = mysqli_connect($hostname, $username, $password)
|
|
or die("Unable to connect to MySQL");
|
|
|
|
// connect with database
|
|
$selected = mysqli_select_db($dbhandle, "graspa")
|
|
or die("Could not connect to DB");
|
|
|
|
$query = "SELECT DISTINCT IZU92ap5P_articoli2autori.email FROM IZU92ap5P_articoli2autori";
|
|
|
|
$result = mysqli_query($dbhandle,$query);
|
|
$rows = [];
|
|
|
|
while($row = mysqli_fetch_array($result))
|
|
{
|
|
$rows[] = $row;
|
|
$query2 = "SELECT IZU92ap5P_articoli2autori.doi,IZU92ap5P_articoli2autori.email,IZU92ap5P_articoli.title FROM IZU92ap5P_articoli2autori
|
|
INNER JOIN IZU92ap5P_articoli ON IZU92ap5P_articoli2autori.doi = IZU92ap5P_articoli.doi
|
|
WHERE IZU92ap5P_articoli.appr = 0 AND IZU92ap5P_articoli.veto = 0 AND IZU92ap5P_articoli2autori.email = '$row[0]'
|
|
GROUP BY IZU92ap5P_articoli2autori.email,IZU92ap5P_articoli.doi
|
|
LIMIT 3";
|
|
$result2 = mysqli_query($dbhandle,$query2);
|
|
//echo $query2;
|
|
while ($rowdoi = mysqli_fetch_array($result2))
|
|
{
|
|
//echo $rowdoi[0];
|
|
//echo $rowdoi[1];
|
|
//$headers = '';
|
|
//$headers .= 'MIME-Version: 1.0' . "\r\n";
|
|
//$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
|
|
//$from = 'mario@graspa.org';
|
|
date_default_timezone_set('Europe/Rome');
|
|
$date = date('d/m/Y h:i:s a', time());
|
|
$to = $rowdoi[1];
|
|
$mail->addAddress("$rowdoi[1]", "Autore");
|
|
|
|
//$to = $row_data['email']; // The column where your e-mail was stored.
|
|
//$subject = 'Approvazione articoli Graspa';
|
|
$mail->Body = "Buongiorno tramite questa mail è possibile inserire il seguente articolo/pubblicazione :"."<br><br><b>".$rowdoi[2]."</b><br><br>"." sul sito graspa.org cliccate sul link <a href=\"http://graspa.org/?email=".$to."&doi=".$rowdoi[0]."&appr=1"."&veto=0\">APPROVA</a> per acconsentire oppure sul link <a href=\"http://graspa.org/?email=".$to."&doi=".$rowdoi[0]."&appr=0"."&veto=1\">RIFIUTA</a> per non dare il consenso"."<br>"." "." "."<br>Messaggio inviato il ".$date."<br> Grazie";
|
|
//$mail->Body = "APPROVA <a href=\"http://graspa.org/?email=".$to."&doi=".$rowdoi[0]."&appr=1"."&veto=0\">$rowdoi[2]</a>"."<br>"." "."RIFIUTA <a href=\"http://graspa.org/?email=".$to."&doi=".$rowdoi[0]."&appr=0"."&veto=1\">$rowdoi[2]</a>";
|
|
|
|
//$msg = "APPROVA <a href=\"http://localhost/test/?email=".$to."&doi=".$rowdoi[0]."&appr=1"."&veto=0\">$rowdoi[2]</a>"."<br>"." "."RIFIUTA <a href=\"http://localhost/test/?email=".$to."&doi=".$rowdoi[0]."&appr=0"."&veto=1\">$rowdoi[2]</a>";
|
|
|
|
if (empty($rowdoi[0])){
|
|
continue;
|
|
} else {
|
|
//mail($to, $subject, $msg,$headers);
|
|
if(!$mail->send())
|
|
{
|
|
echo "Mailer Error: " . $mail->ErrorInfo;
|
|
}
|
|
else
|
|
{
|
|
echo "Message has been sent successfully";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
?>
|