By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,751 Members | 1,158 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,751 IT Pros & Developers. It's quick & easy.

Sending Plain Text Email

P: n/a
Hi All - I have created a survey and I would like the results of the
survey to be emailed the boss in *plain text*.

Can someone PLEASE take a look and tell me why carriage returns are
not being inserted after each $body ? The email comes out as one big
line.

THANK YOU! Sylvie.

include('Mail.php');
include('Mail/mime.php');
$body .= "Are you aware that SCC has a TDC?\n";
$body .= "$_POST[one]\n";
$body .= "Do you know that our resources are available to clients
outside of SCC on an appointment basis?\n";
$body .= "$_POST[three]\n";
$body .= "Do you have occasion to reference the Virtual
Library?<br>\n";
$body .= "$_POST[four]\n";
$body .= "Do you require access collections other than those
available?\n";
$body .= "$_POST[fivea]\n";
$body .= "If so, please indicate which collections\n";
$body .= "$collection\n";
$body .= "Comments\n";
$body .= "$_POST[comments]\n";

$crlf = "\r\n";
$hdrs['From'] = 'a********@home.ca';
$hdrs['To'] = 't******@home.ca';
$hdrs['Subject'] = "TDC Survey for $_POST[year]";
$mime = new Mail_mime($crlf);
$mime->setTXTBody($body);
$body = $mime->get();
$hdrs = $mime->headers($hdrs);
$mail =& Mail::factory('mail');
$mail->send('t******@home.ca', $hdrs, $body);
Jul 16 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Sylvie Stone wrote:
Can someone PLEASE take a look and tell me why carriage returns are
not being inserted after each $body ? The email comes out as one big
line.

This is a complete guess, but perhaps your boss' Windows email client is not
properly translating \n to \r\n. Try an explicite \r\n and see what
happens. A simpler way to do that, instead of doing $body .= "...\r\n" a
bunch of times is:

$body = array();
$body[] = "....";
$body[] = ".....";

$body = join ( "\r\n", $body );
--
----- stephan beal
Registered Linux User #71917 http://counter.li.org
I speak for myself, not my employer. Contents may
be hot. Slippery when wet. Reading disclaimers makes
you go blind. Writing them is worse. You have been Warned.

Jul 16 '05 #2

P: n/a
"stephan beal" <st*****@wanderinghorse.net> wrote in message
news:bg**********@ork.noris.net...
Sylvie Stone wrote:
Can someone PLEASE take a look and tell me why carriage returns are
not being inserted after each $body ? The email comes out as one big
line.



if you use phpmailer, you can use altbody to create a text only message
Jul 16 '05 #3

P: n/a
We had the same problem with MS Outlook. It simply decided it makes the
text nicer and joined the lines. It showed a hint that some line break
were removed, but we have overlooked it and spent some long minutes
playing with \n and \r.

Ondrej

Sylvie Stone wrote:
Hi All - I have created a survey and I would like the results of the
survey to be emailed the boss in *plain text*.

Can someone PLEASE take a look and tell me why carriage returns are
not being inserted after each $body ? The email comes out as one big
line.

THANK YOU! Sylvie.

include('Mail.php');
include('Mail/mime.php');
$body .= "Are you aware that SCC has a TDC?\n";
$body .= "$_POST[one]\n";
$body .= "Do you know that our resources are available to clients
outside of SCC on an appointment basis?\n";
$body .= "$_POST[three]\n";
$body .= "Do you have occasion to reference the Virtual
Library?<br>\n";
$body .= "$_POST[four]\n";
$body .= "Do you require access collections other than those
available?\n";
$body .= "$_POST[fivea]\n";
$body .= "If so, please indicate which collections\n";
$body .= "$collection\n";
$body .= "Comments\n";
$body .= "$_POST[comments]\n";

$crlf = "\r\n";
$hdrs['From'] = 'a********@home.ca';
$hdrs['To'] = 't******@home.ca';
$hdrs['Subject'] = "TDC Survey for $_POST[year]";
$mime = new Mail_mime($crlf);
$mime->setTXTBody($body);
$body = $mime->get();
$hdrs = $mime->headers($hdrs);
$mail =& Mail::factory('mail');
$mail->send('t******@home.ca', $hdrs, $body);


Jul 16 '05 #4

P: n/a
"Sylvie Stone" <sy*********@canada.com> wrote in message
news:18**************************@posting.google.c om...

Can someone PLEASE take a look and tell me why carriage returns are
not being inserted after each $body ? The email comes out as one big
line.
<snip>
$body .= "Do you have occasion to reference the Virtual
Library?<br>\n";


If the email comes out as one big line it is because you are lacking line
breaks <br>, which are not the same as new-line (\n). The only place you seem
to have a line break is on the single line quoted above. The new-line
character creates a line break in your resultant source code...not the HTML
output.

Try EITHER:
a) Changing each instance of \n to <br>\n
b) Running the output through nl2br()

HTH!
Jul 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.