Zend Developer Zone
Where the ElePHPants come to learn

Zend Developer Zone

Rob Allen blogs on sending mail with Zend\Mail

VERY Old Content Warning!

The content you are viewing is more than two years old. It is here for archival purposes. Do not use any advice in this article without double-checking it with a current source.


Over on his blog, Zend Framework master Rob “Akrabat” Allen has a short post titled Sending an HTML with text alternative email with Zend\Mail.

Sending a multi-part email with Zend\Mail is easy enough, but if you want to send an HTML email with a text alternative, you need to remember to set the content-type in the headers to multipart/alternative. As this is the second time I had to work this out, I’m noting it here for the next time I forget!

That quote is quite literally the entire non-code portion of the code. (It’s what we call long on the HOW short on the WHY) The rest of the post gives you all kinds of cut-n-paste goodness to get you going. If you are working with Zend Framework, this is one you will want to bookmark. This is one of those posts that you know you are going to need eventually, even if you don’t right now.

Many moons ago, at the tender age of 14, Cal touched his first computer. (We're using the term "computer" loosely here, it was a TRS-80 Model 1) Since then his life has never been the same. He graduated from TRS-80s to Commodores and eventually to IBM PC's. For the past 10 years Cal has worked with PHP and MySQL on Linux OSX, and when necessary, Windows. He has built on a variety of projects ranging in size from simple web pages to multi-million dollar web applications. When not banging his head on his monitor, attempting a blood sacrifice to get a particular piece of code working, he enjoys building and managing development teams using his widely imitated but never patented management style of "management by wandering around". Cal is happily married to wife 1.31, the lovely and talented Kathy. Together they have 2 kids who were both bright enough not to pursue a career in IT. Cal blogs at http://blog.calevans.com and is the founder and host of Nomad PHP