
Property changes on: wp-includes\email_templates
___________________________________________________________________
Added: bugtraq:number
   + true

Index: wp-includes/email_templates/email-comment-notify.php
===================================================================
--- wp-includes/email_templates/email-comment-notify.php	(revision 0)
+++ wp-includes/email_templates/email-comment-notify.php	(revision 0)
@@ -0,0 +1,53 @@
+<?php 
+			if ( 'comment' == $comment_type ) { 
+            $html_message .= '<table style="margin-top:1em;">
+            	<tr>
+                	<td style="width:75px;" width="75" rowspan="3">
+                    <div style="width:60px;height:60px;background-color: #ffffff; border: 1px solid #ececec; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px;">
+                 		<a style="margin:5px 0 0 5px;display:block;">' . get_avatar( $comment->comment_author_email, 50 ) . '</a>
+                    </div></td>
+                    <td height="12" style="height:12px;padding-top:2px;">Author: <strong>' . $comment->comment_author . '</strong></td>
+                </tr>
+                <tr><td style="font-size:10px;padding-left:45px;vertical-align:top">IP: ' . $comment->comment_author_IP; 
+			if ( $comment->comment_author_domain ) { $html_message .= ', <a href="#" style="color:#21759b;text-decoration:none;">' . $comment->comment_author_domain . '</a>'; } 
+            $html_message .= '</td></tr>
+                <tr><td>Email: <a href="mailto:' . $comment->comment_author_email . '" style="color:#21759b;text-decoration:none;">' . $comment->comment_author_email . '</a></td></tr>
+            </table>
+            <table style="margin-top:15px;">
+                <tr><td style="line-height:150%;">URL: <a href="' . $comment->comment_author_url . '" style="color:#21759b;text-decoration:none;">' . $comment->comment_author_url . '</a></td></tr>
+                <tr><td style="line-height:150%;">Whois: <a href="http://whois.arin.net/rest/ip/' . $comment->comment_author_IP . '" style="color:#21759b;text-decoration:none;">http://whois.arin.net/rest/ip/' . $comment->comment_author_IP . '</a></td></tr>
+            </table>';
+            } elseif ( 'trackback' == $comment_type ) { 
+            $html_message .= '<table style="margin-top:15px;">
+                <tr><td>Website: <a href="' . $comment->comment_author . '" style="color:#21759b;text-decoration:none;">' . $comment->comment_author . '</a></td></tr>
+                <tr><td style="font-size:10px;padding-left:45px;vertical-align:top">IP: ' . $comment->comment_author_IP; 
+			if ( $comment->comment_author_domain ) { $html_message .= ', <a href="' . $comment->comment_author_domain . '" style="color:#21759b;text-decoration:none;">' . $comment->comment_author_domain . '</a>';}
+			$html_message .= '</td></tr>
+            </table>
+            <table style="margin-top:15px;">
+                <tr><td style="line-height:150%;">URL: <a href="' . $comment->comment_author_url . '" style="color:#21759b;text-decoration:none;">' . $comment->comment_author_url . '</a></td></tr>
+            </table>';
+            } elseif ( 'pingback' == $comment_type ) { 
+            $html_message .= '<table style="margin-top:15px;">
+                <tr><td>Website: <a href="' . $comment->comment_author . '" style="color:#21759b;text-decoration:none;">' . $comment->comment_author . '</a></td></tr>
+                <tr><td style="font-size:10px;padding-left:45px;vertical-align:top">IP: ' . $comment->comment_author_IP;
+			if ( $comment->comment_author_domain ) { $html_message .= ', <a href="#" style="color:#21759b;text-decoration:none;">' . $comment->comment_author_domain .'</a><';}
+			$html_message .= '</td></tr>
+            </table>
+            <table style="margin-top:15px;">
+                <tr><td style="line-height:150%;">URL: <a href="' . $comment->comment_author_url . '" style="color:#21759b;text-decoration:none;">' . $comment->comment_author_url . '</a></td></tr>
+            </table>';
+            } 
+            $html_message .= '<div style="line-height:170%;padding: 2em; margin: 1em 0 1em 0;background-color: #ffffff; border: 1px solid #ececec; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px;" id="EemailsContent">';
+			if ( 'pingback' == $comment_type ) $html_message .= '[...] ';
+			$html_message .= wp_specialchars_decode( $comment->comment_content );
+			if ( 'pingback' == $comment_type ) $html_message .= ' [...]';
+           $html_message .= ' </div>
+            <table>
+                <tr><td style="line-height:150%;">Context: <a href="' . get_permalink( $comment->comment_post_ID ) . '" style="color:#21759b;text-decoration:none;">' . get_permalink( $comment->comment_post_ID ) . '</a></td></tr>';
+           if ( isset( $moderation_message ) ) {
+                $html_message .= ' <tr><td style="line-height:150%;">' . $moderation_message . '</td></tr>';
+            }
+            $html_message .= ' </table>';
+            if ( ! empty( $action_links ) ) $html_message .= get_email_action_links( $action_links, $action_links_label );
+?>
\ No newline at end of file
Index: wp-includes/email_templates/email-newblog.php
===================================================================
--- wp-includes/email_templates/email-newblog.php	(revision 0)
+++ wp-includes/email_templates/email-newblog.php	(revision 0)
@@ -0,0 +1,11 @@
+<?php
+            $html_message .= '<div style="line-height:170%;padding: 2em; margin: 1em 0 1em 0;background-color: #ffffff; border: 1px solid #ececec; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px;" id="EemailsContent">
+            	Your new WordPress blog has been successfully set up at:<br />
+                <a href="' . site_url() . '" style="color:#21759b;text-decoration:none;">' . site_url() . '</a>
+                <p style="margin:2em 0 0 0">You can log in to the administrator account with the following information:<br />
+                Username: <strong>admin</strong><br />
+                Password: the password you chose during the install</p>
+            </div>';
+            if ( ! empty( $action_links ) ) $html_message .= get_email_action_links( $action_links, $action_links_label ); 
+        	$html_message .= '<p style="margin-top:15px;line-height:170%;">We hope you enjoy your new blog. Thanks! <br />';
+?>
\ No newline at end of file
Index: wp-includes/email_templates/email-newuser-admin.php
===================================================================
--- wp-includes/email_templates/email-newuser-admin.php	(revision 0)
+++ wp-includes/email_templates/email-newuser-admin.php	(revision 0)
@@ -0,0 +1,9 @@
+<?php
+			$html_message .= '<div style="line-height:170%;padding: 2em; margin: 1em 0 1em 0;background-color: #ffffff; border: 1px solid #ececec; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px;" id="EemailsContent">
+                <p style="margin:2em 0 0.8em 0">A new user - <strong>' . $user->display_name . '</strong>, has just registered on your site.</p>
+                <p style="margin:2em 0 0.8em 0">
+                Username: <strong>' . $user->user_login . '</strong><br />
+                Email: <strong style="text-decoration:none !important;">' . $user->user_email . '</strong><br /></p>
+            </div>';
+            if ( ! empty( $action_links ) ) $html_message .= get_email_action_links( $action_links, $action_links_label );
+?>
\ No newline at end of file
Index: wp-includes/email_templates/email-newuser-user.php
===================================================================
--- wp-includes/email_templates/email-newuser-user.php	(revision 0)
+++ wp-includes/email_templates/email-newuser-user.php	(revision 0)
@@ -0,0 +1,10 @@
+<?php
+			$html_message .= '<div style="line-height:170%;padding: 2em; margin: 1em 0 1em 0;background-color: #ffffff; border: 1px solid #ececec; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px;" id="EemailsContent">
+            	Howdy, ' . $user->user_login . '!
+                <p style="margin:30px 0 10 0">Your account has been successfully created and is ready to use!</p>
+                <p style="margin:30px 0 10 0">You can log in to your account with the following information:<br />
+                Username: <strong>' . $user->user_login . '</strong><br />
+                Password: <strong>' . $user_password . '</strong><br /></p>
+            </div>';
+            if ( ! empty( $action_links ) ) $html_message .= get_email_action_links( $action_links, $action_links_label );
+?>
\ No newline at end of file
Index: wp-includes/email_templates/email-passwordchange-admin.php
===================================================================
--- wp-includes/email_templates/email-passwordchange-admin.php	(revision 0)
+++ wp-includes/email_templates/email-passwordchange-admin.php	(revision 0)
@@ -0,0 +1,9 @@
+<?php
+			$html_message .= '<div style="line-height:170%;padding: 30px; margin: 15px 0 15px 0;background-color: #ffffff; border: 1px solid #ececec; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px;" id="EemailsContent">
+                <p style="margin:2em 0 0.8em 0">The password was reset and changed for the following user:</p>
+                <p style="margin:2em 0 0.8em 0">
+                Username: <strong>' . $user->user_login . '</strong><br />
+                Email: <strong>' . $user->user_email . '</strong><br /></p>
+            </div>';
+            if ( ! empty( $action_links ) ) $html_message .= get_email_action_links( $action_links, $action_links_label );
+?>
\ No newline at end of file
Index: wp-includes/email_templates/email.php
===================================================================
--- wp-includes/email_templates/email.php	(revision 0)
+++ wp-includes/email_templates/email.php	(revision 0)
@@ -0,0 +1 @@
+<?php $html_message .= wp_specialchars_decode( $message ); ?>
\ No newline at end of file
Index: wp-includes/email_templates/email_layout.php
===================================================================
--- wp-includes/email_templates/email_layout.php	(revision 0)
+++ wp-includes/email_templates/email_layout.php	(revision 0)
@@ -0,0 +1,76 @@
+<?php
+
+function get_email_header() {
+	return '<h1 style="margin:0;padding:0;color:#21759b;font-size:20px;font-weight:bold;font-family:Arial;line-height:22px;">
+	' . $content_title . '
+</h1>';
+}
+
+function get_email_footer() {
+	return '
+-- The WordPress Team <br />
+<a href="http://wordpress.org" style="color:#21759b;text-decoration:none;">http://wordpress.org</a>';
+}
+
+function get_email_action_links( $action_links, $action_links_label ) {	
+	$links = array();
+	
+	foreach ($action_links as $link) {
+		$links[] = '<a href="' . $link['link'] . '" style="color:#' . $link['color'] . ';text-decoration:none;margin: 0 10px;font-weight:bold; font-size: 14px">' . $link['text'] . '</a>';
+	}
+	
+	if ( ! empty ( $links ) )
+	$links = $label . implode(' | ',$links);
+	
+	return '<table>
+		<tr><td style="line-height:200%;">' . $links . '</td></tr>
+	</table>';
+}
+
+$html_message = '<!DOCTYPE html>
+<html>
+<head>
+	<title></title>
+	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+	<meta name="viewport" content="width=device-width,user-scalable=no" />
+	<style type="text/css">		
+	@media only screen and (max-device-width: 320px) {
+		#EemailsMainContainer {
+			width:320px !important;
+			margin:0 5px 5px 5px !important;
+		}
+		#EemailsWpLogo {
+			margin:10px !important;
+		}
+		#EemailsInnerContainer {
+			padding:10px !important;
+		}
+		#EemailsContent {
+			padding:10px !important;
+		}
+		#EemailsMainContainer {
+			font-size:11px !important;
+		}
+	}	
+	@media only screen and (min-device-width: 320px) and (max-device-width: 1000px) {
+		#EemailsMainContainer {
+			width:auto !important;
+			margin:0 10px 10px 10px !important;
+		}
+	}	
+	</style>
+</head>
+<body>
+	<div style="max-width:650px;margin:0 0.7em 1em 0.7em;color:#000000;font-family:Arial;font-size:12px;" id="EemailsMainContainer">
+    	<a href="' . site_url() . '" style="border:0;"><img src="' . ABSPATH . WPINC . '/images/wp_logo_email.jpg" alt="WordPress" style="margin:1em;border:0" id="EemailsWpLogo" /></a>
+		<div style="padding: 2em; margin: 0; background-color: #f5f5f5; border: 1px solid #ececec; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px;" id="EemailsInnerContainer">';
+		if ( $include_header ) $html_message .= get_email_header();
+        include( $template );
+        if ( $include_footer ) $html_message .= get_email_footer();
+$html_message .= '
+		</div>
+	</div>
+	</body>
+</html>';
+?>
+           
\ No newline at end of file
Index: wp-includes/functions.php
===================================================================
--- wp-includes/functions.php	(revision 18627)
+++ wp-includes/functions.php	(working copy)
@@ -4580,4 +4580,58 @@
 	@header( 'X-Frame-Options: SAMEORIGIN' );
 }
 
+/**
+ * Compiles the template name based on the arguments and locate the files
+ * 
+ * @param string $slug email template slug
+ * @param string $event email template event (optional)
+ * @param string $name email template name (optional)
+ */
+function get_email_template( $slug, $event = null , $name = null ) {
+	do_action( "get_email_template_{$slug}", $slug, $event, $name );
+	$directories = apply_filters( 'email-template-directories', array(
+                '', // Blank is the default template directories that we want to check first
+	) );
+	$templates = array();
+	foreach ( $directories as $dir ) {
+		$dir_slug = empty( $dir )? $slug : path_join( $dir, $slug );
+
+		if ( isset( $event ) && isset( $name ) )
+		$templates[] = "{$dir_slug}-{$event}-{$name}.php";
+
+		if ( isset( $event ) )
+		$templates[] = "{$dir_slug}-{$event}.php";
+
+		$templates[] = "{$dir_slug}.php";
+	}
+
+	return locate_email_template( $templates );
+} 
+
+/**
+ * Locate the email template
+ * 
+ * @param array $template_names an array of file templates by priority
+ * @return string location where the template was found
+ */
+function locate_email_template( $template_names ) {
+	$located = '';
+	foreach ( (array) $template_names as $template_name ) {
+		if ( !$template_name )
+		continue;
+		if ( file_exists( get_stylesheet_directory() . '/' . $template_name ) ) {
+			$located = array( get_stylesheet_directory() . '/' . $template_name, get_stylesheet_directory() );
+			break;
+		} else if ( file_exists( get_template_directory() . '/' . $template_name ) ) {
+			$located = array( get_template_directory() . '/' . $template_name, get_template_directory() );
+			break;
+		} else if ( file_exists( ABSPATH . WPINC . '/email_templates/' . $template_name ) ) {
+			$located = array( $template_name, ABSPATH . WPINC . '/email_templates' );
+			break;
+		}
+	}
+
+	return $located;
+}
+
 ?>
Index: wp-includes/images/wp_logo_email.jpg
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: wp-includes\images\wp_logo_email.jpg
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: wp-includes/pluggable.php
===================================================================
--- wp-includes/pluggable.php	(revision 18627)
+++ wp-includes/pluggable.php	(working copy)
@@ -180,6 +180,11 @@
  * However, you can set the content type of the email by using the
  * 'wp_mail_content_type' filter.
  *
+ * If $message is an array, the key of each is used to add as an attachment
+ * with the value used as the body. The 'text/plain' element is used as the
+ * text version of the body, with the 'text/html' element used as the HTML
+ * version of the body. All other types are added as attachments.
+ *
  * The default charset is based on the charset used on the blog. The charset can
  * be set using the 'wp_mail_charset' filter.
  *
@@ -196,15 +201,45 @@
  *
  * @param string|array $to Array or comma-separated list of email addresses to send message.
  * @param string $subject Email subject
- * @param string $message Message contents
+ * @param string|array $message Message contents
  * @param string|array $headers Optional. Additional headers.
  * @param string|array $attachments Optional. Files to attach.
+ * @param array $args Optional. E-mail options.
  * @return bool Whether the email contents were sent successfully.
  */
-function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) {
+function wp_mail( $to, $subject, $message, $headers = '', $attachments = array(), $args = array() ) {
+	
+	// Default args
+	$defaults = array (
+ 		'template' => 'email',
+ 		'template_args' => array(),
+ 		'content_title' => '',
+ 		'action_links' => array(),
+ 		'include_header' => true,
+ 		'include_footer' => true,
+	);
+	$args = wp_parse_args( $args, $defaults );
+	
 	// Compact the input, apply the filters, and extract them back out
 	extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) );
