Failed to send HTML mails using PHP mail() -
strange things happening me. i'm trying send html mail, using php mail() function, no luck here. when copy/paste piece of code literally, doesn't work. doing wrong? here piece of code use:
$message = "<html><body>"; $message .= "<table rules='all' style='border-color: #666;' cellpadding='10'>"; $message .= "<tr style='background: #eee;'><td><strong>name:</strong> </td></tr>"; $message .= "<tr><td><strong>email:</strong> </td></tr>"; $message .= "</table>"; $message .= "</body></html>"; $to = 'me@gmail.com'; $subject = 'website change reqest'; $headers = "from: " . $email . "\r\n"; $headers .= "reply-to: ". $email . "\r\n"; $headers .= "mime-version: 1.0\r\n"; $headers .= "content-type: text/html; charset=iso-8859-1\r\n"; if (mail($to, $subject, $message, $headers)) { echo 'your message has been sent.'; } else { echo 'there problem sending email.'; } and e-mail looks like...:
reply-to: me@gmail.com mime-version: 1.0 content-type: text/html; charset=iso-8859-1 message-id: <20110703234551.a9d6153dab@apache10.hostbasket.com> date: mon, 4 jul 2011 01:45:51 +0200 (cest) <html><body><table rules="all" style="border-color: #666;" cellpadding="10"><tr style='background: #eee;'><td><strong>name:</strong> </td></tr><tr><td><strong>email:</strong> </td></tr><tr><td><strong>type of change:</strong> </td></tr><tr><td><strong>urgency:</strong> </td></tr><tr><td><strong>url change (main):</strong> </td></tr><tr><td><strong>new content:</strong> </td></tr></table></body></html> what do wrong?
we can't see variable $email set, i'm guessing there might line break @ end of $email variable. have effect of putting in 2 linebreaks after from: header , before reply-to: , signals start of body of message , completion of headers.
try:
$email = trim($email); before constructing message. since there appears line break after reply-to header well, case stronger break in $email.
update
also try changing linebreaks php's native format on system code run. done replacing \r\n php_eol
$headers = "from: " . $email . php_eol; $headers .= "reply-to: ". $email . php_eol; $headers .= "mime-version: 1.0" . php_eol; $headers .= "content-type: text/html; charset=iso-8859-1" . php_eol;
Comments
Post a Comment