The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

PEAR:Mail, mail(), phpmailer...

I have a newsletter system that i was using phpmailer to send, and it's to the point now where I can't take phpmailer's flakyness anymore. It's a real crap shoot as to which silly errors are going to choke it.
I had an issue with it yesterday where I reverted to using php's mail(). I know i was told before that using mail() was a no no, but it sent my 900 email no problem and in about half the time phpmailer was taking.

php.net suggests using PEAR:mail for sending out bulk mail but doesnt say why. I don't want to have to cross my fingers everytime I need to send out newsletters.

I have a newsletter system that i was using phpmailer to send, and it's to the point now where I can't take phpmailer's flakyness anymore. It's a real crap shoot as to which silly errors are going to choke it.
I had an issue with it yesterday where I reverted to using php's mail(). I know i was told before that using mail() was a no no, but it sent my 900 email no problem and in about half the time phpmailer was taking.

php.net suggests using PEAR:mail for sending out bulk mail but doesnt say why. I don't want to have to cross my fingers everytime I need to send out newsletters.

My question is what do you use to send out mail?

mail() may be ok for bulk mailing if you are not using safe mode and the messages are small. Otherwise you may run into inconviniences.

If you are using Linux/Unix it is more recommended a a solution that uses sendmail or equivalent directly because you have more control over details that may make significant different in terms of mailing queueing performance.

It was specifically optimized for bulk mailing. It supports several delivery methods (mail, sendmail, qmail, SMTP, Windows pickup, etc..) You just need to call a function named SetBulkMail to hint the class to optimize its behavior for sending messages to many recipients, regardless of the delivery method. It makes a big difference, especially when you are using sendmail or Exim as MTA.

Other than that, if you are not personalizing message bodies, the class has a variable to tell it to cache the message bodies between deliveries. This saves a lot of time by only building the message body once. You can still personalize message headers for each recipient.

I use this class for sending over 4 million newsletter messages a month. The performance optimization options that I mentioned made a big difference. Queueing between 30 and 40 messages per second are typical figures.

mail

Originally Posted by mlemos

and the messages are small.

My nessages consist of a few lines of plain text only.

Originally Posted by mlemos

between 30 and 40 messages per second

I dont know what the "per second" rate of my script would be, I put a delay between the sends to avoid any potential queing problems. After reading mlemos' post, my script, although adequate for my needs at present, does seem in need of replacement. (at least if my newsletter subscriptions ever get bigger)

I dont know what the "per second" rate of my script would be, I put a delay between the sends to avoid any potential queing problems.

Yes, a delay is wise if you are short of disk space, your script takes too much CPU or you are consuming too much instant bandwidth. I have another class that checks disk space and CPU usage but it only works on Linux.

After reading mlemos' post, my script, although adequate for my needs at present, does seem in need of replacement. (at least if my newsletter subscriptions ever get bigger)

Maybe. Usually you hit some hosting environment limit or you are warned by your hosting people that you are taking too much resources when your newsletter subscriber count grows. So, you need to upgrade hosting package or make the deliveries more efficient.

Other than that, it is also important to compose messages properly according to MIME standards to prevent that the message arrived corrupted or be confused with SPAM. There are many details to considers about these aspects. A good ready to use MIME message composing and sendind class may solve most of the concerns.

PHPmailer not so bad

In response the the PHPmailer user. I've had good luck with PHPmailer. My largest send is about 15,000 html emails. I do this at least once a week. One thing to make sure is that you are unsing the most recent version of PHPmailer. For a while an older version I used was sending duplicates. This was solved by updating to the most recent version. I also have a system by where I mark each email in my email cue table as pending when its queryed and sent when it's sent. There was a time when I was re-querying the same recipient before the server had a chance to send the intitial email. I also have good luck using the smarty template in conjunction with PHPmailer. To track bounces I use a company called bbounce.com and I use the 1 pixel image in my html emails to get a feel for who opened them. It's been quite a learning curve for me and it's still continueing. Good luck ...

thanks, I'd been using phpmailer(the latest) and just find it too unreliable. Weird errors would crop up like "can't load language blah, blah" only on occasion or just crap out all together. I dealt with it for about a year, but can't go on.

XPertMailer is a PHP class that you can use to send encoded MIME type e-mail messages (text, HTML, HTML embedded images, attachments) towards a localhost, client or relay SMTP servers with optional authorisation. Cc and Bcc functionality are included.
The XPertMailer class functions are optimised to execute in a very small time and allso to be easy to use. This reduces the size of the code and the time required to write it.
The names of the public functions in the XPertMailer class are eloquent so that they can be used without any confusions being made.
The data sendig is done according to the RFC 821 and RFC 2821, and the message type is in conformity with the RFC 2045, RFC 2046, RFC 2047, RFC 2048, RFC 2049, and RFC 2822.

// set HTML embedded images name and optionaly you can rename them
// if the file is not in this directory, write the path name (/path/name.image_extension)
// Attention: do not include path name in the rename file like /path/rename.gif, put only rename.gif
$imgs[] = 'image1.jpg';
$imgs['rename.gif'] = 'image2.gif';

// attach HTML embedded images
$mail->attach($imgs, ATTACH_HTML_IMG);

// set attachment files name and optional you can rename them
// if the file is not in this directory, write the path name (/path/name.file_extension)
$file['new.zip'] = 'archive1.zip';
$file[] = 'archive2.tar.gz';

// send to multiple e-mail addresses and optionaly you can set charset value (here UTF-8, by default is ISO-8859-1)
// as you can see, the text/plain message is required because not all mail clients can currently support HTML messages
$send = $mail->send('touser@domain1.com, toanotheruser@domain2.com', 'subject here', 'text version'.CRLF.'new line', $html, 'UTF-8');