This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
faq:troubleshooting-could-not-instantiate-mail-function [2014/02/27 10:12] Alia |
faq:troubleshooting-could-not-instantiate-mail-function [2014/02/27 11:18] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Troubleshooting "Could not instantiate mail function" ====== | ====== Troubleshooting "Could not instantiate mail function" ====== | ||
- | Full error message: | + | Full error message: |
<code php> | <code php> | ||
OW Debug - Exception | OW Debug - Exception | ||
Message: Could not instantiate mail function. | Message: Could not instantiate mail function. | ||
- | File: /var/www/friendly/data/www/friendly.ru/ow_libraries/php_mailer/class.phpmailer.php | + | File: /mysitename/ow_libraries/php_mailer/class.phpmailer.php |
Line: 595 | Line: 595 | ||
Trace: | Trace: | ||
Line 23: | Line 23: | ||
Human readable explanation of the error message: phpMailer library tried to send a message using the php mail() function and the php mail() function returned "false" result. | Human readable explanation of the error message: phpMailer library tried to send a message using the php mail() function and the php mail() function returned "false" result. | ||
- | Two most common causes of this error message are | + | Two most common causes of this error message are: |
- | - server settings | + | - Server settings |
- | - phpmailer library used within Oxwall. | + | - Phpmailer library used within Oxwall. |
===== Checking Server Settings ===== | ===== Checking Server Settings ===== | ||
- | Since mail functions are part of the PHP's core, first of all make sure that PHP was configured/compiled correctly on your server to send emails. Run following test to see whether php mail script is working. | + | Since mail functions are part of the PHP's core, first of all make sure that PHP was configured/compiled correctly on your server to send emails. Run following test to check this: |
Create a file called testing_mail.php in /public_html/ directory on your server. | Create a file called testing_mail.php in /public_html/ directory on your server. | ||
- | Add one of the following codes into this file: | + | Add **one** of the following codes into this file: |
- | 1. | ||
<code php> <? $headers = 'From:any_sender_email@example.com'; mail('recepient@example.com', 'Test email using PHP', 'This is a test email message', $headers, '-fany_sender_email@example.com');?> </code> | <code php> <? $headers = 'From:any_sender_email@example.com'; mail('recepient@example.com', 'Test email using PHP', 'This is a test email message', $headers, '-fany_sender_email@example.com');?> </code> | ||
- | 2.<code php> <?php $to = 'recepient@example.com'; $subject = 'Test email using PHP'; $message = 'This is a test email message'; $headers = 'From: any_sender_email@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers, '-fany_sender_email@example.com'); ?> </code> | + | <code php> <?php $to = 'recepient@example.com'; $subject = 'Test email using PHP'; $message = 'This is a test email message'; $headers = 'From: any_sender_email@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers, '-fany_sender_email@example.com'); ?> </code> |
Where | Where | ||
* any_sender_email@example.com - your sender's email | * any_sender_email@example.com - your sender's email | ||
Line 44: | Line 42: | ||
* recepient@example.com - your recipient's email. | * recepient@example.com - your recipient's email. | ||
- | Make sure to replace those values in the testing_mail.php by existing email addresses. | + | Make sure to replace those values by existing email addresses. |
Run created file by opening www.yoursitename.com/testing_mail.php in any browser. You should see blank page. | Run created file by opening www.yoursitename.com/testing_mail.php in any browser. You should see blank page. | ||
- | In case if Oxwall itself is installed in /public_html directory, you will see "Page Not Found" message. This happens because Oxwall's .htaccess is blocking this page. Add following line into Oxwall's .htaccess right before "RewriteCond %{REQUEST_URI} !^/index\.php" to solve this issue: | + | |
+ | In case if Oxwall itself is installed in /public_html/ directory, you will see "Page Not Found" message. This happens because Oxwall's .htaccess is blocking this page. Add following line into Oxwall's .htaccess right before //"RewriteCond %{REQUEST_URI} !^/index\.php"// to solve this issue: | ||
<code php> RewriteCond %{REQUEST_URI} !/testing_mail\.php </code> | <code php> RewriteCond %{REQUEST_URI} !/testing_mail\.php </code> | ||
- | Open www.yoursitename.com/testing_mail.php again. | + | Open www.yoursitename.com/testing_mail.php again. You should now see a blank page. |
Check the email you have set for "recepient@example.com". | Check the email you have set for "recepient@example.com". | ||
- | If you don't receive testing email php mail script is not working. | + | If you don't receive testing email, contact your hosting provider and check: |
- | - Check whether phpmailer library is installed/enabled/configured | + | - whether phpmailer library is installed/enabled/configured on your server. |
- | - Check whether php mail() function is installed/enabled/configured | + | - whether php mail() function is installed/enabled/configured on your server. |
- | Best way to check this, is to contact your hosting provider. | + | |
- | - If your hosting company confirms that both are enabled/configured properly, | + | |
- | If you receive testing email, php mail script is working on your server. In this case, "Could not instantiate mail function" is most likely to be caused by php mailer libraries used in Oxwall. | + | If you receive testing email, php mail script is working on your server. In this case, "Could not instantiate mail function" is most likely to be caused by php mailer libraries used in Oxwall itself. |
===== Phpmailer libraries used within Oxwall ===== | ===== Phpmailer libraries used within Oxwall ===== | ||
- | If your have tried all the steps listed above and have contacted your host and you are still getting "Could not Instantiate ..." error: | + | If you have tried all the steps listed above and are still getting "Could not Instantiate Mail Function" then phpmailer libraries used in Oxwall might not be compatible with your server's configuration. |
+ | |||
+ | Open ow_libraries/php_mailer/class.phpmailer.php and find line #571: | ||
+ | |||
+ | <code php> $params = sprintf("-oi -f %s", $this->Sender); </code> | ||
- | open | + | Replace this code by: |
+ | <code php> $params = null; //sprintf("-oi -f %s", $this->Sender); </code> | ||
+ | Once changes are made try to reproduce "Message: Could not instantiate mail function" error. For example, try to reset your password. | ||
+ | If you don't see error message and receive the email, then leave the fix you have just applied. | ||
+ | Explanation of the fix: Most of the servers accept "sprintf("-oi -f %s", $this->Sender " parameter. In your case, your server rejected it and returned "false" result. To solve this Oxwall needs to update phpmailer libraries used within the script. This will be done in one of the upcoming builds. Until then, leave the fix you have just applied and wait for the new update. | ||