PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Notification HTML breaks sometimes

  1. I have weird issue with my HTML notifications. Sometimes the HTML breaks or it adds a weird character like "!". This only happens sometimes.
    I have an example here
    The Mobil number is placed right next to "Mobil:". There is an blank space in the word "Emai l" and an exclamation mark is thrown in there.

    Like I said, this only happens sometimes and there is no rule of thumb. I have seen this on Apple Mail and Outlook.

    Does anyone have an idea what could be going wrong?

    I am using the latest version of GravityForms and Auto-Formating is ticked off.

    Thanks
    Vayu

    Posted 12 years ago on Friday September 30, 2011 | Permalink
  2. We have never had this reported before. You would have to try and find a way to replicate the issue in order to do some tests to see what is causing it. If it can't be replicated, it can't be debugged because in order to debug it you need to be able to test while it's happening. It sounds like some sort of server issue.

    Posted 12 years ago on Friday September 30, 2011 | Permalink
  3. @Vayu, what version of Gravity Forms are you using? This issue occurred once before, but it was a long time ago, prior to version 1.3.11:

    http://www.gravityhelp.com/forums/topic/problem-with-image-link-in-notification-emails

    You've been around long enough that maybe you are still running old versions of Gravity Forms and maybe WordPress?

    Posted 12 years ago on Saturday October 1, 2011 | Permalink
  4. Hi, thanks for your replies. :-)

    I did mention that I am running the latest version ( 1.5.3 ).
    I cannot replicate the problem, so it is impossible test for.
    I hope you guys don't mind me throwing a bunch of code ind here, but maybe someone else can see something I am not seeing in the code that generates the html.

    // Table body
    $email_body .= '<tbody>';
    $email_body .= '<tr><td>&nbsp;</td></tr>';
    $email_body .= '<tr style="background: #d7e3ef;"><th colspan="2"><h3 style="padding:0;margin:0;">Ordre info:</h3></th></tr>';
    $email_body .= '<tr style="border-bottom:1px solid #ddd;"><th>Buffet:</th><td>'.$buffet.'</td></tr>';
    if(!empty($starter))			$email_body .= '<tr style="border-bottom:1px solid #ddd;"><th>Forret:</th><td>'.$starter.'</td></tr>';
    if(!empty($desert))				$email_body .= '<tr style="border-bottom:1px solid #ddd;"><th>Desert:</th><td>'.$desert.'</td></tr>';
    if(!empty($bread))				$email_body .= '<tr style="border-bottom:1px solid #ddd;"><th>Brød:</th><td>'.$bread.'</td></tr>';
    $email_body .= '<tr style="border-bottom:1px solid #ddd;"><th>Kuverter:</th><td>'.$seatings.'</td></tr>';
    $email_body .= '<tr style="border-bottom:1px solid #ddd;"><th>Dato:</th><td>'.$date.'</td></tr>';
    $email_body .= '<tr style="border-bottom:1px solid #ddd;"><th>Tid:</th><td>'.$time.'</td></tr>';
    if(!empty($institution))		$email_body .= '<tr style="border-bottom:1px solid #ddd;"><th>Institution:</th><td> '.$institution.'</td></tr>';
    if(!empty($company))			$email_body .= '<tr style="border-bottom:1px solid #ddd;"><th>Firma:</th><td>'.$company.'</td></tr>';
    if(!empty($ean))				$email_body .= '<tr style="border-bottom:1px solid #ddd;"><th>EAN:</th><td>'.$ean.'</td></tr>';
    if($use_dif_address == "Yes")	$email_body .= '<tr><td>&nbsp;</td></tr>';
    if($use_dif_address == "Yes")	$email_body .= '<tr style="background: #d7e3ef;"><th colspan="2"><h3 style="padding:0;margin:0;">Bestillings adresse:</h3></th></tr>';
    if($use_dif_address == "Yes")	$email_body .= '<tr style="border-bottom:1px solid #ddd;"><th>Navn:</th><td>'.$contact_name.'</td></tr>';
    if($use_dif_address == "Yes")	$email_body .= '<tr style="border-bottom:1px solid #ddd;"><th>Adresse:</th><td>'.$contact_address.'</td></tr>';
    if($use_dif_address == "Yes")	$email_body .= '<tr style="border-bottom:1px solid #ddd;"><th>Postnummer & By:</th><td> '.$contact_zip.' '.$contact_city.'</td></tr>';
    if(!empty($phone)) 				$email_body .= '<tr style="border-bottom:1px solid #ddd;"><th>Telefon:</th><td> '.$phone.'</td></tr>';
    $email_body .= '<tr style="border-bottom:1px solid #ddd;"><th>Mobil:</th><td>'.$mobile.'</td></tr> ';
    $email_body .= '<tr style="background: #d7e3ef;"><th colspan="2"><h3 style="padding:0;margin:0;">Pris</h3></th></tr>';
    $email_body .= '<tr style="border-bottom:1px solid #ddd;"><th>Buffet pris:</th><td>Kr. '.$buffet_price.',-</td></tr>';
    $email_body .= '<tr style="border-bottom:1px solid #ddd;"><th>Leveringspris:</th><td>Kr. '.$shippingrate.',-</td></tr>';
    $email_body .= '<tr style="border-bottom:1px solid #ddd;"><th>Pris ialt:</th><td><strong>Kr. '.$total_price.',-</strong></td></tr>';
    $email_body .= '<tr><td>&nbsp;</td></tr>';
    if(!empty($message))			$email_body .= '<tr><th>Kommentar:</th><td><p>'.$message.'</p></td></tr>';
    $email_body .= '</tbody>';
    // End table body
    Posted 12 years ago on Monday October 3, 2011 | Permalink
  5. Can you post the source of an email notification with broken HTML? Maybe we can see where it's getting messed up. Use pastie.org or pastebin.com for long source code. Thanks.

    You might have to use htmlspecialchars to escape the submitted text so it does not foul your layout.

    Posted 12 years ago on Monday October 3, 2011 | Permalink
  6. Hi Chris.

    Thank you for helping out! :-)

    I had no way of seeing the mail as HTML. But I placed the whole email inside htmlspecialchars and was able to see html generated that way. I found that there was table row ending missing one place.
    I then added some htmlspecialchars to the content. It seems as if this fixed the problem.
    I still had some errors in the HTML though, but it didn't seem to show in the email.
    http://pastebin.com/MdDCqJDh
    See line 10, 31, 33, and 60.

    Posted 12 years ago on Wednesday October 5, 2011 | Permalink
  7. Sounds like you have some of it resolved. The exclamation mark thing has been reported a few times, but a long time ago.

    Let's try something. How about inserting a few "\n" into your HTML so it's not all just one long line. In your comment above, after each "< / tr >" try adding a "\n" so it looks like this:

    [php]
    </td></tr>\n

    The problem is you have all your HTML single quoted, and "\n" won't work there, it has to be in double quoted to be interpreted. Try this version http://pastebin.com/MPTMVcP0

    I added an opening <?php tag there so I could see the syntax. You can remove that.

    Posted 12 years ago on Thursday October 6, 2011 | Permalink
  8. Hi Chris.
    I know this is a bit late, but I had not seen that you had replied to my last message from October 5th, because I never got an email about it and I simply forgot to check up on it.

    I have now returned to this thread, as I came across the same issue in another project I am working on.

    I have now tested it and I can tell you that your advice works great! Brilliant, thanks!
    Vayu

    Posted 11 years ago on Thursday July 5, 2012 | Permalink

This topic has been resolved and has been closed to new replies.