SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    Join Date
    Aug 2002
    Posts
    168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Plain text email from MySQL

    Hey Folks

    I am just wondering about a problem I am encountering when sending plain text emails from MySQL. I am using a textarea to insert text into MySQL which then gets sent as a newsletter via a cron job, nothing too special here.

    It actually works fine except that users with MS Outlook get double breaks in the text. When you export the text to SQL via PhpMyAdmin you can see that the line breaks come out with '\r\n' so it would appear as though Outlook renders both the return and the new line as an individual line break.

    Outlook Express, and Hotmail render it fine.

    So am wondering, does anyone have a way that I can get Outlook to render just the one line break?

    Thanks in advance.

  2. #2
    SitePoint Member
    Join Date
    Feb 2004
    Location
    Earth
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is the code:

    mail("to-address@hotmail.com", "Subject", "body", "From:webmaster@hotmail.com"\r\nReply-to:admin@host.com");

    This is the code and it works fine. Does your ccomputer have a firus? virus

  3. #3
    SitePoint Zealot
    Join Date
    Aug 2002
    Posts
    168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    hmmm

    um, I'm not sure this actually relates to the question.

    Perhaps I should clarify. I am not wondering about how to send the email, that is fine. It is that the body of the email has two line breaks in MS Outlook. The body text is inserted in MySQL through a form from a textarea field. The MySQL data type is "mediumtext".

    Any help is greatly appreciated.

  4. #4

    Join Date
    Oct 2003
    Location
    €uroLand
    Posts
    1,340
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Weird, I just tried the following code
    PHP Code:
    <?
        $msg
    ="Hello\r\nWorld!";
        
    mail('my@email.address''subject'$msg'From: me');
    ?>
    and it arrived as expected in Outlook 2000
    Hello
    World!
    Check whether the text in the database is really properly set.

  5. #5
    SitePoint Zealot
    Join Date
    Aug 2002
    Posts
    168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Ok

    Hey dr...

    Thanks for doing that, much appreciated. Unfortunately it seems as though building up a string in a PHP script works fine. I'd be interested to see what happens to you if you where getting the text out of MySQL. As I said the data type I am using is a mediumtext. A typical entry might look like....

    Code:
    Hello.
     
    Welcome to another newsletter. I this edition you'll learn about...
     
    1. Point one.
    2. Point two
     
    Thanks for reading.
    If you could try that I would appreciate it very much.

  6. #6

    Join Date
    Oct 2003
    Location
    €uroLand
    Posts
    1,340
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you post the code which sets the message's variable?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •