A Better Way to Determine MIME Types for MIME Email with PHP - Putting the modified “Mailer” class to work
(Page 4 of 4 )
Below I coded a final hands-on example that demonstrates how to use the “Mailer” class, after its original signature has been modified.
Here is the corresponding code sample:
// create a new instance of the 'Mailer' class
$mailer=&new Mailer('alejandro@mydomain.com,'mybuddy@yourdomain.com','Testing mailer class','Hello buddy. I am sending you a couple of fun images.');
// add some attachments
$mailer->addAttachment('file1.jpg');
$mailer->addAttachment('file.jpg');
// send MIME email
$mailer->send();
As you can see, changing the way the “Mailer” class does some of its things doesn’t imply that its API must change too. The above example demonstrates this concept very clearly, since the steps taken to use the class in question are the same steps you learned in the two previous tutorials of the series.
And lastly, here’s my final suggestion: feel free to introduce your own modifications to the pertaining “Mailer” class, not only to extend its functionality, but to improve your background in sending MIME email with PHP.
Final thoughts
In this third episode of the series, I showed you how to improve the business logic of the previous MIME mailer class, specifically when it comes to determining the MIME type of the attached files. As you saw before, this process was performed by creating an additional array of class properties. So you shouldn’t have major problems understanding how it functions.
In the next article, I’m going to continue extending the functionality of this MIME mailer class by providing it with the capacity to send email messages in HTML format.
The article will be insightful, trust me. I hope you don’t miss the upcoming tutorial!
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |