Jump to content

Newsletter.php sending time


dejansoftware

Recommended Posts

Hi,

 

I have one problem with Newsletter for announcements (Training schedule, Interviews schedule and Exams schedule) which are showing day in future when they have be published. The problem is because my newsletter will send this training, Interviews or Exams schedules one (1) day after the schedule has passed, this is no good and but I would like if he can be sent at least one day before that term, otherwise, the newsletter is useless and just provokes our customers.

 

Here are couple more clarifications.

 

[a]If I publish article/s from different categories, my newsletter will check for new articles and all of them will be grouped by for tomorrows newsletter and automatically sent on 23:00 same day. (this done by cron job on web server - which I don't have access) [/a]

 

Announcement process

18th october is term for an exam. The Newsletter will be sent on 18th october in 23:00. Most of the customers will read it first thing in the morning, that is 19th october, instead of at least 17th october.

 

The problem is just with scheduled articles for future publishing (Training schedule, Interviews schedule and Exams schedule).

 

How can I solve this?

 

Thanks

 

Here is newsletter.php:

<?php
function auto_newsletter(){
global $webpath, $path, $prefix, $admin_mail, $title, $lang;
	$lang = "latn";
$query = sprintf("SELECT datum FROM %s_logs WHERE sistem ='newsletter' LIMIT 1;", $prefix);
$sql = mysql_query($query) or die(mysql_error());
$data = mysql_fetch_array($sql, MYSQL_ASSOC);
$sql = NULL;
	$time = 24;
$Datum = mktime(date("H")-$time, date("i"), date("s"), date("m") , date("d"), date("Y"));
$Datum = strtotime(date('Y-m-d H:i:s', $Datum));
//		$data["datum"] = "2008-03-07 08:00:00 ";
$datum = strtotime(date('Y-m-d H:i:s', strtotime($data["datum"])));
	$datum2 = date('Y-m-d H:i:s', mktime(date("H", strtotime($data["datum"]))+$time, date("i", strtotime($data["datum"])), date("s", strtotime($data["datum"])), date("m", strtotime($data["datum"])) , date("d", strtotime($data["datum"])), date("Y", strtotime($data["datum"]))));
if ($Datum > $datum) {
// This block is for changing views specific articles
// $prije = date('Y-m-d H:i:s', mktime(0, 0, 0, date("m")-3, date("d"), date("Y")));
// $query = sprintf("UPDATE %s_vijesti SET prikaz=0 WHERE objavljen < %s AND kategorija=2; ", $prefix, quote_smart($prije));
//  mysql_query($query) or die(zabrane("error", "Problem u skrivanju konkursa prije $prije"));
// kraj bloka
$query = sprintf("UPDATE %s_logs SET datum=%s WHERE sistem ='newsletter' LIMIT 1;", $prefix, quote_smart($datum2));
$sql = mysql_query($query);
// collecting news for sending
$query = sprintf("SELECT * FROM %s_vijesti WHERE lang='$lang' AND objavljen BETWEEN %s AND %s ORDER BY objavljen DESC; ", $prefix, quote_smart($data["datum"]), quote_smart($datum2));
		$data = NULL;
$sql = mysql_query($query);
		if (mysql_num_rows($sql) <> 0) {
		// postoji li razlog za slanje newslettera
while ($data = mysql_fetch_array($sql, MYSQL_ASSOC)) {
$kat = $data["kategorija"];
if (file_exists($path."/docs/news/".$filename."-mala.jpg")) {
$html .= "<img src='".$webpath."/docs/news/".$filename."-mala.jpg' alt='' title='' align='left' hspace='10' vspace='10' />";
}
			$page = modul_page('news_categorised', $data["kategorija"]);
$html .="<p><strong><a href='$webpath/$lang/?page=$page&kat=$kat&vijest=".$data["id"]."'>".$data["naslov"]."</a></strong>";
$text =  "<p>".strip_tags($data["text"])."<hr />";
$duzina = 400;
while(substr($text, $duzina, 1)<>" " AND strlen($text)>$duzina){ $duzina++; }
$html .= substr($text, 0, $duzina);
}
$html = "<h1>".convert("newsletter").": ".date('d.m.Y.', $datum)."</h1>".$html;
		$query = sprintf("SELECT mail FROM %s_korisnici WHERE alerts>0 AND nivo>0; ", $prefix);
$sql = mysql_query($query) or die(mysql_error());
		if (mysql_num_rows($sql) <> 0) {
require("$path/data/class.phpmailer.php");
			$html = sprintf(convert("notification_header"), $webpath, $webpath, $webpath, $title, $title).$html.convert("notification_footer");
			while ($data = mysql_fetch_array($sql, MYSQL_ASSOC)) {
				$mejl = new PHPMailer();
$mejl->From     = $admin_mail;
$mejl->FromName = $title;
$mejl->Host     = "mail.dars.net";
$mejl->Mailer   = "smtp";
$mejl->Subject  = convert("newsletter").": ".date('d.m.Y.', $datum);
				$mejl->Body    = $html;
$mejl->AltBody = $title."\n________________________________\n".strip_tags($html);
$mejl->AddAddress($data["mail"]);
if(!$mejl->Send()) zabrane("mailer", $data["mail"]);
$mejl->ClearAddresses();
$mejl->ClearAttachments();
			}
		}
}
}

}
?>

Link to comment
Share on other sites

yes, but I don't think that time zone difference is the problem,

 

I think that I should extract those 3 categories (Training schedule, Interviews schedule and Exams schedule) from other news which are OK, and create new role just for them, but I need help to understand how can I do that.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.