Skip to content

Instantly share code, notes, and snippets.

@mauriciogofas
Last active August 29, 2015 14:14
Show Gist options
  • Save mauriciogofas/7cfc8e03aaf107d75e36 to your computer and use it in GitHub Desktop.
Save mauriciogofas/7cfc8e03aaf107d75e36 to your computer and use it in GitHub Desktop.
Default WP From email
<?php
//Default From mail
function custom_wp_mail_from( $email ) {
$handle = 'site';
$find = 'http://www.';
$replace = '';
$link = get_bloginfo( 'url' );
$domain = str_replace( $find, $replace, $link );
return $handle . '@' . $domain ;
}
add_filter( 'wp_mail_from', 'custom_wp_mail_from' );
class email_return_path {
function __construct() {
add_action( 'phpmailer_init', array( $this, 'fix' ) );
}
function fix( $phpmailer ) {
$phpmailer->Sender = $phpmailer->From;
}
}
new email_return_path();
//From name
add_filter('wp_mail_from_name', 'new_mail_from_name');
function new_mail_from_name($old) {
$site_name = get_option( 'blogname');
return $site_name;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment