HTML Emails with wp_mail()

PHP programming language and everything associated with it.

HTML Emails with wp_mail()

Postby adam123 » Thu Sep 20, 2012 5:40 am

HTML Emails with wp_mail()

Code: Select all
   <?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 );
       }
   ?>
adam123
Posting Frequency
Posting Frequency
 
Posts: 1041
Joined: Tue Sep 18, 2012 2:12 am

HTML Emails with wp_mail()

Return to PHP


Link to: HTML Emails with wp_mail()
URL:
BBCODE:
HTML:

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 0 guests

 ® PcLayer.com 2009-2012 ©   All Rights Reserved

cron