Hello Friends,

I want to send emails daily 3 times,6 times a day automatically with my PHP code.
the people who r registered for them only.
i require help in sheduled mail code.
iam not getting any idea on how to send scheduled mails.

r provide any links related to this please

Thnaks in advance

Recommended Answers

All 5 Replies

Hello Friends

I want to create an option to the user to suscribe to a service that sends an automatic mails everyday with information taken from a database created in MySQL. I have the form and the access with PHP to the database and I can send an automatic mail at the moment that the users press a button to activate the action, but I do not know how to do it everyday

Say you have email sending script in php which reads the information from the database and sends out the mail if some users have suscribed for a service. Now let us assume you need to send email everyday at 09:00 A.M. So that means you need to automatically execute the email sending script at 09:00 A.M everyday. That is where the cron job comes into play. You need to set up a cron job which will execute the php email sending script everyday at 09:00 A.M

For more details on setting up a cron job please go through the links i have provided in my earlier post. They contain information on setting up a cron job on both windows and unix platforms.

Thanks for providing the links

I seen those links and

the modifications have to be done in server?

i want to take the values from database and send the users the no of mails daily (2 times ,3 times ) as they provided the value at subscribing time

please provide some info on this

Thank u in advance

yes you need to make those changes in the server. Also the best way to do it is say have only one php script being scheduled every 1min, 10 mins or say every hour ( according to your need ).
Say for example you create one script called maincron.php which will be scheduled to call every minute. Now you can have your maincron.php something like this...

$hr = date("H");
$min = date("i");

// say  you want to send mails at 08:00 A.M and 10:00 A.M every morning
if ( ($hr == "08" && $min == "00") || ($hr == "10" && $min == "00") ) {
if ($hr == "18" && $min == "30") {
    // call some other file ( This may be for some other purpose )

This way you can have only one cron job set to call many other files depending on your need.
I hope this helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.