class EmailService {

    String compressHtmlSpaces(String html) {
        // Very basic, but we go from 100 kB down to 60 kB:
        // enough to go below the 102 kB GMail clipping:
        // https://emailmonks.com/blog/email-design/avoid-gmail-clipping/
        html = html.replace("\r\n", "\n");
        html = replaceAll(html, "  ", " ");
        html = replaceAll(html, "\n ", "\n");
        html = replaceAll(html, "\n\n", "\n");
        // IMPORTANT: keep order!
        return html;
    }

}