Created
October 17, 2013 19:54
-
-
Save un1ko85/7031166 to your computer and use it in GitHub Desktop.
HTML Emails with wp_mail()
This file contains hidden or 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 | |
function mail_from() { | |
$emailaddress = '[email protected]'; | |
return $emailaddress; | |
} | |
function mail_from_name() { | |
$sendername = "1stWebDesigner.com - Dainis"; | |
return $sendername; | |
} | |
add_filter('wp_mail_from','mail_from'); | |
add_filter('wp_mail_from_name','mail_from_name'); | |
?> | |
<html></span></h2> | |
<pre><head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
</head> | |
<body> | |
<table style="font-family: Verdana,sans-serif; font-size: 11px; color: #374953; width: 600px;"> | |
<tr> | |
<td align="left"><a href="<?php bloginfo('url'); ?>" title="MyBlog"><img src="<?php bloginfo('url'); ?>/logo.png" alt="MyBlog" style="border: none;" ></a></td> | |
</tr> | |
<tr> | |
<td> </td> | |
</tr> | |
<tr> | |
<td align="left">Yo, <?php echo $name; ?>.<br />How are you?</td> | |
</tr> | |
<tr> | |
<td> </td> | |
</tr> | |
<tr> | |
<td>I've recieved your message and we'll answer it soon!</td> | |
</tr> | |
<tr> | |
<td> </td> | |
</tr> | |
<tr> | |
<td align="left" style="background-color: #aeaeae; color:#FFF; font-size: 12px; font-weight: bold; padding: 0.5em 1em;">Original Message</td> | |
</tr> | |
<tr> | |
<td><?php echo $message; ?></td> | |
</tr> | |
<tr> | |
<td> </td> | |
</tr> | |
<tr> | |
<td align="center" style="font-size: 10px; border-top: 1px solid #c10000;"> | |
<p><i>Thank you!</i><br /><b>MyBlog</b> - <br /><?php bloginfo('url'); ?></p> | |
</td> | |
</tr> | |
</table> | |
</body> | |
</html> | |
//And we call this function with our contact form: | |
<?php | |
function contactMail($post) { | |
$attachments = ""; | |
$subject = "[MyBlog] Contact"; | |
$name = $post["name"]; | |
$email = $post["email"]; | |
$message = $post["message"]; | |
ob_start(); | |
include(TEMPLATEPATH . '/_mails/contact.html'); | |
$message = ob_get_contents(); | |
ob_end_clean(); | |
$headers = "From: [email protected]"; | |
$headers .= "Return-Path: [email protected]"; | |
$headers .= "MIME-Version: 1.0"; | |
$headers .= "Content-Type: text/html; charset=UTF-8"; | |
$headers .= "BCC: [email protected]"; | |
//$headers .= "BCC: [email protected]"; | |
wp_mail( $email, $subject, $message, $headers, $attachments ); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment