• Register
0 votes

Problem :

Getting following wordpress error while tring to send the email
the email could not be sent. possible reason: your host may have disabled the mail() function.
6 5 3
6,930 points

Please log in or register to answer this question.

2 Answers

0 votes
Best answer

Solution :

Go to -Manage Registered Email-Ids for Sending Mails via Scripts or Wordpress

  1. Firstly you need to Login to your Cpanel.
  2. Then go to Email Section > then Click Registered Email IDs.
  3. then add domain (wordpress@yourdomain.com) or where your wordpress hosted (wordpress@blog.yourdomain.com) . then submit , it will take few minute to activate can wait 15minute to 1 hour depending to your hosting provider, then it will work.
9 7 4
38,600 points
0 votes



 First find the file where the error message appear. I use Notepad++ and the CTRL + F command to search in files. It is a good idea to search only the first few words of the error message, because some error messages are combined of different messages.

Your error message appear in wp-login.php and holy luck, only there. So let's have a look why this error could occur.

if ( $message && !wp_mail($user_email, $title, $message) )


There are two conditions. $messagehave to be true (not an empty string, not false, not null, etc). And wp_mail() shouldn't return false.

One line above, there is a filter $message = apply_filters('retrieve_password_message', $message, $key);, so it is possible that a plugin (or theme) use this filter and returns a value that is not true (empty string, false, null, etc.).

But it is much easier to check if wp_mail() is working or not. Write a small plugin to send a test mail to yourself:

 * Plugin Name: Stackexchange Testplugin
 * Plugin URI:  http://yoda.neun12.de
 * Description: Send me a test email
 * Version:     0.1
 * Author:      Ralf Albert
 * Author URI:  http://yoda.neun12.de
 * Text Domain:
 * Domain Path:
 * Network:
 * License:     GPLv3

namespace WordPressStackexchange;

add_action( 'init', __NAMESPACE__ . '\plugin_init' );

function plugin_init(){
    $to      = 'your-email-adress@some-domain.tld';
    $subject = 'Testemail';
    $message = 'FooBarBaz Testmail is working';

    wp_mail( $to, $subject, $message );

(This is PHP5.3 code. If you are running PHP5.2, remove the namespace things)

The plugin should send a testmail immediately after activation. If not, calling some backend pages (e.g. dashboard) should do it.

If the testmail does not arrive, then you probably have an issue with wp_mail(). So turn on debugging:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', true );
@ini_set( 'display_errors',1 );

Put this code into your wp-config.php and retry sending yourself a testmail. Now you should get some error messages and they also should be logged into wp-content/debug.log (The debug log can grow very large if there are more errors caused by plugins and/or themes).

At this point, you got good informations if wp_mail() fails and if so, why. If wp_mail() work correctly and the testmail arrived, go back to top and find out why $message is not true.

If you have issues with wp_mail(), so keep in mind that wp_mail() does not use PHPs mail() function. WordPress use a PHP class (PHPMailer). Maybe you just need a plugin to use SMTP instead of sendmail. Or the problem is located at another place. We don't know. You have to investigate.

10 6 4
31,120 points

Related questions

0 votes
1 answer 39 views
Problem Hi Kodlogs, How am having following error while sending mails using PHP: mailer error: could not instantiate mail function Need help fixing please
asked Nov 3, 2020 hashq 1.1k points
0 votes
1 answer 81 views
Problem: I am trying to send the email to my gmail address but it keeps on showing below error: "SMTP -> ERROR: Failed to connect to server: Connection timed out (110)SMTP Connect() failed. Message was not sent.Mailer error: SMTP Connect() failed." Please find ... ;             } else {             echo 'Message has been sent.';            } How can I fix above error message related to PHPMail?
asked Jul 31, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 19 views
Problem: I am trying to send mail to gmail address but it keeps getting this error "SMTP -> ERROR: Failed to connect to server: connection timeout (110) SMTP Connect () failed. Message was not sent. Sender error: SMTP Connect () error . " What could be the problem? require ' ... { echo 'Message was not sent.'; echo 'Mailer error: ' . $mail->ErrorInfo; } else { echo 'Message has been sent.'; }
asked Nov 12, 2020 sasha 6.4k points
0 votes
1 answer 34 views
Problem I need example code to send attachment in php.
asked Oct 29, 2020 hashq 1.1k points
1 vote
1 answer 354 views
Problem: I am very new to Laravel. I have recently started leaning laravel. I am using the correct email address. I have already echoed it but if I try to send it then I face the below error: "Address in mailbox given [] does not comply with RFC 2822, 3 ... send('emails.activation', $data, function($message){ $message->to($email)->subject($subject); }); ->with('title', "Registered Successfully.");
asked Jun 5, 2020 Martin K 6.6k points
0 votes
1 answer 570 views
Problem : I am facing below error message Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in I am unable to understand this message. Please let me know how can I fix it?
asked Jan 31, 2020 jwilliam 3.9k points
0 votes
1 answer 13 views
1 vote
1 answer 329 views
Problem: I have fundamental knowledge in Spring Mvc 4. I have gained knowledge from local tutor. Now I am trying to use the javamail in the spring mvc 4 to send the email using the gmail but I am facing below error there. My error reads as: Info: DEBUG: getProvider( ... starttls.enable">true</prop>         </props>     </property> </bean> Please help me in fixing above error related to Spring MVC.
asked Jun 13, 2020 Martin K 6.6k points