sending mails regularly and completly once

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
shivam0101
Forum Contributor
Posts: 197
Joined: Sat Jun 09, 2007 12:09 am

sending mails regularly and completly once

Post by shivam0101 »

I have to send mails to clients depending upon their selection mode - mode's are single, as the event take place OR one single consolidated mail (periodically).

The events are dependent on clients actions.

At present i am sending mails as the event take place.

example,

Code: Select all

function Addme($memberId)
{
   $this->addClient($memberId);
   mail('client_mail_id', 'Member', 'You have been successfully added', "From: $from");
}
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Okay... So what is your question?
sunnyverma1984
Forum Newbie
Posts: 3
Joined: Mon Sep 10, 2007 10:04 am
Contact:

Post by sunnyverma1984 »

i m sure he is asking about linux cronjob
shivam0101
Forum Contributor
Posts: 197
Joined: Sat Jun 09, 2007 12:09 am

Post by shivam0101 »

my question is,

how to do it? i.e should i have to store each step in a separate table and if the user has opted for consolidated, retrieve from that table and send mail OR should i have to query each table and check any event has occurred and if there is any send the consolidated mail. Or is there any better way of doing it.
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Post by Zoxive »

You keep saying how to "do(ing) it". Whats is "it"?

From what i understand, you want to Mail when "Events take place" what are these events, and when do they take place (An example).

Do you want them to e-mail the time of the event? or like a week or so in advance.

You probably want a Cron Job to check and see if you should mail every couple hours or so (Depending on how speedy you want the mail sent in essence to the event time/date)
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

shivam0101 wrote:my question is,

how to do it?
That is a very vague question, one that your code snippet doesn't even really seem to address remotely. However, what you are asking is an interesting thought, and I'll probably end up implementing a similar feature in the future.

I think you should save events as they occur in a table that associates the events with the user. I'd have each event sent to a central event processing object that would do this for me, and then it would have an instance variable that serves as a flag to inform the event processor whether an event has occurred during the current page request. After all of the data is served, the event processor would be told to handle the events. During that process, it would check the user's preferences to see if they wanted per-event notification, and, if they did, get all of their events, mail out notifications, and remove the events from the table. If not, then all of this user's event would remain in the event table.

That's where you'd use a cronjob that would get all of the users who wanted periodic notices, and use that period to mail all of their accumulated events together, and remove them from the events table.

That's how I'd do it at least.
Post Reply