Avatar of jericotolentino
jericotolentinoFlag for Philippines

asked on 

How to send emails at a regular interval

Dear experts,

I'm trying to figure out a way to send emails at a regular interval, say every 15 seconds, so spam filters won't mark them as spam. I've got my email addresses in a text file which is loaded into a PHP array. Then, they're just sent to the mail server using the mail function.

My problem is, Apache times out when by the time I get to the third email because I used the sleep function for the delay. I was thinking AJAX and/or JavaScript would be useful, but so far all I've found where countdown scripts to a specific time in the future. Any ideas on how this can be solved/improved?

I'm developing this under a Windows XP system.


Avatar of undefined
Last Comment
Avatar of Steve Bink
Steve Bink
Flag of United States of America image

I do not believe adding a delay between sending will help you.

I'm certainly no expert on email, but I don't think they get marked as spam because of when they were sent, and certainly not in comparison to the next message sent.  Outside of the originating server, one message has absolutely no relation to the next.  I've sent more than 6000 emails in a single batch and never had an issue with them being marked as spam.  From my *very* basic knowledge of spam filters, they look at other characteristics like content, address resolution, etc.  Perhaps there is something in your content triggering the spam filter?
Avatar of geoffreyreemer

Agreed with routinet. I developed several mailscripts for companies that have been sending big batches of e-mail and it does work fine. The main criterium for "spam" (other than the standard word-checks) is if the e-mail is actually sent from the server it claims to be sent from. For example: if you use the mailaddress info@yourcompany.com, you should launch the mailscript from the yourcompany.com webserver. Otherwise mail programs will know they have been lied to and that your mail has been sent from mailserver.com. And then they might mark your mail as spam.

But in my experience, being marked as spam doesn't have that much to do with mail intervals. So I wouldn't go through all that trouble writing all those workarounds.
Avatar of RWJDCom
Flag of United States of America image

Blurred text
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Steve Bink
Steve Bink
Flag of United States of America image

Setting the max_execution_time may keep Apache from timing out, but that will not address the email being picked up as spam.  You'll have to audit your email server and email content to find out why your mail is being flagged.
Avatar of RWJDCom
Flag of United States of America image

That is true; but it will keep the script running and that seemed to be the question that he was asking.  He wanted to know how to stop apache from timing out.

As far as the spam question goes.  I would suggest you try using PHPMailer to send out your emails.  I was sending out emails using the simple mail function and it got flagged as spam but when I used PHPMailer and embeded the images and sent a plain text version of the email as well it did not get picked up as spam.  Try it out and let me know if that works for you.
Avatar of Steve Bink
Steve Bink
Flag of United States of America image

No worries, RWJDCom.  I just wanted to make sure he understood what your suggestion affected.  

I also use a third-party mailer, Richard Heyes' email class...LUV IT!

** Title.........: HTML Mime Mail class
** Version.......: 2.0.1
** Author........: Richard Heyes <richard@phpguru.org>
** Filename......: class.html.mime.mail.class
** Last changed..: 11 October 2001
** License.......: Free to use. If you find it useful
**                 though, feel free to buy me something
**                 from my wishlist :)
**                 http://www.amazon.co.uk/exec/obidos/wishlist/S8H2UOGMPZK6
Avatar of jericotolentino


Thanks! I'll work on the spam issue next, but at least I got the timeout issue out of the way. Sorry for the confusion.

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews


IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo