Author Topic: Send scheduled messages at different times each day - v1.88 mod  (Read 9102 times)

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
Send scheduled messages at different times each day - v1.88 mod
« on: February 08, 2015, 06:46:09 am »
Until this becomes a feature, here's a hack:

Copy dailymail.php to dailymail2.php. Edit dailymail2.php as follows:

Change "2" to "99" on line 146:

Code: [Select]
$batid = qstart(99);
This prevents the Dailymail report from being sent when there are messages.

--------------------

Add ",date" to line 446:

Code: [Select]
   $qrows = mysql_query("select id,list,subject,message,htmessage,fattach,date from $qtable where date <= '".date("Y-m-d")."' and type = 'm' order by id");
Add ",$qdate" to line 449:

Code: [Select]
    while(list($qid,$qlist,$qsubj,$qmsg,$qhtmsg,$qfatt,$qdate)=@mysql_fetch_row($qrows)){
The queued date is retrieved for comparison later.

--------------------

Add " && false" to line 848:

Code: [Select]
  if($sendq==0 && false){
This disables the Dailymail Report when there are no messages.

--------------------

Add this starting at line 450, after the line "while(list($qid ...":

Code: [Select]
     // BEGIN TIME MOD
     $dstime='0000'; // default sending time 0000 to 2359
     list($stime)=explode(' ',$qsubj);
     if(is_numeric($stime) && strlen($stime)==4) $qsubj=substr($qsubj,strpos($qsubj,' ')+1); else $stime=$dstime;
     if(round($stime)>date("Gi") && $qdate==date("Y-m-d")) continue;
     // END TIME MOD

This checks the subject for the time and removes it if found, and skips sending if a message is scheduled for later than the current day and time.

--------------------

If you're using the optional daily-xtra.php script, "comment out" lines 841-845, like so:

Code: [Select]
// if(file_exists('./daily-xtra.php')){
//    if($outp) echo "Running daily-xtra.php..<br>";
//    include('./daily-xtra.php');
//    mysql_select_db($sqldb);
//  }

--------------------

Notes / instructions:

- Add &nosched=1 to the regular dailymail.php once-per-day cron task to suppress scheduled message processing, e.g. as follows (note: quotes around URL are important):

Code: [Select]
0 0 * * * /usr/bin/wget -O /dev/null -T 0 "http://example.com/mail/dailymail.php?pw=YourDailyMailPass&nosched=1" 1>/dev/null 2>&1
- Schedule the modified (see above) dailymail2.php script for every 15 or 30 minutes, skipping 'last ran' checking and updating and suppressing all but scheduled messages, e.g. as follows:

Code: [Select]
*/15 * * * * /usr/bin/wget -O /dev/null -T 0 "http://example.com/mail/dailymail2.php?pw=YourDailyMailPass&warn=no&nolastran=1&nomaint=1&nofups=1&nobounce=1&noscfup=1&noremind=1" 1>/dev/null 2>&1
- There is currently no report sent to the admin when scheduled messages are sent. It is recommended to set up test addresses on your lists and perhaps enable the SMTP log temporarily to ensure everything is being sent to the server as expected. A custom report could be added fairly easily but I wanted to publish the mod in its simplest form first and foremost.

- To schedule by time, add 4 digits and a space to the beginning of the subject when scheduling messages, e.g. "1234 Example Subject". The dailymail2.php script will read the digits as the time to send (0000 to 2359), and remove them automatically before sending. Note that if any combination other than 4 digits and a space appears it will NOT be processed or removed and the default time as configured in the mod (above set to 0000, midnight) will be used instead.

- All times use the server time zone which can be viewed on the Dailymail page within LMP.
« Last Edit: March 22, 2015, 07:03:30 am by DW »
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting

BGSWebDesign

  • Posts: 625
    • View Profile
    • http://www.bgswebdesign.com
Re: Send scheduled messages at different times each day - v1.88 mod
« Reply #1 on: March 23, 2015, 07:56:38 pm »
DW,

That's totally awesome!  I've always wanted something like that, now to add it by hotlinking the time (by prefixing directly in the subject of the message) that's really, great, and a fantastic help... I'm finding myself that many people are more likely to respond, and make purchases at certain times of the day.

There's one little thing that would also be nice... Many of the big mailers also do this where they send the followups to each user within 2-3 minutes of when they signed up - claiming that they are more likely to respond at that time, as that's the time they were online to sign up...   It seems that would have to be recorded for each user?  Is something like that possible, or in the works for the next version?

Finally - one more thing, what I've noticed is that customers in other timezones, such as in Europe (which are 6 hours ahead of me most of the year), are also more likely to respond at the same, or similar times as USA customers - IF the time that the email is sent to them is adjusted for the timezone for each user.  Now, that would really be incredible, but once again, it appears it requires you to store the timezone of each user, and send based on that timezone, rather then based on the server timezone.  Is there anything like that coming in the next version? 

Thanks,
-Brett
http://www.bgswebdesign.com/Contact-Us.php

*** I do custom List Mail Pro installations ***
Contact me through my website (above)