send email on specific day

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Tassadduq
Forum Commoner
Posts: 60
Joined: Wed Dec 03, 2008 2:53 pm

send email on specific day

Post 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?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: send email on specific day

Post 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.
User avatar
Tassadduq
Forum Commoner
Posts: 60
Joined: Wed Dec 03, 2008 2:53 pm

Re: send email on specific day

Post 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.
User avatar
Tassadduq
Forum Commoner
Posts: 60
Joined: Wed Dec 03, 2008 2:53 pm

Re: send email on specific day

Post by Tassadduq »

someone help please :( :(
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: send email on specific day

Post by califdon »

I'm not very experienced using cron. Your best bet is to read the instructions: http://www.linuxhelp.net/guides/cron/.
dzelenika
Forum Newbie
Posts: 10
Joined: Sat Feb 20, 2010 2:29 pm

Re: send email on specific day

Post 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
Post Reply