Mail clients can receive both HTML and text-only emails. Emails formatted in HTML are much more attractive and generally sought after by most clients. However, many users do not accept HTML emails, believing these emails to be more vulnerable to attack. The solution is to send a multi-part email, which includes both text and HTML versions of the message. In such case, people who do accept HTML e-mails will see a pretty version and the rest will see a text-based version. Let’s look at a quick example:
Disclaimer This code sample is for Drupal5. The “drupal_mail” function is different in Drupal6. Please, refer to Drupal documentation for the differences. But the main principle should still work. Caution: In multi-part e-mail syntax every space and caret return counts. It’s very fragile to anything extra or missing, so we highly recommend that you use $multi_body and $params variables EXACTLY the way it is in this sample. Do not indent text for “code formatting”.
Sign up for the Phase2 newsletter for exclusive content and news.