Mail Call!

      5 Comments on Mail Call!

p. Everybody needs to send mail from their application at one point or another. It’s like using a database or a sledge-hammer, sooner or later, you are going to want to do it. But what’s the best tool? Yesterday I got an email from a “friend of mine”: asking me this question. Since I respect him and his team and they didn’t know the answer, I figure there might be others out there who struggle with this. (It will come as no surprise to those of you who read this site regularly that this is not a comprehensive list but more of a primer to get you going. Comprehensive lists are just too hard.)

p. First and foremost is the venerable “mail()”: function built into PHP. If your needs are modest, this will work just fine. It is simple to use, allows you to fire off an email to multiple users at once and allows you *some* control over what is happening. You do trade off functionality for ease of use but in a lot of cases, this is enough. “There are some gotchas”: to be aware of so like any technology, make sure you understand it before you deploy.

p. Next, “Pear_Mail”: One thing you can say about Pear_Mail is it’s stable. The last release was 09/13/2005. Pear_Mail’s documentation skews towards the PHPDoc style “Here’s what you get” documentation. To it’s credit there are also some “examples”: of how to use it. RFC822 Address validation and an object oriented interface are the two main things that Pear_mail give you. Pear_Mail is like a compact car, it gets the job done with little or no frills. In cases where you need a little more than mail() gives you, Pear_Mail may be all you need.

p. As a new kid on the block, the “Zend Framework”: introduces “Zend_Mail”: with the following features:

* Multiple recipients
* Send email through multiple SMTP accounts
* Send multiple emails in one connection
* HTML email
* Multipart emails for providing text alternative to HTML
* MIME attachments
* Custom mail headers
* Control over character sets
* Support for 8bit, base64, binary, and quoted-printable encoding
* Support for alternative transports

At its current “preview” state, Zend_Mail is really only “missing SMTP authentication”: and embedded image support. I expect more features to come as it progresses.

p. But Cal, I hear you out there saying, I need rich content emails, I need to send directly to SMTP servers, I really need something that will let me message my closest 25,000 friends to tell them how they too can get a free iPod. You are evil, but I’ll help you anyhow. Next in line is one of my favorite tools and the one that I recommended to my friend that he deploy on his site. “PHPMailer”: is available at everybody’s best buddy, SourceForge and is a complete mailing solution. [Warning: blatent content ripoff ahead] Here’s their overview feature list.

* Can send emails with multiple TOs, CCs, BCCs and REPLY-TOs
* Redundant SMTP servers
* HTML email with multipart/alternative emails for mail clients that do not read HTML email
* Support for 8bit, base64, binary, and quoted-printable encoding
* Uses the same methods as the very popular AspEmail active server (COM) component
* SMTP authentication
* Word wrap
* Address reset functions
* Tested on multiple SMTP servers: Sendmail, qmail, Postfix, Imail, Exchange, etc
* Works on any platform
* Flexible debugging
* Custom mail headers
* Multiple fs, string, and binary attachments (those from database, string, etc)
* Embedded image support

p. It’s truly a marvel of modern programming. The “documentation”: is again PHPDoc style so be prepared to go on on an Easter Egg hunt if you need specific information but thankfully both the download and the web site include easy to follow “examples”:

p. Well that’s it for today. Please feel free to send me those ever popular “You forgot my favorite mailer class” emails. I especially like the ones that go longer than 2 pages explaining why your favorite is the best. Really, those make my day.