Topic on Project:Support desk

[RESOLVED] Unknown error in PHP's mail() function

12
Kmacdowe (talkcontribs)

MediaWiki: 1.23.5 PHP: 5.5.9-1ubuntu4.4 (apache2handler) MySQL: 5.5.40-0ubuntu0.14.04.1

I installed a new wiki. It is working fine other than it fails at sending email. For example when I ask it to send a confirmation email I get the following error:

"4MI Wiki could not send your confirmation mail. Please check your email address for invalid characters. Mailer returned: Unknown error in PHP's mail() function."

Or when I try to create a new account and have a random password sent to the user I get this error: "Account creation error Error sending mail: Unknown error in PHP's mail() function."

Florianschmidtwelzow (talkcontribs)
Kmacdowe (talkcontribs)

The solution was to remove a line from the PHP configuration file that was redundantly calling a PHP module that was already called from a different config file. Sorry I don't have the specifics at hand right now. Advice to others that have this problem: try sending mail from the CLI, if you get an error, fix that and then try sending from your wiki again. Thanks Florianschmidtwelzow for the help.

Foudfou (talkcontribs)
Jabbott (talkcontribs)

If you are running CentOS7 (or the equivalent Redhat) running SEL, you may have to turn on the ability of apache to send mail. See if this is set to allow or disallow by running the following command:
getsebool -a | grep mail
If you get the following response:
allow_postfix_local_write_mail_spool --> off
Then you will get the Unknown error. You will need to turn on this ability in the OS by the following command:
setsebool -P httpd_can_sendmail on
This should cure the error.

Kmacdowe (talkcontribs)
Fokebox (talkcontribs)

I have the same problem at my Wiki:

MediaWiki 1.35.0
PHP 7.4.12 (cgi-fcgi)
MySQL 5.7.27-30
ICU 50.1.2
Lua 5.1.5

What is the solution?

Ciencia Al Poder (talkcontribs)

The solution is to unblock (you, or your hosting provider) connections from PHP to the external mail server.

Fokebox (talkcontribs)

A little bit unclear for me how to so ... what I noticed I have such problem after upgrading from 1.29 to 1.35

Ciencia Al Poder (talkcontribs)

With the upgrade of MediaWiki 1.29 to 1.35 you have also upgraded PHP (otherwise it wouldn't work). Since you're using php mail() function instead of PEAR_mail, you'll have to review and correct php's mail settings. See https://www.php.net/manual/mail.configuration.php

Fokebox (talkcontribs)

Thank you! I am not a programmer and appreciate if you let me know what exactly should be made according to the provided article.

Ciencia Al Poder (talkcontribs)

This is not really something for a programmer, but for a system/network administrator. Contact your hosting provider

Reply to "[RESOLVED] Unknown error in PHP's mail() function"