WordPress anyone can register, but no email confirmation

Many times it has happened to me that my WordPress installation properly send emails using wp_mail directly, specifing also the…

August 25, 2015

Many times it has happened to me that my WordPress installation properly send emails using wp_mail directly, specifing also the headers parameter with the proper From syntax followed by the email address.
But when I use the “anyone can register” checkbox and try to register a new user from the url http://yourdomain.it/wp-login.php?action=register I don’t receive any email and can’t use the users (neither for the user nor for the admin).
So I’ve investigated a little bit more and I’ve found that the wp_new_user_notification function in the wp-includes/pluggable.php core file do not have a default value for From header. This let the PHP use the parameter in the php.ini file (I think) which on many server is not configured for your web sites, and so your emails are not sent.
To fix this, force wp_mail to use a From header by adding this two functions on your functions.php file.

add_filter( 'wp_mail_from', 'force_from' );
function force_from( $email ) {
	return "noreply@yourdomain.it";

add_filter( 'wp_mail_from_name', 'force_from_name' );
function force_from_name( $name ) {
	return "Wordpress of Your Domain";


I'm a software engineer, an everyday web developer and a maker. I usually build sites with PHP, within or without WordPress. I build Internet of Things with Arduino and ESP8266. I'm the founder of Rockit.it and Dailybest.it and I'm actually the Chief Technical Officer of Better Days web agency.


How to add rel=”nofollow” to links with preg_replace()

Adding rel="nofollow" to external link is a good SEO practice.

September 22, 2015

Social buttons: the fastest way for WordPress, without plugins

NOTE: the code in this post is written for WordPress but you can easily translate it in any language. You’re here…

September 15, 2015

Optimize WordPress, a long list of tips

In the above image you can see your WordPress before reading this post, and after the optimizations you will make…

Limit the number of categories for posts in WordPress

CHOOSE ONLY ONE CATEGORY WORDPRESS If you need to limit the number of categories used by the authors of your…

September 14, 2015

Remove archive pages in WordPress, how to

I think that in most blogs (that is not all) archive pages are redundant content and there’s no need to…

September 8, 2015

WordPress 4.1.1 is available! Please update now.

Sometimes you find messages like “WordPress 4.1.1 is available! Please update now.“, in italian it is: “È disponibile WordPress 4.1.1! Aggiorna…

March 16, 2015