Saturday, November 9, 2013

Change FromName and FromEmail For Wordpress

Open your theme function.php file to setup new fromname and fromemail for Site emails.

<?php
add_filter('wp_mail_from','mail_from');
add_filter('wp_mail_from_name','mail_from_name');

function mail_from()
{

global $mail_from_opt;

if (empty($mail_from_opt['username'])) : $username = "Bhumika"; endif;
$domainname = strtolower( $_SERVER['SERVER_NAME'] );
if ( substr( $domainname, 0, 4 ) == 'www.' ) {
$domainname = substr( $domainname, 4 );
}
$emailaddress = $username.'@'.$domainname;

return $emailaddress;
}

function mail_from_name()
{

global $mail_from_opt;

if (empty($mail_from_opt['sendername'])) : $sendername = "Bhumika"; endif;

return $sendername;
}
?>

:)