May 21, 2007

Easy professional emails

I had a task to send some emails from the site scripts in the HTML format, while other emails should be kept in the plain text.
A big deal - what's difficult in sending emails? Nothing, actually.

I had a class in PHP that used Smarty template to fetch letter body with subject and send it either as HTML or in plain text using the 3rd party PHP library.
I rewrote the wrapper and made it usable for all kinds of tasks I have in my web practice.
This are the registration-confirmation-congradulations, invitations, monthly newsletters and notifications.

Technically, it requires sending a relatively small amount of letters from a PHP script with the content created from a template. The template has to be editable by the non-programmers
(to let a customer do it himself).
The goal of rewriting the script is to forget the endless options I had to code for sending emails. Just make it simple and do the work, but if anything beyond is required - the full power of both packages is available.

Yesterday I wrote samples of usage for my script, compiled it in a working package and published it on

References to the packeges used.
One is the "MIME E-mail message" library by Manuel Lemos. It allows sending emails from a PHP script with attachments, in plain text, HTML-formatted, with images, with non-latin characters, bulk-sending, etc ... I just can't think out what it does not allow about sending emails.
Another is the Smarty template engine I use in all sites I do. It is convenient to prepare the email body and subject with the same template engine as used for generating pages output.

1 comment:

Kris said...

Thank you Grek.

I'm sure more people are using it than are posting comments :-).

It exactly what I was looking for.