Professional Web Applications Themes

PHP Mail Header and New Lines - Dreamweaver AppDev

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 pd as regular characters, so the headers are incomplete. Example: MIME-Version: 1.0\r\n Content-type: text/html; cht=iso-8859-1 Where is should instead be: MIME-Version: 1.0 Content-type: text/html; cht=iso-8859-1 I know the servers are Unix servers, so I've even tried removing the ...

  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 pd as regular characters, so the
    headers are incomplete. Example:

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

    Where is should instead be:

    MIME-Version: 1.0
    Content-type: text/html; cht=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. #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; cht=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

  3. #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.johnsonnospam.sun.com> wrote in message
    news:d17ssg$26n$1forums.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 pd as regular characters, so the
    > headers are incomplete. Example:
    >
    > MIME-Version: 1.0\r\n Content-type: text/html; cht=iso-8859-1
    >
    > Where is should instead be:
    >
    > MIME-Version: 1.0
    > Content-type: text/html; cht=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

  4. #4

    Default Re: PHP Mail Header and New Lines

    .oO(Josh Johnson)
    >My problem is that the carriage
    >returns and new lines are being pd 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

  5. #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 pd 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

Similar Threads

  1. Using PHP to p mail header
    By Faisal Humayun in forum PHP Development
    Replies: 3
    Last Post: September 30th, 03:22 AM
  2. manipulate mail header
    By Klaus Linzner in forum PHP Development
    Replies: 1
    Last Post: August 6th, 03:02 PM
  3. [PHP] Mail Header/Return Receipt
    By Ralph Guzman in forum PHP Development
    Replies: 0
    Last Post: July 8th, 07:01 PM
  4. Mail Header/Return Receipt
    By Brian S. Drexler in forum PHP Development
    Replies: 0
    Last Post: July 8th, 04:58 PM
  5. LWP Extra Header Lines
    By Robert in forum PERL Miscellaneous
    Replies: 1
    Last Post: June 24th, 08:58 PM

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
  •  

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