Advertisement
keha76

WordPress Set WP Mail Headers

Jun 27th, 2013
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.27 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: Set WP Mail Headers
  4. Plugin URI: http://pastebin.com/edit.php?i=WvWknrmp
  5. Version: 1.0
  6. Description: Put anything you want in the email headers.
  7. Author: Kenth Hagström
  8. Author URI: http://designpalatset.se/
  9. Contributors:
  10. License: GPL2
  11. License URI: http://www.opensource.org/licenses/gpl-license.php
  12. */
  13.  
  14. /**
  15.  * Set any WP Mail Parameters you'd like to
  16.  *
  17.  * @uses filter wp_mail
  18.  * @param array $params
  19.  * @return array
  20.  */
  21. function dp_set_wp_mail_params( $params ) {
  22.     $params['headers'] = '';
  23.     $params['headers'] .= "Reply-To: Ditt Namn <[email protected]>\r\n";
  24.     $params['headers'] .= "From: Ditt Namn <[email protected]>\r\n";
  25.     $params['headers'] .= "Organization: Organisationsnamn\r\n";
  26.     $params['headers'] .= "MIME-Version: 1.0\r\n";
  27.     $params['headers'] .= "Content-Type: text/plain; charset=iso-8859-1\r\n";
  28.     $params['headers'] .= "X-Priority: 2\r\n"; // Make it less spammy
  29.     $params['headers'] .= "X-Mailer: PHP ". phpversion() ."\r\n";
  30.     return $params;
  31. }
  32. add_filter( 'wp_mail', 'dp_set_wp_mail_params', 5 );
  33.  
  34. /**
  35.  * Force Return-Path
  36.  *
  37.  * @param object $phpmailer
  38.  * @return void
  39.  */
  40. function dp_fix_return_path( $phpmailer ) {
  41.     $phpmailer->Sender = $phpmailer->From;
  42. }
  43. add_action( 'phpmailer_init', 'dp_fix_return_path', 10 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement