Emailing Question

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
User avatar
Mr Tech
Forum Contributor
Posts: 424
Joined: Tue Aug 10, 2004 3:08 am

Emailing Question

Post by Mr Tech »

I'm wanting to send out my email newsletter to over 5000 people using PHP...

Would the mail() function handle that amount or would I have to use something like SMTP? Which is better and faster?

And basically all I would need to get now is a lot of bandwidth and a web host who lets me send out mass emails... Is that correct?

Thanks in advance :)
AimsB
Forum Newbie
Posts: 12
Joined: Thu Jul 08, 2004 9:39 am
Location: UK

Post by AimsB »

I have used mail() to send out mass emails, but not all in one go. The way I would do it is to first of all save all of the email addresses you are sending to into a database, with a status column all set to 0. Select from the database where the status is 0, with a limit of say 50 records. Send the email to those addresses and set their status to 1. Then redirect the page to itself so that it will take the next 50. This may take a little while but is 'safe' because if it ever stops for some reason you will just be able to resume the process, because you have a record of who it has been sent to so far.
User avatar
Mr Tech
Forum Contributor
Posts: 424
Joined: Tue Aug 10, 2004 3:08 am

Post by Mr Tech »

ok thanks.

any other ideas anyone?
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

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... not very efficient.

To send email using sockets, I suggest reading this:
http://cr.yp.to/smtp.html

I would not recommend using the mail() function in PHP for anything over 100 mails, not even using it by breaking out your recipients in batches of 25, 50, 100 etc. and looping with the function.

The mail function in general is pretty weak - your best option would be to open a socket to SMTP and package up the mail in an env and send it at once by using 'RCPT TO:' in the SMTP connection.

Make your connection by using fsockopen() or popen().

Look through the user notes on fsockopen() and you will see a few examples of sending mail to SMTP using this...

Mark

P.S. Also tak a look at phpmailer-class
User avatar
Mr Tech
Forum Contributor
Posts: 424
Joined: Tue Aug 10, 2004 3:08 am

Post by Mr Tech »

Thanjs Mark,

You've been a great help :)
Post Reply