• Register
0 votes
379 views

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

Solution:

STEP 1:

 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) )

STEP 2:

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:

<?php
/**
 * 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

1 vote
1 answer 5 views
5 views
Problem: How to fix this erro:the activity must be exported or contain an intent-filter. your host may have disabled the mail() function.
asked Mar 3 Muneeb Saadii 127k points
1 vote
1 answer 3 views
3 views
Problem: Getting the following error. Mailer error could not instantiate mail function.
asked Mar 25 PkGuy 13.1k points
0 votes
1 answer 64 views
64 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 194 views
194 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 4 views
4 views
Problem: Please solve it &hellip; Because I am unable to find out the solution
asked Mar 12 Ifra 24.4k points
0 votes
1 answer 3 views
3 views
Problem: Hello ... Can anyone tell me that why I got this error?
asked Mar 12 Ifra 24.4k points
0 votes
1 answer 5 views
5 views
Problem: Please someone help me how to send mail with pdf attachment?
asked Mar 12 Ifra 24.4k points
0 votes
1 answer 37 views
37 views
Problem I need example code to send attachment in php.
asked Oct 29, 2020 hashq 1.1k points
0 votes
1 answer 37 views
37 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 16.2k points
0 votes
1 answer 1 view
1 view
Problem: I need someone&rsquo;s assistance to solve my problem .. php code to send email from contact form
asked 5 days ago Ifra 24.4k points