sheriff Posted April 10, 2007 Share Posted April 10, 2007 Hi all ... I have a php generated page, what is saved as html. I want that html file to be sended as html. The mail is sent, but in normal plain text. I have searched in google, i found some examples, but i don't know what's wrong. Can anyone help me please ! this is the code: <?php // Turn off all error reporting error_reporting(1); // Report all PHP errors (bitwise 63 may be used in PHP 3) error_reporting(E_ALL); // Same as error_reporting(E_ALL); ini_set('error_reporting', E_ALL); // The mailing system $today = date('d-m-Y H:i'); $random_hash = md5(date('r', time())); $headers = "From: [email protected] \r\n"; $headers .= "MIME-Version: 1.0 "; $boundary = uniqid("$random_hash"); $headers .= "Content-Type: multipart/alternative;". "boundary = $boundary\r\n\r\n"; $headers .= "This is a MIME encoded message.\r\n\r\n"; $headers .= "--$boundary\r\n". "Content-Type: text/plain; charset=ISO-8859-2\r\n". "Content-Transfer-Encoding: base64\r\n\r\n"; $headers .= chunk_split(base64_encode(strip_tags($attachment))); $headers .= "--$boundary\r\n". "Content-Type: text/html; charset=ISO-8859-2\r\n". "Content-Transfer-Encoding: base64\r\n\r\n"; $headers .= chunk_split(base64_encode($attachment)); $attachment = chunk_split(file_get_contents("send.html")); $mail_sent = @mail($_POST['to'].", [email protected]" , "Date - " . $today, $_POST['message'] . "<br><br>" . $attachment, $headers); echo $mail_sent ? "<center>Mail sent</center>" : "<center>Mail failed</center>"; ?> Link to comment https://forums.phpfreaks.com/topic/46387-sending-html-mail-form-php/ Share on other sites More sharing options...
trq Posted April 10, 2007 Share Posted April 10, 2007 You might start by removing.... $headers .= "--$boundary\r\n". "Content-Type: text/plain; charset=ISO-8859-2\r\n". "Content-Transfer-Encoding: base64\r\n\r\n"; Link to comment https://forums.phpfreaks.com/topic/46387-sending-html-mail-form-php/#findComment-225614 Share on other sites More sharing options...
sheriff Posted April 10, 2007 Author Share Posted April 10, 2007 ok, I removed, but this didn't resolved the problem is that important ? .. in the html file what i want to send, is no <html><body> tags ... just a table wint some text in. Link to comment https://forums.phpfreaks.com/topic/46387-sending-html-mail-form-php/#findComment-225623 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.