the email could not be sent. possible reason: your host may have disabled the mail() function.
- WordPress is built on PHP and it uses PHP
mail()
to send emails in different situations. - It is also referred as
wp_mail()
function or justmail()
function. - PHP
mail()
function however, uses a program calledsendmail
to work or send email usingsendmail_path
.
your host may have disabled the mail() function.
- To find out if PHP
mail()
function is disabled inphp.ini
file, you need to first open thephp.ini
file.php.ini
file is often located in a folder under/etc/php/
.
possible reason: your host may have disabled the mail() function.
There are two conditions. $messagehave
to be true (not an empty string, not false, not null, etc). And wp_mail()
shouldn’t return false.
if ( $message && !wp_mail($user_email, $title, $message) )
You can easily find the path of PHP.ini file by uploading a simple php file with following script to your hosting server.
<?php phpinfo(); ?>
Word-press used wp_mail()
function to send email which need PHPMailer class which used php mailer stored in /usr/sbin/sendmail.
Use this simple php function first to check php mail
<?php $to = "example@gmail.com"; $subject = "Test Email Function"; $txt = "Hello world!"; $headers = "From: webmaster@example.com" . "\r\n" . "CC: xyz@example.com"; mail($to,$subject,$txt,$headers); ?>
If this is not working then you need to install php mailer. Use this command to install php mail on Ubuntu server.
sudo apt-get install sendmail
Then check word-press email functions.