Skip to main content
1 of 2
66h3m3ab
  • 119
  • 1
  • 7

PHP mail templates

I'm working on a webshop (used to be for just one product, expanding it to multiple products and multiple shops hooked up to one backoffice, can't use PrestaShop because of compatibility).
We send 3 kinds of emails, all filled with certain data.

First we send an order notification when someone orders and pays (that's when we see it in the list of orders to be processed), this contains the order details including full list of products and prices.

Then we send another email once we mail the order, this includes pretty much the same as the order notification (except some details it doesn't contain and it has some extras).

We also receive an email when people use the contact form that uses the same styling.

Right now what happens is that the system grabs all the items in the order and creates a string containing the table with the items. This works fine, but it's sloppy. I also have the complete email script (using PHPMailer) copied and pasted to 7 different spots where it is possible that an email will be sent.

I need a better way to do this. I was thinking about writing a wrapper for PHPMailer automatically doing most things, and maybe include a few helper functions to do stuff like the item table, but I'm really not sure how to best go about this. Smarty and other templating engines look too bulky for this.

Is there one 'perfect' way to do this?

66h3m3ab
  • 119
  • 1
  • 7