Plugin to change the WP Email sender details and fix html entities
if you want to change the default sender in the WP core this can be easily plugged.
Equally it’s easy to fix html entitites being transmitted as their encoded literals in the email subjects.
This code shows you how
<?php /* Plugin Name: Change Email From Address/Name Plugin URI: http://rathercurious.net Description: changes the email from address Version: 0.1.0 Author: Justin Adie Author URI: http://rathercurious.net */ class emailFrom{ public function __construct(){ add_filter('wp_mail_from', array(&$this, 'doEmailFilter'),10, 1); add_filter('wp_mail_from_name', array(&$this, 'doEmailNameFilter'), 10, 1); add_filter('wp_mail_charset',array(&$this, 'fixCharset'), 10, 1); add_filter('wp_mail', array(&$this, 'decode'), 10,1); } public function decode($array){ $array['subject'] = html_entity_decode($array['subject']); return $array; } public function fixCharset($data){ return 'UTF-8'; } public function doEmailFilter($data){ return 'email@domain.com'; } public function doEmailNameFilter($data){ return 'My Name'; } } $_ef = new emailFrom(); ?> |
Works like a charm, thank you very much!
Have you thought of adding this to the WP plugins site?
Hello
how are you? great tool! I would like to know is it possible for me to get the user’s email address as from address instead of wordpresss@yourdomain.com when a user register with my site. That is quite easier for me to add them to my “email client’s address book”
Thanks for your effort
test