Jump to:

10848 Posts in 2516 Topics by 1792 members

All other Modules

SilverStripe Forums » All other Modules » Newsletter generates warning

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 732 Views
  • _Vince
    Avatar
    Community Member
    156 Posts

    Newsletter generates warning Link to this post

    Hi, I'm trying to use the Newsletter module and I am running into problems.

    Basically, the email generates the following warning:

    Sun-Java-System-SMTP-Warning: Lines longer than SMTP allows found and truncated.

    the email is being sent from a Windows XP machine. Looking at the source, I can see the HTML text but as a single line.

    Any idea what's wrong? I have tried looking at Mailer.php. wordwrap is set to 120, but lowering the number doesn't seem to be making any difference.

    Any suggestions?

  • _Vince
    Avatar
    Community Member
    156 Posts

    Re: Newsletter generates warning Link to this post

    I suppose the solution is to add "\r" to the "\n" characters?

    But I'm not sure where to do that. Is it in Mailer.php? Email.php? Where?

    Any suggestions?

  • MarcusDalgren
    Avatar
    Community Member
    288 Posts

    Re: Newsletter generates warning Link to this post

    Are you using an Email template?

  • _Vince
    Avatar
    Community Member
    156 Posts

    Re: Newsletter generates warning Link to this post

    Yeah, I am.

    It works fine from a Linux server, but the customer decided to have the site inhouse and it's now on a Windows XP box.

    I think it's some sort of problem with CRLF vs CR, Windows/Linux?

    Things have improved slightly since I started playing with QuotedPrintable_encode() in Mailer.php and adding values to the list, but it's still not quite right.

  • MarcusDalgren
    Avatar
    Community Member
    288 Posts

    Re: Newsletter generates warning Link to this post

    I'm not sure how deep you'd have to go. It's the template parser (SSViewer) that actually parses the template so in a worst case scenario you might have to make your changes there. SSViewer does add the \n only no \r. Hopefully there's something else you can do instead of changing SSViewer but I've never run into the issue myself (probably because I always run on Linux) but do you get the same issue with normal templates on the site? My local dev environment is a windows machine but I still get multi line template output when looking at the source in the browser.

  • _Vince
    Avatar
    Community Member
    156 Posts

    Re: Newsletter generates warning Link to this post

    It's taken me a while to understand the problem, let alone the answer.

    As it looks now:

    Newsletter module worked great on a Linux server.

    Was moved to a Windows XP box.

    Newsletters immediately arrived with a "line too long" error and didn't display. The content was blank, as per the error.

    I added extra stuff to Mailer.php

    function QuotedPrintable_encode($quotprint) {      
          $quotprint = (string) str_replace("\r\n",chr(13).chr(10),$quotprint);
          $quotprint = (string) str_replace("\r\n", chr(13).chr(10),$quotprint);
          $quotprint = (string) preg_replace("~([\x01-\x1F\x3D\x7F-\xFF])~e", "sprintf('=%02X', ord('\\1'))", $quotprint);
          //$quotprint = (string) str_replace('\=0D=0A',"=0D=0A",$quotprint);
          $quotprint = (string) str_replace("=0D=0A","\r\n",$quotprint);
          $quotprint = (string) str_replace("=0A=0D","\r\n",$quotprint);
          $quotprint = (string) str_replace("=0D","\r\n",$quotprint);
          $quotprint = (string) str_replace("=0A","\r\n",$quotprint);
          $quotprint = (string) str_replace("=0C","\r\n",$quotprint);
          $quotprint = (string) str_replace("=09","\r\n",$quotprint);
          $quotprint = (string) str_replace("=20","\r\n",$quotprint);
          $quotprint = (string) str_replace("=3D","=",$quotprint);
          return (string) $quotprint;
    }

    (bit of a scattergun approach)

    Newsletters now arrive displaying almost correctly.

    The remaining problem now is that SOME spaces, every now and then, are removed. As in:

    "We havethe best selection of goods with a great price range so youcan choose the best present"

    I've looked at the HTML code inside TinyMCE and it looks absolutely normal. All the spaces are there.

    Any suggestions as to how to make sure all the spaces appear on the Newsletter?

    Wild guesses, even?

    732 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.