Sending HTML composite email in PHP using objects!

Photo of an American MailboxHave you ever tried to send HTML email using PHP? Sending plaintext email is quite straight forward and easy, and if you have the energy to write your own functions, sending HTML email can be pretty simple too. Half the problem is writing functions that can be ported around to different projects quickly and easily.

PHP Objects made this much easier to do, and since then I’ve been swapping objects in and out of various different parts of the code, and across different applications. I realised the other day that the one I make the most use of is my mail message object. So I thought I would open it up in the event that you also found it useful!It is really simple and lightweight – which means that it works, but it doesn’t offer hundreds of functions like some of the really sophisticated packages out there.

It supports sending plaintext only, or HTML with a plaintext component. I haven’t yet added attachment functionality, because I try to avoid sending attachments by email. If you’re curious as to why – well attachments can clog up inboxes (especially for those on slower connections), and also because it is difficult to track who opens your attachments. If you send dynamic hyperlinks along with your message, that point to the location of the downloadable files, then at least you can track who is actually accessing them!

If you want an object that dynamically supports attachments as well, then let me know, and I’ll upgrade this object so that you can do that.

In relation to email, another common problem is the inclusion of far too much email message content in the actual HTML file – I’ve found that a lot of my code, and those from other developers, contained message templates within the body of the code (much like you’ll see in the example file in the attached download). So I’ve also knocked together a message template manager that can be used with this object – I’ll release that shortly too.

In the meantime however, I have included two files in the ZIP file for download, and one of them is an example that guides you through how to make messages using the object. It’s licensed under GPL, so you can download it and use it in your projects – if you do, I ask that you link back and let me know how you’re using it!

I request that you don’t host this ZIP for download on your servers, as I will update the object with enhancements that people send back, or bug fixes if anybody finds them!

Download the VenueMirror Mail Object.

Share on Facebook

Tags: , , , , ,

2 Responses to “Sending HTML composite email in PHP using objects!”

  1. Tweets that mention Sending HTML composite email in PHP using objects! -- Topsy.com says:

    [...] This post was mentioned on Twitter by Kaiesh, VenueMirror.com. VenueMirror.com said: Sending HTML composite #email in #PHP using #objects! http://goo.gl/fb/5jUOg #development #code #mail [...]

  2. alicia key says:

    This is a good post, I stumbled across your story while looking for free downloads. Thanks for sharing, I’ll be sure to return regularly.

Leave a Reply