Email From header modification
-
If you want sent emails to have “From” address in form of “blogname <admin_email>”, you can modify this great plugin as follows. All changes are done in file new-user-approve.php.
1. Insert this code after last function in php file:
public function headers() { if ( empty($this->myname) || empty($this->myemail) ) { $this->myname = html_entity_decode(get_option('blogname'), ENT_QUOTES); $this->myemail = get_option('admin_email'); } if ( function_exists('mb_encode_mimeheader') ) { $header['From'] = mb_encode_mimeheader($this->myname, 'UTF-8', 'Q') . " <" . $this->myemail . ">"; $header['Reply-To'] = mb_encode_mimeheader($this->myname, 'UTF-8', 'Q') . " <" . $this->myemail . ">"; } else { $header['From'] = $this->myname. " <" . $this->myemail . ">"; $header['Reply-To'] = $this->myname . " <" . $this->myemail . ">"; } $header['Return-path'] = "<" . $this->myemail . ">"; $header['Content-Type'] = "text/plain; charset=\"". get_option('blog_charset') . "\""; // collapse the headers using $key as the header name foreach ( $header as $key => $value ) { $headers[$key] = $key . ": " . $value; } $headers = implode("\n", $headers); $headers .= "\n"; return $headers; }2. Find all occurences of code
wp_mail( get_option( 'admin_email' ), $subject, $message );
and
@wp_mail( $user_email, $subject, $message )
and change them to
wp_mail( get_option( 'admin_email' ), $subject, $message, $headers );
and
@wp_mail( $user_email, $subject, $message, $headers );
respectively.3. Insert following code
$headers = $this->headers();
before all occurences of
wp_mail( get_option( 'admin_email' ), $subject, $message, $headers );
and
@wp_mail( $user_email, $subject, $message, $headers );4. Find this code
var $_admin_page = 'new-user-approve-admin';
and insert this code after it:var $myname = ''; var $myemail = '';This modification is based on code from great Subscribe2 plugin.
The topic ‘Email From header modification’ is closed to new replies.