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 for 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 for 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 for 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 for iLikePHP

Alright. :)

Member Avatar for 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 for 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 for iLikePHP

How long until I can chat? :/

Whenever normally arround most nights

Member Avatar for iLikePHP

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

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.