Page 1 of 1

send email on specific day

Posted: Sat Feb 20, 2010 2:22 pm
by Tassadduq
hi i have a simple email sending script for my site members. it works fine in all sections of my site now i want to use the same script to send weekly newsletter to all my site members.
here is my email sending script

Code: Select all

<?PHP
$SQL_UGET = mysql_query("SELECT * FROM subscribers");
    $NUM_UGET = mysql_num_rows($SQL_UGET);
    if($NUM_UGET > 0){
        while($ROWS_UGET = mysql_fetch_array($SQL_UGET));{
            $UEMAIL = $ROWS_UGET['email'];          
        }
    }               
    $msg = 'here goes my newsletter message';
    $to = $UEMAIL;
    $from = "My Site Name";
    $sub = "weekly newslatter";
    
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'From:'.$from."\r\n";
    $smail = mail($to, $sub, $msg, $headers);
?>
problem is that i want to specify a time to send email automatically means i want to send the newsletter on every saturday of the week.
could anyone help me how to set the time for send the automated mail on every saturday?

Re: send email on specific day

Posted: Sat Feb 20, 2010 2:33 pm
by califdon
Scheduling tasks is a system function. If it's a Linux server, use cron. If it's a Windows server, use Windows Scheduler.

Re: send email on specific day

Posted: Sat Feb 20, 2010 3:01 pm
by Tassadduq
i am using linux web server and my hosting allowed me to use cron jobs.
i have created a cron job.
please let me know that if i want to send email on every saturday than should i have to use these seeting?

Minute Hour Day Month Weekday Command
15 8 * * 1 /home/mysite/newsletter/send.php

the send.php contains the email sending script.

Re: send email on specific day

Posted: Sat Feb 20, 2010 3:37 pm
by Tassadduq
someone help please :( :(

Re: send email on specific day

Posted: Sat Feb 20, 2010 4:51 pm
by califdon
I'm not very experienced using cron. Your best bet is to read the instructions: http://www.linuxhelp.net/guides/cron/.

Re: send email on specific day

Posted: Sat Feb 20, 2010 5:08 pm
by dzelenika
Tassadduq wrote:i am using linux web server and my hosting allowed me to use cron jobs.
i have created a cron job.
please let me know that if i want to send email on every saturday than should i have to use these seeting?

Minute Hour Day Month Weekday Command
15 8 * * 1 /home/mysite/newsletter/send.php

the send.php contains the email sending script.
15 8 * * 1 /path/to/php/php /home/mysite/newsletter/send.php