Jump to content

Sending html mail form php


sheriff

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.