| Server IP : 104.21.21.239 / Your IP : 216.73.216.11 Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5 System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64 User : ec2-user ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/home2/mommybites/automation/ |
Upload File : |
#!/usr/local/bin/php
<?php
echo "START\n"; // TESTING
/**
* set script params
*/
$live = true; // null | true; note: null = test mode and will select more records and send to test addresses
$renewalUrl = 'https://www.mommybites.com/newyork/aroundtown-post/';
$subject_main = 'mommybites reminder - your around town post is about to expire';
$from_email = '[email protected]';
$from_name = 'mommybites';
$reply_email = '[email protected]';
$reply_name = 'mommybites';
if(!$live){
echo "NOT live";
}
/**
* connect to server
*/
require_once($_SERVER['DOCUMENT_ROOT'].'/wp-config.php');
$conn = mysqli_connect(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME);
if (!$conn){
die('mysqli error (' . mysqli_errno($conn) . ' - ' . mysqli_error($conn) . ')');
}
mysqli_set_charset($conn, "UTF8");
/**
* define/execute query
*/
if($live){
$query = "SELECT * FROM aroundtown_post
WHERE DATE(
DATE_SUB(
DATE_ADD(approved_date, Interval (days_to_run) Day ),
INTERVAL 3 Day)
) = CURDATE()
AND
post_status = 'approved' AND is_deleted != 'yes';
" ;
} else { // TESTING
$query = "SELECT * FROM aroundtown_post
WHERE lister_email IN ('[email protected]', '[email protected]')
AND is_deleted = 'no' LIMIT 5" ;
echo $query;
}
$result = mysqli_query($conn, $query);
if (!$result){
die('mysqli error (' . mysqli_errno($conn) . ' - ' . mysqli_error($conn) . ')');
}
/**
* send emails
*/
while($arrRow = mysqli_fetch_array($result) ){
// create message
$message = '';
$message .= 'Dear ' . $arrRow['lister_name'] . ',';
$message .= '<br /><br />Your Around Town posting on the Mommybites website is about to expire. If you would like to renew your posting, please click here: <a href="'.$renewalUrl.'?hashid=' . $arrRow['hash'] . '-' . $arrRow['id'].'">'.$renewalUrl.'?hashid=' . $arrRow['hash'] . '-' . $arrRow['id'] . '</a>. You can resubmit the identical posting or you can make changes to any of the information before you remit payment. Thank you once again for using the resources of www.mommybites.com.';
$message .= '<br/><br/>Sincerely,<br/>The Mommybites Staff';
require_once($_SERVER['DOCUMENT_ROOT'].'/php_mailer_config.php');
$mail = new PHPMailer;
if($live){ // email message
$arBCC = PHPM_BCC;
$arCC = [];
$subject = $subject_main;
$mail_to = $arrRow['reference_email'];
} else {
$arBCC = PHPM_DEV_BCC;
$arCC = [];
$mail_to = PHPM_DEV_TO;
$subject = $subject_main.' - TEST';
echo $message . "\n\n"; // TESTING
echo $query;
}
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP();
$mail->Host = PHPM_SMTP_HOST;
$mail->SMTPAuth = PHPM_SMTP_AUTHENTICATION;
$mail->Username = PHPM_SMTP_USERNAME;
$mail->Password = PHPM_SMTP_PASSWORD;
$mail->SMTPSecure = PHPM_SMTP_ENCRYPTION;
$mail->Port = PHPM_SMTP_PORT;
$mail->setFrom($from_email, $from_name);
$mail->addAddress($mail_to);
$mail->addReplyTo($reply_email, $reply_name);
foreach ($arBCC as $value) {
$mail->addBCC($value);
}
foreach ($arCC as $value) {
$mail->addCC($value);
}
//$mail->addAttachment('/var/tmp/file.tar.gz');
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg');
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = '<html><head></head><body>'.$message.'</body></html>';
$mail->AltBody = '';
if(!$mail->send()) {
echo '<p>Message could not be sent.</p>';
echo '<p>Mailer Error: ' . $mail->ErrorInfo.'</p>';
} else {
echo '<p>Message has been sent</p>';
}
}
echo "DONE\n";
exit();
?>