Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP mail problem 1

Status
Not open for further replies.

Dweezel

Technical User
Feb 12, 2004
428
GB
We have a PHP shopping cart application on our website called X-Cart. One of its features is for customers to sign up to a newsletter, which we send out quarterly. They are sent out by a php script which runs by pressing a button in the X-Cart admin panel (browser based PHP page), and we have been having some problems with this.

The browser seems to time out before all the emails are sent. We have 4500 people signed up to the email, and X-Cart has no way of logging which emails were sent.

We've got someone who will be looking into this problem for us but in the meantime we need a short term solution for sending out our latest newsletter. The newsletter subscribers table (mysql) consists of three rows:
'id' - an auto incrementing integer field
'email'
'since_date' - a unix timestamp for when they subscribed.

I'm considering setting up another table which will have rows:
'id' - relates to subscriber id above
'newsletter_id' - the newsletter edition number.

I could then set up a php script with a for loop and a mysql query to run as a cron job. It could get the subscribers from the newsletter subscribers table (perhaps 50 addresses each time it runs) and then send out the email newsletter using the PHP Mailer class. After a successfully sent email the newsletter edition number would be added to that subscriber’s id in the second table.

Does this sound feasible as a short term stop gap while we look for a solution? Are there any unforeseen gotchas that I'm missing by sending out 4500 emails this way? If how many emails I send and how often is an issue, how many emails do you think I should send out on each run of the cron job, and how often do you think it should run?

TIA,

Chris.
 
the problem will be that you are using mail() to send your mailshots.
this is a snapshot from the manual

phpmanual said:
Note: It is worth noting that the mail() function is not suitable for larger volumes of email in a loop. This function opens and closes an SMTP socket for each email, which is not very efficient.
For the sending of large amounts of email, see the » PEAR::Mail, and » PEAR::Mail_Queue packages.

so i'd advise following the author's advice!

or at least running your normal script in batches of 100 with a long sleep period between each batch (say 2-5 minutes).

consider also buying some proper list management software that will track the sending for you. and use phpmailer. they have a new class out for mailing lists: arriving 1/july
 
Thanks a lot jpadie. I'll look into all of your suggestions.

Chris.
 
You might also wish to consider an online mailing service such as MailChimp.

--
Tek-Tips Forums is Member Supported. Click Here to donate

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top