LineBreaks in plain text email

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
arturpawel
Forum Newbie
Posts: 2
Joined: Wed Mar 25, 2009 9:41 am

LineBreaks in plain text email

Post by arturpawel »

Hi there.

In my code I've got something like this:

Code: Select all

 
define(NL,"\x0D\x0A"); //CRLF
foreach(blah) {
printf("%-30.30s|%-7.7s|%-20.20s|%7.7s|%21.21s%s",__('Blah'),__('Type'),__('Blah'),__('Blah'),__('Blah'),NL);
}
 
And:

Code: Select all

 
$mime = 'text/plain';
$message =new Swift_Message(MailReport::$MailSubject, $body,$mime);
$mailer->send($message, new Swift_Address($options['mailto'], $options['nickname']),
                                        new Swift_Address(MailReport::$MailFromAddr,MailReport::$MailFromName))            
 
But mail comes with linebreaks inside of a line disrupting the whole layout :|
The php mail() function works correct (no linebreaks ).

Is it a bug or do I need to add some options to Swift?
Thanks
Arthur
Hocker
Forum Newbie
Posts: 3
Joined: Wed Mar 25, 2009 10:54 am

Re: LineBreaks in plain text email

Post by Hocker »

It probably has to do with the line length,
Swift Mailer defaults to using 78 characters per line in a message

try something like:

Code: Select all

$message->setMaxLineLength(1000);
here's the reference:
http://swiftmailer.org/docs/message-line-length
arturpawel
Forum Newbie
Posts: 2
Joined: Wed Mar 25, 2009 9:41 am

Re: LineBreaks in plain text email

Post by arturpawel »

Yeap, forgot to tell, I'm using version 3 (symfony :| ).

I didn't found option to set maxLine.
$message->setLineWrap($len); does not work as expected :P

Thank You anyway.
Cheers
Arthur
Post Reply