Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

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

Newsletter generates warning


Go to End


6 Posts   1227 Views

Avatar
_Vince

Community Member, 165 Posts

2 November 2010 at 2:27pm

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?

Avatar
_Vince

Community Member, 165 Posts

2 November 2010 at 4:33pm

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?

Avatar
MarcusDalgren

Community Member, 288 Posts

2 November 2010 at 10:30pm

Are you using an Email template?

Avatar
_Vince

Community Member, 165 Posts

2 November 2010 at 11:25pm

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.

Avatar
MarcusDalgren

Community Member, 288 Posts

2 November 2010 at 11:39pm

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.

Avatar
_Vince

Community Member, 165 Posts

9 November 2010 at 9:25am

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?