Comment Comment by kels You could do this a lot easier: if ( !isset( $from_email ) ) { $sitename = parse_url( strtolower( WP_HOME ) )['host']; if ( substr( $sitename, 0, 4 ) == 'www.' ) { $sitename = substr( $sitename, 4 ); } $from_email = 'wordpress@' . $sitename; } Edit: you still need to strip out www. if it exits. Also not compatible with < PHP 5.4 parent kels 9 years ago