Created
January 10, 2014 05:05
-
-
Save BastinRobin/8347296 to your computer and use it in GitHub Desktop.
PHP Mail Snippet [Table View]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Compose the mail | |
$to = "imail@example.co.uk"; | |
$subject = "Enquiry from Example"; | |
$headers = "From: " . strip_tags($_POST['email']) . "\r\n"; | |
$headers .= "Reply-To: ". strip_tags($_POST['email']) . "\r\n"; | |
$headers .= "CC: email@gmail.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 .= '<img src="http://google.com/logo.png" alt="Website Change Request" />'; | |
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">'; | |
$message .= "<tr style='background: #eee;'><td><strong>Name:</strong> </td><td>" . strip_tags($_POST['name']) . "</td></tr>"; | |
$message .= "<tr><td><strong>Email:</strong> </td><td>" . strip_tags($_POST['email']) . "</td></tr>"; | |
$message .= "<tr><td><strong>Contact:</strong> </td><td>" . strip_tags($_POST['contact']) . "</td></tr>"; | |
$message .= "<tr><td><strong>Address:</strong> </td><td>" . strip_tags($_POST['address']) . "</td></tr>"; | |
$message .= "<tr><td><strong>Comment:</strong> </td><td>" . strip_tags($_POST['comment']) . "</td></tr>"; | |
$message .= "</table>"; | |
$message .= "</body></html>"; | |
if(mail($to, $subject, $message, $headers)) { | |
header( 'Location: http://www.example.com' ) ; | |
} else { | |
echo "Failed to send"; | |
}; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment