silvershop / silvershop-core

SilverShop is an e-commerce shopping cart module for the SilverStripe CMS
http://silvershop.github.io
BSD 2-Clause "Simplified" License
113 stars 119 forks source link

Plain text version of shop e-mails are cluttered with HTML and styles #826

Open thomasbnielsen opened 5 months ago

thomasbnielsen commented 5 months ago

All emails sent out from Silvershop are missing plain text versions, or rather they are poorly formatted. The styles and HTML inside the plain version of these e-mails are a red flag for spam filters.

Suggest we make plan text versions of all e-mails and set those like: $email->setPlainTemplate($html_template . 'Plain'); or revisit how we strip HTML and Styles from the HTML version into a plain version.

The solution we did for a project was making an extension for OrderEmailNotifier, for the hook "updateClientEmail"

class OrderEmailNotifierExtension extends DataExtension
{
    public function updateClientEmail(Email $email)
    {
        $order = $email->getData()->Order;

        $html_template = $email->getHTMLTemplate();
        if($html_template == 'SilverShop/Model/Order_ReceiptEmail') {
            $email->setPlainTemplate($html_template . 'Plain');
        }
    }
}