Skip to content

Instantly share code, notes, and snippets.

@un1ko85
Created October 17, 2013 19:54
Show Gist options
  • Save un1ko85/7031166 to your computer and use it in GitHub Desktop.
Save un1ko85/7031166 to your computer and use it in GitHub Desktop.
HTML Emails with wp_mail()
<?php
function mail_from() {
$emailaddress = 'contact@1stwebdesigner.com';
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>&nbsp;</td>
</tr>
<tr>
<td align="left">Yo, <?php echo $name; ?>.<br />How are you?</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>I've recieved your message and we'll answer it soon!</td>
</tr>
<tr>
<td>&nbsp;</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>&nbsp;</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: me@myblog.com";
$headers .= "Return-Path: me@myblog.com";
$headers .= "MIME-Version: 1.0";
$headers .= "Content-Type: text/html; charset=UTF-8";
$headers .= "BCC: thisIsMe@gmail.com";
//$headers .= "BCC: rochesterj@gmail.com";
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