Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Unintended line breaks in text being emailed.

 
   Database Help (Home) -> PHP RSS
Next:  SQL Server 2008 Express - Analysis Services suppo..  
Author Message
Mechphisto

External


Since: Dec 02, 2008
Posts: 18



(Msg. 1) Posted: Mon Mar 02, 2009 11:19 am
Post subject: Unintended line breaks in text being emailed.
Archived from groups: comp>lang>php (more info?)

I've this problem where I need to put a list of form text field
results into a single line (for a pipe-separated text file), and
emailed to me...but when I get the e-mail, the single line is broken
into three lines with some duplicate info at the start of each line.
The line breaks happen where there's a space in the text...but not
every space creates a line break.

For example:
154|Wal-Mart |12345|3/8/2009|3/8/2009|1:00 PM|3:00 PM|2100 N. Main
St.||Springfield|XZ|12345|Mike Smith|123-555-1234|mike@foo.com|538 -
Old Mill Trails|1

ends up looking like this in the email:

154|Wal-Mart |12345|3/8/2009|3/8/2009|1:00 PM|3:00 PM|2100 N.
154|Main St.||Springfield|XZ|12345|Mike
154|Smith|123-555-1234|mike@foo.com|538 - Old Mill Trails|1

See, duplicate "154|" get stuck at the beginning of each new line.

The PHP side is:
[...]
Add code:\n
154|$locname|".$_POST['frm_troop']."|".$start_date."|".$end_date."|".
$start_time."|".$end_time."|$locadd1|".$_POST['frm_loc_add2']."|".
$_POST['frm_loc_city']."|".$_POST['frm_loc_state']."|".$_POST
['frm_loc_zip']."|".$_POST['frm_name']."|".$_POST
['frm_contactphone']."|".$_POST['frm_email']."|".$_POST['frm_su']."|1
\n\n";

(There's a mix of inline strings, breaks with strings, and _POSTs
because I've been trying different things to fix it, and all methods
produce the same result.)

Any ideas? I'd appreciate it!
Thanks,
Liam

 >> Stay informed about: Unintended line breaks in text being emailed. 
Back to top
Login to vote
Richard

External


Since: Jan 15, 2008
Posts: 49



