The default wp_mail()
function is pluggable – meaning it can be entirely overridden by plugins. In the absence of any external influence, though, the “from” settings for the email address are hard-coded.
Here’s a snippet from /wp-includes/pluggable.php
:
// From email and name
// If we don't have a name from the input headers
if ( !isset( $from_name ) )
$from_name="WordPress";
/* If we don't have an email from the input headers default to wordpress@$sitename
* Some hosts will block outgoing mail from this address if it doesn't exist but
* there's no easy alternative. Defaulting to admin_email might appear to be another
* option but some hosts may refuse to relay mail from an unknown domain. See
* http://trac.wordpress.org/ticket/5007.
*/
if ( !isset( $from_email ) ) {
// Get the site domain and get rid of www.
$sitename = strtolower( $_SERVER['SERVER_NAME'] );
if ( substr( $sitename, 0, 4 ) == 'www.' ) {
$sitename = substr( $sitename, 4 );
}
$from_email="wordpress@" . $sitename;
}
// Plugin authors can override the potentially troublesome default
$phpmailer->From = apply_filters( 'wp_mail_from' , $from_email );
$phpmailer->FromName = apply_filters( 'wp_mail_from_name', $from_name );
I showed you this specific snippet for two reasons:
- It illustrates how the from name and email are set. By default mail is sent from “WordPress” using the address
wordpress@sitename.url
… whateversitename.url
might be in your case. - It shows that you can filter things a bit.
If you don’t want to go the plugin route, you can set up a quick filter in your theme or in a drop-in MU plugin.
add_filter( 'wp_mail_from', 'wp44834_from' );
function wp44834_from( $from_email ) {
return "myemail@mydomain.com";
}
add_filter( 'wp_mail_from_name', 'wp44834_from_name' );
function wp44834_from_name( $from_name ) {
return "Bob";
}
These filters will override the built-in defaults and make it appear as if your email actually came from you rather than from WordPress.