SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: PHP newsletter

  1. #1
    SitePoint Zealot
    Join Date
    May 2001
    Location
    UK
    Posts
    184
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP newsletter

    Hi I was just testing my newsletter script when I noticed that it put eveything on one line. So I used \n after each line, however when I received my test mail \n had been replaced, I also noticed that what's had been replaced with what\'s How do I get it so that it does do that?

    I thought the quick fix / for this issue I could put the content into the PHP script that instead of it using $content from the form input? But What that is by no means ideal.

    Also, HTML email would be good

  2. #2
    SitePoint Addict lveale's Avatar
    Join Date
    Jun 2001
    Location
    Dublin
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    stripslashes

    try the php function : stripslashes

    http://www.php.net/manual/en/function.stripslashes.php

  3. #3
    SitePoint Enthusiast RandMan's Avatar
    Join Date
    Mar 2001
    Location
    Crossville, TN USA
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Take a look at this function:
    http://www.php.net/manual/en/function.wordwrap.php
    PHP Code:
    $text "The quick brown fox jumped over the lazy dog.";
    $newtext wordwrap$text20 ); 
    This example would display:

    The quick brown fox
    jumped over the lazy dog.

    This will save you from manually having to enter new lines.

    Most email newsletters are set at between 55-70 characters per line. Just substitute your choice for the 20 in the example above.

  4. #4
    Victory shall be mine tubedogg's Avatar
    Join Date
    Mar 2001
    Location
    Medina, OH
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you are passing data from page to page, PHP will add slashes to it automatically. You will need to use stripslashes right before sending it, as Iveale noted.

    Did your test email after adding \n work?
    Kevin

  5. #5
    SitePoint Zealot
    Join Date
    May 2001
    Location
    UK
    Posts
    184
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys

    tubedogg, \n was replaced by \\n and therefore didn't work.

    OK, almost there! The \n still does not break lines. I actually get \n in the content of the email. However, if you have \n directly in message filed as you know that does break line.

    Stripslashes does what it is meant to.
    However, wordwrap gets confused by my \n it does not break those lines. I assume it thinks that the \n will do that so it is not needed?

    Umm, strange!

    I'm sure there must be plenty of other people who have got round this problem so I will have a look at a few more scripts. If I find anything will let u know.

  6. #6
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah...took a while to find out when writing my mailing list script but here:

    PHP Code:
    $content str_replace("\r\n""\n"$content); 
    Also, for HTML emails, you just add a header with a content type of.....umm.....I can't be bothered to look....

    PHP Code:
    $headersh "Content-Type: text/html;charset=iso-8859-1\n"
    Hope this helps...

    -Peter


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
  •