PHP Mail Header and New Lines

Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default PHP Mail Header and New Lines

    I'm using PHP to send out email to users when they submit a form (user
    registration). The email gets sent just fine, but I'd like to be able to
    send HTML emails as well. After consulting php.net, I noted that I have
    to add the correct headers to the email. My problem is that the carriage
    returns and new lines are being parsed as regular characters, so the
    headers are incomplete. Example:

    MIME-Version: 1.0\r\n Content-type: text/html; charset=iso-8859-1

    Where is should instead be:

    MIME-Version: 1.0
    Content-type: text/html; charset=iso-8859-1

    I know the servers are Unix servers, so I've even tried removing the
    Windows \r, but it doesn't seem to help. Anyone know what's wrong and
    why it's not adhering to the new line?

    - Josh
    Josh Johnson Guest

  2. Similar Questions and Discussions

    1. Using PHP to parse mail header
      Hello! I am very new to PHP (or any type of scripting language), and am trying to write a PHP script that will accept email headers posted into a...
    2. manipulate mail header
      Hi! Its me again. Sorry for the last post - it was quite clumsy. In fact, it wasn't really what I need. I have a mail and I want to fake the...
    3. [PHP] Mail Header/Return Receipt
      Disposition-Notification-To: is not a sure bet, since the majority of people ignore the return receipt. The only way you will know if the email...
    4. Mail Header/Return Receipt
      Ok, I have an interesting one here. I'm trying to send an e-mail from Server A, through Server B, and to a recipient using PHP on Server A. Server...
    5. LWP Extra Header Lines
      Hi, Does anyone know how to add extra request header lines with LWP? I've seen this way but thought I'd see if there's a 'better' way: my...
  3. #2

    Default Re: PHP Mail Header and New Lines

    Here's the example code I'm working with:

    function sendEmail() {
    $headers = 'MIME-Version: 1.0\r\n ';
    $headers .= 'Content-type: text/html; charset=iso-8859-1 ';
    $to = $name . ' <' . $address . '>';
    $subject = 'User Registration';
    $message = '<html><body><p>';
    $message .= 'Canned message here';
    $message .= '</p></body></html>';
    mail($to, $subject, $message, $headers);
    }
    Josh Johnson Guest

  4. #3

    Default Re: PHP Mail Header and New Lines

    Josh,

    First, I apologize for being of no help, regarding your question. I'm just
    learning PHP, and have many more quesstions than answers.

    With that in mind, I'm trying to set up forms on my pages to automatically
    e-mail to specified addresses, when the form is submitted to the database.
    It sounds like you've already figured that out. How did you do that?

    Thanks,

    Kerry



    "Josh Johnson" <josh.johnson@nospam.sun.com> wrote in message
    news:d17ssg$26n$1@forums.macromedia.com...
    > I'm using PHP to send out email to users when they submit a form (user
    > registration). The email gets sent just fine, but I'd like to be able to
    > send HTML emails as well. After consulting php.net, I noted that I have to
    > add the correct headers to the email. My problem is that the carriage
    > returns and new lines are being parsed as regular characters, so the
    > headers are incomplete. Example:
    >
    > MIME-Version: 1.0\r\n Content-type: text/html; charset=iso-8859-1
    >
    > Where is should instead be:
    >
    > MIME-Version: 1.0
    > Content-type: text/html; charset=iso-8859-1
    >
    > I know the servers are Unix servers, so I've even tried removing the
    > Windows \r, but it doesn't seem to help. Anyone know what's wrong and why
    > it's not adhering to the new line?
    >
    > - Josh

    Kerry Snow Guest

  5. #4

    Default Re: PHP Mail Header and New Lines

    .oO(Josh Johnson)
    >My problem is that the carriage
    >returns and new lines are being parsed as regular characters, so the
    >headers are incomplete.
    Use double quotes around the string or PHP won't recognize the special
    chars.

    Micha
    Michael Fesser Guest

  6. #5

    Default Re: PHP Mail Header and New Lines

    I've been working more javascript than PHP lately, and had forgotten
    that PHP treats single and double quotes differently. Thanks for the
    reminder!

    - Josh

    Michael Fesser wrote:
    > .oO(Josh Johnson)
    >
    >
    >>My problem is that the carriage
    >>returns and new lines are being parsed as regular characters, so the
    >>headers are incomplete.
    >
    >
    > Use double quotes around the string or PHP won't recognize the special
    > chars.
    >
    > Micha
    Josh Johnson Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139