0

My goal is to apply a standard, branded layout template to all emails when sending (on the server, not the client). I have been googling this topic and not found any resources specifically addressing this issue. The following is the flow I am envisioning:

  1. Email is initiated from client via SMTP.
  2. EXIM server manipulates the content of the email and applies the HTML layout.
  3. EXIM then sends the email on to where it needs to go.

Step #2 is what I'm trying to figure out. Maybe this needs to be down outside of EXIM in something like PROCMAIL?

I have no experience with this, have just started learning. Any help is greatly appreciated!

2 Answers2

0

Exim, like Postfix, Sendmail, qmail, and others, are Mail Transfer Agents (MTA) which facilitate the transfer of messages between systems. You should not modify message bodies, however if you still want to do this, the MTA is not where it should be done.

If your requirement is to modify the content sent from a conventional email client (Outlook, Thunderbird, Apple Mail) consider using a transport filter, described in the Exim wiki; however, you should be aware that if you modify content like this, you may make unintentional changes to the message.

Will you have some control over the content sent from the client? This is important if the client sends plain text, or HTML mail. Perhaps you could describe more about the specific application to help decide what type of template system you could use.

AndrewNimmo
  • 367
  • 1
  • 7
  • Thanks for trying to help ... I worked on this last week implementing a process and spent this week testing it and fine-tuning HTML manipulation aspects. I posted my answer here. – mike.bronner May 01 '20 at 18:47
-1

With some help I have identified a solution:

  1. Capture all incoming email via transport condition and run it through a bash script.
  2. The bash script then saves the email to a temp folder.
  3. The bash script then triggers a PHP script (because that's what I'm most comfortable with, you could use any scripting language that can manipulate MIME emails.
  4. The PHP script parses the MIME email into its component parts using a PHP package.
  5. It then manipulates both the text and html version of the email as desired.
  6. Using another package I recompose the parts into a new email with a custom header, and send it.
  7. A dedicated transport that triggers if the custom header is set then send the email outbound to Postmark, or any other SMTP account you would like to use.