Forum Moderators: bakedjake

Message Too Old, No Replies

send email at a fixed hour

how could I have my webserver send mails daily at 8 AM?

         

siraxi

2:22 am on Feb 24, 2004 (gmt 0)

10+ Year Member



Hello

I have a php website on a Linux server and I'd like to send emails to a list of email addresses taken from a mysql database at a fixed hour, on a daily or user-customized basis.

How can do that?

Is there some script or something?

Thanks is advance!

siraxi

hyperbole

6:12 pm on Feb 24, 2004 (gmt 0)

10+ Year Member



Just a general answer:

Write a script to invoke sendmail. You can do this in perl using Mail::Send.

Then set up a cron that runs the script every day at 0800.

I assume you are using a *nix server. Cron is not provided in windows.

MattyMoose

1:19 am on Feb 26, 2004 (gmt 0)

10+ Year Member




I have a php website on a Linux server and I'd like to send emails to a list of email addresses taken from a mysql database at a fixed hour, on a daily or user-customized basis.

Since you have PHP already installed, and a linux server, that's pretty straight-forward to do (famous last words).
From the PHP perspective, if you don't already have the queries set up to yank all the emails out of MySQL, check out [webmasterworld.com ]. A nice tutorial by Jatar_k, describing basic mysql extraction functions.

Once that's working, you can plug in the emails into the php mail() functions: [ca3.php.net ].

Once *that's* done, you can cron it... the basic syntax is like this:

(this example says do the job at 8 am every day)


#minute hour day of month month of year day of week (0-6; the 0 refers to Sunday) command
0 8 * * * /usr/local/bin/php /path/to/your/script.php&

this does at 8:15, on the 1st of January:

15 8 1 1 * usr/local/bin/php /path/to/happynewyear.php&

Currently php doesn't support modifying crons (AFAIK)

HTH,
-MM

siraxi

5:11 am on Feb 28, 2004 (gmt 0)

10+ Year Member



Thanks! Very helpful!