(Msg. 2) Posted: Mon Mar 02, 2009 7:29 pm
Post subject: Re: Unintended line breaks in text being emailed. [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Mechphisto" wrote in message

> I've this problem where I need to put a list of form text field
> results into a single line (for a pipe-separated text file), and
> emailed to me...but when I get the e-mail, the single line is broken
> into three lines with some duplicate info at the start of each line.
> The line breaks happen where there's a space in the text...but not
> every space creates a line break.
>
> For example:
> 154|Wal-Mart |12345|3/8/2009|3/8/2009|1:00 PM|3:00 PM|2100 N. Main
> St.||Springfield|XZ|12345|Mike Smith|123-555-1234|mike@foo.com|538 -
> Old Mill Trails|1
>
> ends up looking like this in the email:
>
> 154|Wal-Mart |12345|3/8/2009|3/8/2009|1:00 PM|3:00 PM|2100 N.
> 154|Main St.||Springfield|XZ|12345|Mike
> 154|Smith|123-555-1234|mike@foo.com|538 - Old Mill Trails|1
>
> See, duplicate "154|" get stuck at the beginning of each new line.
>
> The PHP side is:
> [...]
> Add code:\n
> 154|$locname|".$_POST['frm_troop']."|".$start_date."|".$end_date."|".
> $start_time."|".$end_time."|$locadd1|".$_POST['frm_loc_add2']."|".
> $_POST['frm_loc_city']."|".$_POST['frm_loc_state']."|".$_POST
> ['frm_loc_zip']."|".$_POST['frm_name']."|".$_POST
> ['frm_contactphone']."|".$_POST['frm_email']."|".$_POST['frm_su']."|1
> \n\n";
>
> (There's a mix of inline strings, breaks with strings, and _POSTs
> because I've been trying different things to fix it, and all methods
> produce the same result.)
>
> Any ideas? I'd appreciate it!
> Thanks,
> Liam

Hi,
there is a maximum line length for emails.

Try a transfer encoding, or send as attachment.

R.

 >> Stay informed about: Unintended line breaks in text being emailed. 
Back to top
Login to vote
Mechphisto

External


Since: Dec 02, 2008
Posts: 18



(Msg. 3) Posted: Tue Mar 03, 2009 7:12 am
Post subject: Re: Unintended line breaks in text being emailed. [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Mar 3, 2:17 am, "Álvaro G. Vicario"
wrote:
> Mechphisto escribió:
>
> > I've this problem where I need to put a list of form text field
> > results into a single line (for a pipe-separated text file), and
> > emailed to me...but when I get the e-mail, the single line is broken
> > into three lines with some duplicate info at the start of each line.
> > The line breaks happen where there's a space in the text...but not
> > every space creates a line break.
>
> Most e-mail clients wrap long lines when *displaying* them on screen,
> make sure that's not the only issue.
>
> Whatever, the SMTP specs specify a maximum line length so plain text
> mail parts are likely to be wrapped. You have to use base64 or a similar
> encoding with the appropriate headers, e.g.:
>
> Content-Type: text/plain; charset=ISO-8859-1
> Content-transfer-encoding: base64
>
> See:
>
> http://es.php.net/manual/en/function.base64-encode.php
>
Ah! That makes sense.
I tried the base64, and yeah, it encodes the text into human
unreadable code. I m sure if I wrote a script where I plugged it in to
decode64 I could read the e-mail. But that seems like a hassle.
I guess what I'll do is just break the line up into multiple lines in
the e-mail, then when I receive them, I'll just copy-n-paste each
segment into one line. It's a tiny hassle, but better than dealing
with the way it was munging up before.
Thanks for replying!
Liam
 >> Stay informed about: Unintended line breaks in text being emailed. 
Back to top
Login to vote
Álvaro_G._Vicario

External


Since: Apr 11, 2008
Posts: 1021



(Msg. 4) Posted: Tue Mar 03, 2009 9:17 am
Post subject: Re: Unintended line breaks in text being emailed. [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Mechphisto escribió:
> I've this problem where I need to put a list of form text field
> results into a single line (for a pipe-separated text file), and
> emailed to me...but when I get the e-mail, the single line is broken
> into three lines with some duplicate info at the start of each line.
> The line breaks happen where there's a space in the text...but not
> every space creates a line break.

Most e-mail clients wrap long lines when *displaying* them on screen,
make sure that's not the only issue.

Whatever, the SMTP specs specify a maximum line length so plain text
mail parts are likely to be wrapped. You have to use base64 or a similar
encoding with the appropriate headers, e.g.:

Content-Type: text/plain; charset=ISO-8859-1
Content-transfer-encoding: base64


See:

http://es.php.net/manual/en/function.base64-encode.php




--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
 >> Stay informed about: Unintended line breaks in text being emailed. 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
highlight_file() strange line breaks - Hi, Taking a closer look to highlight_file() lastly, I found out that its line break policy was a bit.. strange. <?php # highlight_file() line breaks test $f = fopen('highlight_file_test', 'w'); fwrite($f, highlight_file(__FILE__, true)); fclose($f)...

Adding line breaks to a variable dynamically - OK - here is what I want to do - but I am lost how to do it. I have a variable $mystring = "one two three four five six seven eight nine" This variable $mystring can be 4 words long or it could be 50 words long it is totally variable. What ...

will no line breaks in xml file cause a problem ? - I am fetching various xml documents like this $merch = substr($key,1); $feed = file_get_contents($_POST['data_url'.$merch]); $fp = fopen("./feeds/feed".$merch.".txt","w+"); fwrite ($fp,$feed); fclose ($fp); and the...

Append text at specific line #? - Hi, If I'm using fwrite to append text to a file, is it possible to set the pointer to a specific line # at which to insert the text, rather than the beginning or end of the file? Thanks.

how to get a line of text as an array without white space? - I'm suppose to track FTP uploads to the server. I've got a cron script, written in PHP, that runs every 5 minutes and which does the command lsof | grep vsftpd This gives me a big file that has data like this in it: vsftpd 12316 lawrence cwd ...
   Database Help (Home) -> PHP All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]