-
+	
+	// Extract the arguments, and then the template arguments
+	extract( $args, EXTR_SKIP );
+	extract( $template_args, EXTR_SKIP );
+	
+	// Get template folder and file name
+	$template_data = get_email_template($args['template-slug'], $args['template-event'], $args['template-name']);
+	$template = $template_data[0]; // template name for email layout
+	
+	$html_message = '';
+	
+	include( $template_data[1] . '/email_layout.php' ); 
+	
+	$message = array(
+					 'text/plain' => $message,
+					 'text/html' => $html_message
+					);
+	
 	if ( !is_array($attachments) )
 		$attachments = explode( "\n", str_replace( "\r\n", "\n", $attachments ) );
 
@@ -267,6 +302,10 @@
 						}
 						break;
 					case 'content-type':
+						if ( is_array($message) ) {
+							// Multipart email, ignore the content-type header
+							break;
+						}
 						if ( strpos( $content, ';' ) !== false ) {
 							list( $type, $charset ) = explode( ';', $content );
 							$content_type = trim( $type );
@@ -350,10 +389,53 @@
 		}
 	}
 
+	// If we don't have a charset from the input headers
+	if ( !isset( $charset ) )
+		$charset = get_bloginfo( 'charset' );
+
+	// Set the content-type and charset
+	$phpmailer->CharSet = apply_filters( 'wp_mail_charset', $charset );
+
 	// Set mail's subject and body
 	$phpmailer->Subject = $subject;
