Exclamation Point in HTML Email

后端 未结 4 1673
[愿得一人]
[愿得一人] 2020-12-15 07:02

I am having a hard time formatting a table in an HTML email. There seems to always be one cell that doesn\'t have the background color or weird white spaces.

Here i

相关标签:
4条回答
  • 2020-12-15 07:10

    Remove all CSS styling, lots of email rendering engines fail with it. Use plain old table design.

    Use <font color="black">blah</font> instead of style color, use <table cellpadding="10"> instead of style padding, use bgcolor instead of style background-color.

    Set bgcolor to whole TABLE, not TDs.

    0 讨论(0)
  • 2020-12-15 07:15

    I hate to answer my own question but I did find a resolution to the issue, and hopefully someone can use this solution to get rid of the headaches this causes.

    The issue is being caused by use of the mail() function. When I try to send the email, I have a long string of html code. IN FACT, TOO LONG! When I go past 78 characters a BANG! shows up and then jacks with my html or css. RFC 2822

    The resolution is to change it to base-64 encode the data or add \r\n on my long lines of html code. Either way resolves the issue.

    Thanks for the help everyone!

    0 讨论(0)
  • 2020-12-15 07:25

    Here is a example of how to create a Base64 Encoded Email in:

        <?php 
    
    $html = "<p>The <b>quick</b> <em>brown</em> <u>fox</u> jumped right over the lazy dog.</p><hr />";
    
    $to   = "amit@labnol.org";
    $cc   = "cc@labnol.org";
    $bcc  = "bcc@labnol.org";
    $from = "from@labnol.org";
    
    $subject  = "This is a MIME encoded email";
    $boundary = str_replace(" ", "", date('l jS \of F Y h i s A'));
    $newline  = "\r\n";
    
    $headers = "From: $from$newline".
               "Cc: $cc$newline".
               "Bcc: $bcc$newline".
               "MIME-Version: 1.0$newline".
               "Content-Type: multipart/alternative;".
               "boundary = \"$boundary\"$newline$newline".
               "--$boundary$newline".
               "Content-Type: text/html; charset=ISO-8859-1$newline".
               "Content-Transfer-Encoding: base64$newline$newline";
    
    $headers .= rtrim(chunk_split(base64_encode($html)));
    
    mail($to,$subject,"",$headers);
    
    ?>
    

    I found this code in the following site :

    https://ctrlq.org/code/19840-base64-encoded-email

    Setting up your emails to be Based64 Encoded will remove the random '!' being added to emails.

    0 讨论(0)
  • 2020-12-15 07:31

    Seems there is not a return on the offending cells So try adding height:100% to them so they are fully filled. You could fix this by adjusting this code

    <td style=\"padding:10px;background-color:#113797;color:white;\">
    

    To

    <td style=\"padding:10px;background-color:#113797;color:white;height:100%;\">
    

    This should solve your problem.

    0 讨论(0)
提交回复
热议问题