Abadis Abadis - 8 months ago 33
PHP Question

Send HTML in email via PHP?

How can I send a HTML format email with pictures using PHP?
I want to have a page with some settings and a HTML output which is sent via email to an address. What should I do?
The main problem is to attach files.how can i do that?


It is pretty simple, leave the images on the server and send the PHP + CSS to them...

$to = 'bob@example.com';

$subject = 'Website Change Reqest';

$headers = "From: " . strip_tags($_POST['req-email']) . "\r\n";
$headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "\r\n";
$headers .= "CC: susan@example.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";

$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

$message = '<html><body>';
$message .= '<h1>Hello, World!</h1>';
$message .= '</body></html>';

mail($to, $subject, $message, $headers);

It is this line that tells the mailer and the recipient that the email contains (hopefully) well formed HTML that it will need to interpret:

$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

Here is the link I got the info.. (link...)

You will need security though...