12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- require_once 'vendor/phpmailer/phpmailer/PHPMailerAutoload.php';
- include_once 'config/config.php';
- include_once "vendor/notorm/NotORM.php";
- //exit('Commentami, lanciami e ricommentami.');
- function generateLink($url, $token, $ml, $email){
- $link = $url."/mlMemberRoller/stayin.php?";
- $token = "token=".$token;
- $ml = "&ml=".$ml;
- $email = "&email=".$email;
-
- return $link.$token.$ml.$email;
- }
- $pdo = new PDO("mysql:host=".$db_host.";dbname=".$db_dbname,
- $db_user,
- $db_pass
- );
- $db = new NotORM($pdo);
- $mail = new PHPMailer;
- $mail->setLanguage($lang, 'vendor/phpmailer/phpmailer/language/phpmailer.lang-'.$lang.'.php');
- $mail->CharSet = 'utf-8';
- //$mail->SMTPDebug = 5; // Enable verbose debug output
- //$mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = $smtpHost; // Specify main and backup SMTP servers
- //$mail->SMTPAuth = true; // Enable SMTP authentication
- //$mail->Username = $sender; // SMTP username
- //$mail->Password = $credential_pw; // SMTP password
- //$mail->SMTPSecure = $algo_sec; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = $port; // TCP port to connect to
- $mail->isHTML(false); // Set email format to HTML
- $mail->setFrom($sender, $senderName);
- $mail->Subject = $subject;
- $db->debug = true;
- //cerco la ml che ha lo end date.
- //prendo l'id
- //prendo tutte le email con quel id che hanno renewed = 0
- //ciclo
- function getMyDateFormatted($datestr){
- $date = null;
- if(empty($datestr)){
- $date = new DateTime();
- } else {
- $date = new DateTime($datestr);
- }
-
- return $date->format('Y-m-d');
- }
- $last = getMyDateFormatted($rollday);
- $rolls = $db->roll()->where(array(
- "ml" => $ml,
- "endroll" => $last
- ));
- foreach($rolls as $roll) {
- $members = $db->$db_table()->where(array(
- "id" => $roll['id'],
- "renewed" => 0
- ));
- foreach($members as $member) {
- $sanitized_mail = filter_var($member['email'], FILTER_SANITIZE_EMAIL);
- if($sanitized_mail !== "") {
-
- $mail->addAddress($sanitized_mail);
- $token = $member['token'];
- $link = generateLink($mlrollmember_url, $token, $ml, $sanitized_mail);
- $mail->Body = $def_body.$link;
-
- if(!$mail->send()) {
- echo 'Message could not be sent.'."\n";
- echo 'Mailer Error: ' . $mail->ErrorInfo."\n";
- } else {
- echo 'Message has been sent'."\n";
- }
- }
- }
- }
|