-	$phpmailer->Body    = $message;
 
+	if ( is_string($message) ) {
+		$phpmailer->Body    = $message;
+
+		// Set Content-Type and charset
+		// If we don't have a content-type from the input headers
+		if ( !isset( $content_type ) )
+			$content_type = 'text/plain';
+
+		$content_type = apply_filters( 'wp_mail_content_type', $content_type );
+
+		$phpmailer->ContentType = $content_type;
+
+		// Set whether it's plaintext, depending on $content_type
+		if ( 'text/html' == $content_type )
+			$phpmailer->IsHTML( true );
+
+		// For backwards compatibility, new multipart emails should use
+		// the array style $message. This never really worked well anyway
+		if ( false !== stripos( $content_type, 'multipart' ) && ! empty($boundary) )
+			$phpmailer->AddCustomHeader( sprintf( "Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary ) );
+	}
+	elseif ( is_array($message) ) {
+		foreach ($message as $type => $bodies) {
+			foreach ((array) $bodies as $body) {
+				if ($type === 'text/html') {
+					$phpmailer->Body = $body;
+				}
+				elseif ($type === 'text/plain') {
+					$phpmailer->AltBody = $body;
+				}
+				else {
+					$phpmailer->AddAttachment($body, '', 'base64', $type);
+				}
+			}
+		}
+	}
+
 	// Add any CC and BCC recipients
 	if ( !empty( $cc ) ) {
 		foreach ( (array) $cc as $recipient ) {
@@ -394,34 +476,11 @@
 	// Set to use PHP's mail()
 	$phpmailer->IsMail();
 
-	// Set Content-Type and charset
-	// If we don't have a content-type from the input headers
-	if ( !isset( $content_type ) )
-		$content_type = 'text/plain';
-
-	$content_type = apply_filters( 'wp_mail_content_type', $content_type );
-
-	$phpmailer->ContentType = $content_type;
-
-	// Set whether it's plaintext, depending on $content_type
-	if ( 'text/html' == $content_type )
-		$phpmailer->IsHTML( true );
-
-	// If we don't have a charset from the input headers
-	if ( !isset( $charset ) )
-		$charset = get_bloginfo( 'charset' );
-
-	// Set the content-type and charset
-	$phpmailer->CharSet = apply_filters( 'wp_mail_charset', $charset );
-
 	// Set custom headers
 	if ( !empty( $headers ) ) {
 		foreach( (array) $headers as $name => $content ) {
 			$phpmailer->AddCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) );
 		}
-
-		if ( false !== stripos( $content_type, 'multipart' ) && ! empty($boundary) )
-			$phpmailer->AddCustomHeader( sprintf( "Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary ) );
 	}
 
 	if ( !empty( $attachments ) ) {
@@ -986,8 +1045,8 @@
 		return false;
 
 	// The author moderated a comment on his own post
-	if ( $post->post_author == get_current_user_id() )
-		return false;
+	//if ( $post->post_author == get_current_user_id() )
+	//	return false;
 
 	// If there's no email to send the comment to
 	if ( '' == $author->user_email )
@@ -998,9 +1057,14 @@
 	// The blogname option is escaped with esc_html on the way into the database in sanitize_option
 	// we want to reverse this for the plain text arena of emails.
 	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
-
+	$eemail_args = array();
 	if ( empty( $comment_type ) ) $comment_type = 'comment';
 
+	$eemail_args['template_args'] = array(
+		'comment' => $comment,
+		 'comment_type' => $comment_type
+	);
+	
 	if ('comment' == $comment_type) {
 		$notify_message  = sprintf( __( 'New comment on your post "%s"' ), $post->post_title ) . "\r\n";
 		/* translators: 1: comment author, 2: author IP, 3: author domain */
@@ -1010,6 +1074,7 @@
 		$notify_message .= sprintf( __('Whois  : http://whois.arin.net/rest/ip/%s'), $comment->comment_author_IP ) . "\r\n";
 		$notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
 		$notify_message .= __('You can see all comments on this post here: ') . "\r\n";
+		$eemail_args['content_title'] = sprintf( __( '"%s" - new comment' ), $post->post_title );
 		/* translators: 1: blog name, 2: post title */
 		$subject = sprintf( __('[%1$s] Comment: "%2$s"'), $blogname, $post->post_title );
 	} elseif ('trackback' == $comment_type) {
@@ -1019,6 +1084,7 @@
 		$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
 		$notify_message .= __('Excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
 		$notify_message .= __('You can see all trackbacks on this post here: ') . "\r\n";
+		$eemail_args['content_title'] = sprintf( __( '"%s" - new trackback' ), $post->post_title );
 		/* translators: 1: blog name, 2: post title */
 		$subject = sprintf( __('[%1$s] Trackback: "%2$s"'), $blogname, $post->post_title );
 	} elseif ('pingback' == $comment_type) {
@@ -1028,16 +1094,24 @@
 		$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
 		$notify_message .= __('Excerpt: ') . "\r\n" . sprintf('[...] %s [...]', $comment->comment_content ) . "\r\n\r\n";
 		$notify_message .= __('You can see all pingbacks on this post here: ') . "\r\n";
+		$eemail_args['content_title'] = sprintf( __( '"%s" - new pingback' ), $post->post_title );
 		/* translators: 1: blog name, 2: post title */
 		$subject = sprintf( __('[%1$s] Pingback: "%2$s"'), $blogname, $post->post_title );
 	}
 	$notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n";
 	$notify_message .= sprintf( __('Permalink: %s'), get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment_id ) . "\r\n";
-	if ( EMPTY_TRASH_DAYS )
+	
+	$eemail_args['action_links'] = array();
+	if ( EMPTY_TRASH_DAYS ) {
 		$notify_message .= sprintf( __('Trash it: %s'), admin_url("comment.php?action=trash&c=$comment_id") ) . "\r\n";
-	else
+		$eemail_args['action_links'][] = array('link'=>admin_url("comment.php?action=trash&c=$comment_id"),'color'=>'c23031','text'=>__('Trash it'));
+	}
+	else {
 		$notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=delete&c=$comment_id") ) . "\r\n";
+		$eemail_args['action_links'][] = array('link'=>admin_url("comment.php?action=delete&c=$comment_id"),'color'=>'c23031','text'=>__('Delete it'));
+	}
 	$notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=spam&c=$comment_id") ) . "\r\n";
+	$eemail_args['action_links'][] = array('link'=>admin_url("comment.php?action=spam&c=$comment_id"),'color'=>'d2b12e','text'=>__('Mark as spam'));
 
 	$wp_email = 'wordpress@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME']));
 
@@ -1060,9 +1134,10 @@
 	$notify_message = apply_filters('comment_notification_text', $notify_message, $comment_id);
 	$subject = apply_filters('comment_notification_subject', $subject, $comment_id);
 	$message_headers = apply_filters('comment_notification_headers', $message_headers, $comment_id);
-
-	@wp_mail( $author->user_email, $subject, $notify_message, $message_headers );
-
+	$eemail_args['template-slug'] = 'email'; 
+	$eemail_args['template-event'] = 'comment'; 
+	$eemail_args['template-name'] = 'notify'; 
+	@eemails_wp_mail( $author->user_email, $subject, $notify_message, $message_headers, array(), $eemail_args );
 	return true;
 }
 endif;
@@ -1082,7 +1157,7 @@
 
 	if ( 0 == get_option( 'moderation_notify' ) )
 		return true;
-
+		
 	$comment = get_comment($comment_id);
 	$post = get_post($comment->comment_post_ID);
 	$user = get_userdata( $post->post_author );
@@ -1097,7 +1172,16 @@
 	// The blogname option is escaped with esc_html on the way into the database in sanitize_option
 	// we want to reverse this for the plain text arena of emails.
 	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
+	
+	$eemail_args = array();
 
+	$comment_type = $comment->comment_type;
+	if ( empty( $comment_type ) ) $comment_type = 'comment';
+
+	$eemail_args['template_args'] = array(
+		'comment' => $comment,
+		'comment_type' => $comment_type
+	);
 	switch ($comment->comment_type)
 	{
 		case 'trackback':
@@ -1106,6 +1190,7 @@
 			$notify_message .= sprintf( __('Website : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
 			$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
 			$notify_message .= __('Trackback excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
+			$eemail_args['content_title'] = sprintf( __( '"%s" - new trackback awaiting approval' ), $post->post_title );
 			break;
 		case 'pingback':
 			$notify_message  = sprintf( __('A new pingback on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
@@ -1113,6 +1198,7 @@
 			$notify_message .= sprintf( __('Website : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
 			$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
 			$notify_message .= __('Pingback excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
+			$eemail_args['content_title'] = sprintf( __( '"%s" - new pingback awaiting approval' ), $post->post_title );
 			break;
 		default: //Comments
 			$notify_message  = sprintf( __('A new comment on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
@@ -1122,16 +1208,27 @@
 			$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
 			$notify_message .= sprintf( __('Whois  : http://whois.arin.net/rest/ip/%s'), $comment->comment_author_IP ) . "\r\n";
 			$notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
+			$eemail_args['content_title'] = sprintf( __( '"%s" - new comment awaiting approval' ), $post->post_title );
 			break;
 	}
 
+	$eemail_args['action_links'] = array(array('link'=>admin_url("comment.php?action=approve&c=$comment_id"),'color'=>'3ca757','text'=>__('Approve it')));
+																																		   
 	$notify_message .= sprintf( __('Approve it: %s'),  admin_url("comment.php?action=approve&c=$comment_id") ) . "\r\n";
-	if ( EMPTY_TRASH_DAYS )
+	if ( EMPTY_TRASH_DAYS ) {
 		$notify_message .= sprintf( __('Trash it: %s'), admin_url("comment.php?action=trash&c=$comment_id") ) . "\r\n";
-	else
+		$eemail_args['action_links'][] = array('link'=>admin_url("comment.php?action=trash&c=$comment_id"),'color'=>'c23031','text'=>__('Trash it'));
+	}
+	else {
 		$notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=delete&c=$comment_id") ) . "\r\n";
+		$eemail_args['action_links'][] = array('link'=>admin_url("comment.php?action=delete&c=$comment_id"),'color'=>'c23031','text'=>__('Delete it'));
+	}
+		
 	$notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=spam&c=$comment_id") ) . "\r\n";
-
+	$eemail_args['action_links'][] = array('link'=>admin_url("comment.php?action=spam&c=$comment_id"),'color'=>'d2b12e','text'=>__('Mark as spam'));
+	
+	$eemail_args['template_args']['moderation_message'] = sprintf( _n('Currently %s comment is waiting for approval. ',
+ 		'Currently %s comments are waiting for approval.', $comments_waiting), number_format_i18n($comments_waiting) ) . ' <a href="' . admin_url("edit-comments.php?comment_status=moderated") . '" style="color:#21759b;text-decoration:none;">Please visit the moderation panel.</a>';
 	$notify_message .= sprintf( _n('Currently %s comment is waiting for approval. Please visit the moderation panel:',
  		'Currently %s comments are waiting for approval. Please visit the moderation panel:', $comments_waiting), number_format_i18n($comments_waiting) ) . "\r\n";
 	$notify_message .= admin_url("edit-comments.php?comment_status=moderated") . "\r\n";
@@ -1142,9 +1239,12 @@
 	$notify_message = apply_filters('comment_moderation_text', $notify_message, $comment_id);
 	$subject = apply_filters('comment_moderation_subject', $subject, $comment_id);
 	$message_headers = apply_filters('comment_moderation_headers', $message_headers);
-
+	
+	$eemail_args['template-slug'] = 'email';
+	$eemail_args['template-event'] = 'comment';
+	$eemail_args['template-name'] = 'notify';
 	foreach ( $email_to as $email )
-		@wp_mail($email, $subject, $notify_message, $message_headers);
+		@eemails_wp_mail($email, $subject, $notify_message, $message_headers, array(), $eemail_args);
 
 	return true;
 }
@@ -1162,11 +1262,18 @@
 	// send a copy of password change notification to the admin
 	// but check to see if it's the admin whose password we're changing, and skip this
 	if ( $user->user_email != get_option('admin_email') ) {
+		$eemails_args = array();
 		$message = sprintf(__('Password Lost and Changed for user: %s'), $user->user_login) . "\r\n";
 		// The blogname option is escaped with esc_html on the way into the database in sanitize_option
 		// we want to reverse this for the plain text arena of emails.
 		$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
-		wp_mail(get_option('admin_email'), sprintf(__('[%s] Password Lost/Changed'), $blogname), $message);
+		$eemail_args['template'] = 'email-passwordchange-admin';
+		$eemail_args['template_args'] = array('user' => $user);
+		$eemail_args['action_links'] = array(
+											  array('link'=>admin_url("user-edit.php?user_id=".$user->ID),'color'=>'d2b12e','text'=>__('Edit user')),
+											  array('link'=>admin_url("users.php"),'color'=>'3ca757','text'=>__('See all users'))
+											  );
+		eemails_wp_mail(get_option('admin_email'), sprintf(__('[%s] Password Lost/Changed'), $blogname), $message, '', array(), $eemail_args);
 	}
 }
 endif;
@@ -1194,16 +1301,29 @@
 	$message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
 	$message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
 
-	@wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);
+	$eemail_args['template-slug'] = 'email';
+	$eemail_args['template-event'] = 'newuser';
+	$eemail_args['template-name'] = 'admin';
+	$eemail_args['template_args'] = array('user' => $user);
+	$eemail_args['action_links'] = array(
+										  array('link'=>admin_url("user-edit.php?user_id=".$user->ID),'color'=>'d2b12e','text'=>__('Edit user')),
+										  array('link'=>admin_url("users.php"),'color'=>'3ca757','text'=>__('See all users'))
+										);
+	@eemails_wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message, '', array(), $eemail_args);
 
 	if ( empty($plaintext_pass) )
 		return;
 
+	$eemail_args['template_args']["user_password"] = $plaintext_pass;
+	$eemail_args['action_links'] = array();
+	$eemail_args['template-slug'] = 'email';
+	$eemail_args['template-event'] = 'newuser';
+	$eemail_args['template-name'] = 'user'; 
 	$message  = sprintf(__('Username: %s'), $user_login) . "\r\n";
 	$message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n";
 	$message .= wp_login_url() . "\r\n";
 
-	wp_mail($user_email, sprintf(__('[%s] Your username and password'), $blogname), $message);
+	eemails_wp_mail($user_email, sprintf(__('[%s] Your username and password'), $blogname), $message, '', array(), $eemail_args);
 
 }
 endif;
