Hello,

I am currently working on a project which involves sending email out automatically when certain conditions are met in a MySQL dB using a php script, I have managed to build the email part and works, my question is how do you prevent an email being sent out twice when a condition is met, I only want one email to go out when a certain condition is met, my problem is this will be set as a cron tab so it will be running all the time, is there a variable I can use to prevent duplicate emails

Apologies if I'm not very clear and feel free to ask me for any further info

Cheers
Martin

It's easy enough to set a flag (by user) in the database to indicate that the email has been sent. The more important issue is: Can this set of conditions occur again, necessitating a further email? If so, there has to be some sort of reset process to end the first occurrence and set everything back to "Normal" and unset the flag. Otherwise you have the opposite problem and you'll never send another email after the first.

Thanks, I'll have a play with some code and see what I can come up with

Cheers,

Member Avatar

iLikePHP

Want me write up a quick example for you?
I use it on pingrglobe.com for a mailing queue. :)

Hi iLikePHP

Yes please can you write me a quick example to get me started it will be of great help,

Cheers

Member Avatar

iLikePHP

I'll get it done for you in an hour or two if I have time, working on PingrGlobe a little(which you should sign up for if you've a website hint hint)

Member Avatar

iLikePHP

Since I've not had enough time...
You'd want to make a database table such as "queue" and then do:
email_id(just because, it's good to have IDs)
to(varchar)
subject(varchar)
message(varchar)
sent(int/bool)
And then use a cron to send out emails with "sent" = 0, and when sending it out... set "sent" = 1.

Hope this helps!

Thanks, Will have a go later

P.S. I've signed up to PingrGlobe, looks great!!!

Member Avatar

iLikePHP

Alright. :)

Member Avatar

iLikePHP

Awesome!
You tried PingrGlobe yet? :)
You made an account, but no server... need help?
"urbanthistleuk" is your username if I am correct, and good at matching it here and there. :P

Hi,

Yeah I have added an account and server, works like a dream!!

Member Avatar

iLikePHP

Cool!
If your VPS(judging by "My VPS" :P) is hosting a popular site, I would recommend 30 minute checks.
If you need any help, open a support ticket. :)

Hello valued members-

Your current converstation is now off topic. Please continue your converstation about your extrenal, unrelated product either in a chat session or in a new thread within the Business Exchange category.

Users that arrive at this thread would be interested in the original topic.

thank you.

Member Avatar

iLikePHP

How long until I can chat? :/

Member Avatar

iLikePHP

Woop! I just gained the privilege to chat!
<3 DaniWeb