Payament
Free Photos
WordPress Themes

PHP Mailer with HTML body

<?php if(!$_POST) header("Location: http://...com"); // Set your url here $to = 'info@...com'; // Who is getting the emails? $subject = 'Your subject'; $headers = "From: " . strip_tags($_POST['email']) . "\r\n"; $headers .= "Reply-To: ". strip_tags($_POST['email']) . "\r\n"; // $headers .= "CC: susan@example.com\r\n"; // Uncomment if you want to CC $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $message = '<html><body>'; $message .= '<img src="" alt="">'; $message .= '<table rules="all" style="border-color: #666;" cellpadding="10">'; $message .= "<tr><td><strong>Name:</strong> </td><td>" . strip_tags($_POST['name']) . "</td></tr>"; $message .= "<tr><td><strong>Company:</strong> </td><td>" . strip_tags($_POST['company']) . "</td></tr>"; $message .= "<tr><td><strong>Message:</strong> </td><td>" . htmlentities($_POST['message']) . "</td></tr>"; $message .= "</table>"; $message .= '</body></html>'; if(mail($to, $subject, $message, $headers)) { header("Location: http://....com/thanks.html"); // If ok what url do we show? } else { echo "Something went wrong. If the error persists please let us know: info@....com"; // If not.. die(); }
Easily send contact forms or any other kind of POST info as an email with HTML content.

1 Response

very cool!

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.