By default, your WordPress website sends e-mails like wordpress@your-domain.com and WordPress as the default sender (From :) name. That is not always desirable. For example, your mail may be blocked and classified as spam. Do you notice that your mail does not arrive regularly and do you have complaints about this? The instructions below can help you to ensure that your mail is not so quickly blocked by spam checks.
Change standard WordPress e-mail address
The standard WordPress e-mail address can be changed with a small piece of code. You add these to your functions.php of your theme.
// Verander standaard e-mail afzender naam (From name)
add_filter( 'wp_mail_from_name', 'jouw_prefix_wp_mail_from_name' );
function jouw_prefix_wp_mail_from_name( $original_email_from ) {
return 'Jouw naam';
}
You can also change the default sender name (From name) with a simple filter. You also add these to your functions.php of your theme.
// Verander standaard e-mail afzender naam (From name)
add_filter( 'wp_mail_from_name', 'jouw_prefix_wp_mail_from_name' );
function jouw_prefix_wp_mail_from_name( $original_email_from ) {
return 'Jouw Naam';
}
Bonus: Send e-mail by default as HTML in WordPress
By default, all e-mail in WordPress is sent as plain text. The standard e-mail content type is text/plain. If you want to send your e-mails as HTML, you can adjust the content type for all e-mails. You also do that with a simple filter that you add to your functions.php themes.
With the above filters, you can ensure that your mail is sent better and nicer. This can be useful, for example, if your website is running on a subdomain. An e-mail that is sent from an e-mail address wordpress@subdomain.yourdomain.com is quickly marked as SPAM and of course, you do not want that.
// Verander e-mail content type
add_filter( 'wp_mail_content_type', 'jouw_prefix_set_content_type' );
function jouw_prefix_set_content_type( $content_type ) {
return 'text/html';
}
With the above filters, you can ensure that your mail is sent better and nicer. This can be useful, for example, if your website is running on a subdomain. An e-mail that is sent from an e-mail address wordpress@subdomain.yourdomain.com is quickly marked as SPAM and of course, you do not want that.
Do you want to know how "spammy" are your emails? Then use mail-tester.com.
How do you use the above filters? Let us know in the comments.