Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: getting text to line break in an email

by azatoth (Curate)
on Sep 27, 2001 at 12:31 UTC ( [id://115025]=note: print w/replies, xml ) Need Help??


in reply to getting text to line break in an email

\n is the correct operator, so please post your code here, using the "code" tags, so we can help you.

Generally, it's always best to include the offending chunk of code with your question for that straight-off-the-bat response.

Azatoth a.k.a Captain Whiplash

Make Your Die Messages Full of Wisdom!
Get YOUR PerlMonks Stagename here!
Want to speak like a Londoner?

Replies are listed 'Best First'.
Re: Re: getting text to line break in an email
by Anonymous Monk on Sep 27, 2001 at 13:32 UTC
    okay, first I put the text block from a database into a text file (requests.txt) and replace the html break tags with '\n'


    cat $HOME/housekeeping/requests.txt | sed -e 's/<br>/\\n/g' -e s/\&#39 +\;/\'/g > $HOME/housekeeping/requests2.txt


    this gives me a text file containing for example:

    Date : 2001-09-26 10:47:00
    Request No. 107
    Request Title: CHILDREN
    Request : 1. 13 year old twin boys\n2. A boy aged 13 years old standing facing the camera\n3. A girl aged 13 years old standing facing the camera\n4. A girl & a boy aged approx 13 years old standing in front of the Eiffel Tower, Paris\n5. A girl aged approx 11 years old on a beach in Greece(or could be anot her location as long as it is not too exotic)
    Format :
    Deadline : 2001-9-27
    Budget : £85 per pic used
    Name : Louise Edgeworth
    Company : Pearson Education
    Country : United Kingdom
    Telephone : 01279 793472
    Fax : 01279 793472
    Email : edgeworthl@aol.com

    Then I run the perl script and use this code to format the email:

    open(REQUESTS,"/home/picturesea/housekeeping/requests3.txt") || di +e "requests3 file not found"; # Open The Mail Program open(MAIL,"|$mailprog -t"); print MAIL "Bcc: $emails\n"; print MAIL "From: chrisbarton\@postmaster.co.uk (PICTURE SEARCH)\n +"; print MAIL "Subject: PICTURE SEARCH REQUESTS $date\n\n"; print MAIL "If you think you have suitable images, please CONTACT +THE RESEARCHER DIRECT.\n YOU DO NOT NEED TO REPLY TO THIS EMAIL.\n"; print MAIL "$date\n"; print MAIL "-" x 75 . "\n"; while ($requests = <REQUESTS>) { print MAIL "$requests"; } close(REQUESTS);


    this all works fine and the email is formatted fine, except the request text comes out:

    Request : 1. 13 year old twin boys\n2. A boy aged 13 years old standing facing the camera\n3. A girl aged 13 years old standing facing the camera\n4. A girl & a boy aged approx 13 years old standing in front of the Eiffel Tower, Paris\n5. A girl aged approx 11 years old on a beach in Greece(or could be anot her location as long as it is not too exotic)

    when what I want is:

    Request : 1. 13 year old twin boys
    2. A boy aged 13 years old standing facing the camera
    3. A girl aged 13 years old standing facing the camera
    4. A girl & a boy aged approx 13 years old standing in front of the Eiffel Tower, Paris
    5. A girl aged approx 11 years old on a beach in Greece(or could be another location as long as it is not too exotic

    ie the '\n's don't get translated as line breaks - any idea why this is?

      The problem comes from the sed command. As I'm no sed expert give perl a try:

      perl -pe "s/<br>/\n/g; s/\&#39;/'/g;"

      alex pleiner <alex@zeitform.de>
      zeitform Internet Dienste

      Guys, It was very difficult to figure how we can break the line text email. I have found a very simple solution just "break the line in your code" and it will do the same in the email as well. eg: I have done this in PHP ------------------------ message ="Hello World Now this is my next line message"; Message .= "Dear".$var.", again this next lien message" --------------------------- Thats it and it works fine with me.. Cheers, Azim

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://115025]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-03-29 08:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found