Zen(d) and the Art of Email
|
|
|
Click to rate: |
|
|
|
74 votes / avg. rating 15.70%
|
|
Since the beginning of Internet time man has strived for the best way to send emails from a program. Whether a web page that notifies its owner when an order is placed to merchants sending a welcomed message to its closest 250,000 customers; man continues to strive for the best way to communicate without having to be personal. With the advent of the Zend Framework, we have another weapon in the arsenal, Zend_Mail.
There are many good reasons for programs to send emails. The example we dissect here isn't one of them but trust me, there are some good reasons. Since the early days of the web, cgi has been used to programmatically generate emails based on actions taken. It's a great way to keep administrators abreast of issues with the server or the software. Especially since these days even the simplest phones can receive emails, it's easier than ever to keep up to date. Let's Get StartedThere is no shortage of scripts or classes in PHP that will let you send emails in a variety of ways. With the Zend Framework comes Zend_Mail. Zend_Mail has helper classes like Zend_Mime. (There are others but they are not players in our little drama) It may surprise some of you who are not as versed in the black arts of email as this author but there are multiple ways to transport emails with PHP. The traditional mail() function is the most common but not always the best choice. It's great for dashing of a quick email but lacks the sophistication of talking directly to the SMTP server. Talking directly to the receiving server gives you the advantage of knowing immediately the dispensation of your message. It also lacks the ability to easily handle attachments.
Thankfully, Zend_Mail lets you choose specifically how you want your mail transported. If you don't care, Zend_Mail will make the choice for you. If you do care, it will allow you to choose between the default object oriented interface to the mail() function and the same interface that talks directly to an SMTP server. So let's dive in with some sample code. For those of you with an itchy trigger finger, there's no need to try and copy and paste the different pieces together into a whole, here is the code for your viewing pleasure.
 |
|
 |
|
Tags:
zend framework, zendmail
Tags Help
Tags are keywords associated with a web page that help classifying information. You can find a good explanation here.
To add one or more tags to this page, simply enter them below (separate them with a comma) and hit enter or click on the "Go" button.
|
|
 |
|
 |
|
Index
|