Plain text wrapping/line lengths

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
majiga
Forum Newbie
Posts: 7
Joined: Mon Jun 11, 2007 9:42 am

Plain text wrapping/line lengths

Post by majiga »

Hi everyone,

A question about line lengths on plain text versions of emails sent with swiftmailer. Thus far I don't have any line length stuff sorted out, and so when I send an email to my gmail account and then click "Message text garbled?" to display the plain text version, all the long lines extend far out past the width of my monitor.

Is it best for me to put in some code to wrap lines to 72 (?) characters before I actually transmit them, or is it just best to send the plain text versions with really long lines and then just let the client wrap them for display? (The fact that gmail doesn't do this, makes me think I should be doing the former).

I couldn't even test this in Outlook; how can i get the plain text version to display in Outlook 2003? If I open the email up (double click), and then choose the Format menu; it has the options for Plain Text and HTML greyed out, with a tick next to HTML; which indicates to me that outlook doesnt think there's a plain text version of the email present.

Any ideas?

Thanks heaps!
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Wrap it to 70 characters.
majiga
Forum Newbie
Posts: 7
Joined: Mon Jun 11, 2007 9:42 am

Post by majiga »

is there a recommended way to do this?

I've found this function:

http://www.weberdev.com/get_example-164.html

which looks like it'll do the trick. is there a better way?

cheers
User avatar
Stryks
Forum Regular
Posts: 746
Joined: Wed Jan 14, 2004 5:06 pm

Post by Stryks »

Sorry, cant add much in the way of a solution, but I reading your post, I just had to comment.
I couldn't even test this in Outlook; how can i get the plain text version to display in Outlook 2003? If I open the email up (double click), and then choose the Format menu; it has the options for Plain Text and HTML greyed out, with a tick next to HTML; which indicates to me that outlook doesnt think there's a plain text version of the email present.
Ya know ... I found this too, and it is REALLY frustrating.

Outlook seems to ticks the version you are seeing, and wont let you change whether there is a text component or not.

If you're trying to test your emails for structure and mutipart views, move on up in the world and get yourself Thunderbird.

Source view is easily accessible, includes full headers and it allows switching between HTML and text parts with ease.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

wordwrap()

Plain text emails can't use the <br /> line break. You must use word wrap and wrap to 70 characters with "\r\n" as the break.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Code: Select all

$message->setLineWrap(70);

//and/or

$part->setLineWrap(70);
There are some constants to provide lengths of 70 and 1000 but they're not really useful anyway.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

d11wtq wrote:

Code: Select all

$message->setLineWrap(70);

//and/or

$part->setLineWrap(70);
There are some constants to provide lengths of 70 and 1000 but they're not really useful anyway.
I would assume they use wordwrap? :P
I couldn't find your documentation for line wrapping, so I just use wordwrap manually.
majiga
Forum Newbie
Posts: 7
Joined: Mon Jun 11, 2007 9:42 am

Post by majiga »

d11wtq wrote:

Code: Select all

$part->setLineWrap(70);
That did the job! Thanks heaps!
Post Reply