Jump to content

Topic on Project:Support desk/Flow

Mediawiki mail settings for password reset and registration

27
Bekircem (talkcontribs)

I want to setup mail settings on Mediawiki. I am used Sparkpost for mail server. My Mediawiki system installed on Digital Ocean with Serverpilot. There my mail settings on Localsettings.php file.

$wgEnableEmail = True;

$wgEnableUserEmail = True; # UPO

$wgEmailAuthentication = True;

$wgSMTP = array(

'host'     => "smtp.sparkpostmail.com", // could also be an IP address. Where the SMTP server is located

'IDHost'   => "sitename.com",      // Generally this will be the domain name of your website (aka mywiki.org)

'port'     => 587,                 // Port to use when connecting to the SMTP server

'auth'     => true,               // Should we use SMTP authentication (true or false)

'username' => "SMTP_Injection",     // Username to use for SMTP authentication (if being used)

'password' => "KEY"       // Password to use for SMTP authentication (if being used)

);

It does not work that way. When i create account or password reset request, Mediawiki gives me an error:

[9d7926ea] /index.php?title=%C3%96zel:Kullan%C4%B1c%C4%B1OturumuA%C3%A7ma&action=submitlogin&type=signup&returnto=Ana+Sayfa MWException from line 268 of includes/mail/UserMailer.php: PEAR mail package is not installed

Backtrace:

#0 includes/User.php(4208): UserMailer::send(array, MailAddress, string, string, NULL)

#1 includes/User.php(4184): User->sendMail(string, string)

#2 includes/specials/SpecialUserlogin.php(409): User->sendConfirmationMail()

#3 includes/specials/SpecialUserlogin.php(314): LoginForm->addNewAccount()

#4 includes/specialpage/SpecialPage.php(384): LoginForm->execute(NULL)

#5 includes/specialpage/SpecialPageFactory.php(582): SpecialPage->run(NULL)

#6 includes/MediaWiki.php(267): SpecialPageFactory::executePath(Title, RequestContext)

#7 includes/MediaWiki.php(566): MediaWiki->performRequest()

#8 includes/MediaWiki.php(414): MediaWiki->main()

#9 index.php(41): MediaWiki->run()

#10 {main}

So, I check PEAR version on the terminal with that command: pear7.0-sp version

Output:

PEAR Version: 1.10.5

PHP Version: 7.0.27

Zend Engine Version: 3.0.0

Running on: Linux sitename.com 3.13.0-79-generic #123-Ubuntu SMP Fri Feb 19 14:27:58 UTC 2016 x86_64

Pear installed on my server. This problem about include path or PEAR mail package installation? What is your suggestion?

I've tried include path settings but it gives me error too. If the problem is related to this, how i can set that correctly? Thank you so much.

Malyacko (talkcontribs)
Bekircem (talkcontribs)

I've installed Pear Mail package. After that, when i request for password reset it gives me that error:

Fatal error: Uncaught TypeError: Argument 1 passed to MWExceptionHandler::handleException() must be an instance of Exception, instance of Error given in includes/exception/MWExceptionHandler.php:153 Stack trace: #0 [internal function]: MWExceptionHandler::handleException(Object(Error)) #1 {main} thrown in includes/exception/MWExceptionHandler.php on line 153

I think Pear problem fixed but there is another problem now... :(

Malyacko (talkcontribs)
Bekircem (talkcontribs)

I added Localsettings.php this lines:

$wgShowExceptionDetails = true;;

$wgDebugToolbar = true;

$wgShowDebug = true;

$wgDevelopmentWarnings = true;

It gives me error, i disabled Description2 extension for viewing wiki correctly.

Notice: Deprecated PHP entry point used for Description2 extension. Please use wfLoadExtension instead, see https://www.mediawiki.org/wiki/Extension_registration for more details. [Called from require_once in /extensions/Description2/Description2.php at line 20] in /includes/debug/MWDebug.php on line 300

Warning: Cannot modify header information - headers already sent by (output started at /includes/debug/MWDebug.php:300) in /includes/WebResponse.php on line 37

Warning: Cannot modify header information - headers already sent by (output started at /includes/debug/MWDebug.php:300) in /includes/WebResponse.php on line 37

Warning: Cannot modify header information - headers already sent by (output started at /includes/debug/MWDebug.php:300) in /includes/WebResponse.php on line 37

Warning: Cannot modify header information - headers already sent by (output started at /includes/debug/MWDebug.php:300) in /includes/WebResponse.php on line 37

Warning: Cannot modify header information - headers already sent by (output started at /includes/debug/MWDebug.php:300) in /includes/WebResponse.php on line 37

Warning: Cannot modify header information - headers already sent by (output started at /includes/debug/MWDebug.php:300) in /includes/WebResponse.php on line 37

Warning: Cannot modify header information - headers already sent by (output started at /includes/debug/MWDebug.php:300) in /includes/WebResponse.php on line 37

It's error when i go special pages.

Deprecated: Use of SpecialRecentChangesQuery hook (used in FlaggedRevsUIHooks::modifyRecentChangesQuery) was deprecated in MediaWiki 1.23. [Called from SpecialRecentChanges::runMainQueryHook in specials/SpecialRecentchanges.php at line 262] in includes/debug/MWDebug.php on line 300

When i added that lines to .htaccess file wiki gives me 500 Internal Server Error:

php_value error_reporting -1

php_flag display_errors On

When i request for password reset it gives me same error:

Fatal error: Uncaught TypeError: Argument 1 passed to MWExceptionHandler::handleException() must be an instance of Exception, instance of Error given in exception/MWExceptionHandler.php:153 Stack trace: #0 [internal function]: MWExceptionHandler::handleException(Object(Error)) #1 {main} thrown in includes/exception/MWExceptionHandler.php on line 153

Malyacko (talkcontribs)

Except for the last one ("Fatal error") and a HTTP 500, none of the messages that you posted above are errors. There is no error when you go to special pages, but a warning that you or someone should update the code of "Description2".

We still need a full stacktrace of the fatal error, via $wgShowExceptionDetails as described on Manual:How to debug.

Bekircem (talkcontribs)

We need a full stacktrace for PHP errors or SQL errors? $wgShowExceptionDetails is already has true value in localsettings.php file. I also set display_startup_errors on with index.php. Here is my locatsettings file changes about that topic:

#PHP ERRORS

$wgShowExceptionDetails = true;;

$wgDebugToolbar = true;

$wgShowDebug = true;

$wgDevelopmentWarnings = true;

#SQL ERRORS

$wgShowSQLErrors = true;

$wgDebugDumpSql  = true;

error_reporting( -1 );

ini_set( 'display_errors', 1 );

I did everything as described on PHP errors and SQL errors part of the page. There is no error on the viki web page. Just i see very long debug-data on the bottom of the page. Must i look some error log or something like that?

Malyacko (talkcontribs)

You have a typo at the very end of your line:

$wgShowExceptionDetails = true;;

Bekircem (talkcontribs)

I fixed typo problem. And there no error seems yet. Nothing has changed.

Ciencia Al Poder (talkcontribs)

The debug log may give more info, but if you're unable to find hints to solve your problem you may post it in dpaste.org and post the link here so we can take a look (remove private information like cookies)

Bekircem (talkcontribs)
Ciencia Al Poder (talkcontribs)

Each request get logged, but of course you need to get the log of the request that causes the error (a password reset or registration).

Your request is "# Start request GET /Ana_Sayfa". A password reset should be a POST to the Special:Userlogin or similar. That's why your debug log is not useful.

Bekircem (talkcontribs)

Thanks for your explanations.

Here it is debug data for password reset page(Special:PasswordReset): https://dpaste.de/dXe9

Ciencia Al Poder (talkcontribs)

No, the log should be from the request that produces the error. You said the error happens when you submit the special:passwordreset form, not when you load it for the first time. Hence, the log should contain the POST request, not the GET one.

Bekircem (talkcontribs)
Ciencia Al Poder (talkcontribs)

That's OK, this is where the log would probably be more useful. If you were getting your error from the console log, yoi should enable a debug log file instead (see Manual:How to debug). Enable the debug log first and load a page, it should be created (if not check for permissions). Once you know the log can be created, go to the page before pressing the button that cause the error, delete the log, press the button, and then you'll have the log containing the request that causes the error, hopefully with useful information.

Bekircem (talkcontribs)

I am enabled debug log file too now.

$wgDebugLogFile = "/var/log/mediawiki/debug-{$wgDBname}.log";

I think I'm having a permission problem. Because in the var/log/mediawiki directory, there is no log file. Localsettings file users groups permisson seems serverpilot serverpilot now. How i fix permissions? Am i must give localsettingsfile.php file root permissions?

I fully understand what you say. Thanks for your great explanations.

Ciencia Al Poder (talkcontribs)

well, if you're not sure, you can set permissions to everybody (777) to the /var/log/mediawiki/ folder, and when the file gets created, you'll see what the correct owner is

Bekircem (talkcontribs)

Debug file created finally after set permissions 777. Can i share it here?

Edit: I removed some special informations and added with dpaste.org: removed

Ciencia Al Poder (talkcontribs)

I've removed the paste, because it contains private information (cookies and hashed passwords). Please reset your password on the wiki just in case.

The relevant code of the log is this:

Sending mail via PEAR::Mail
[fatal] [93b10efd] /%C3%96zel:ParolaS%C4%B1f%C4%B1rlama   ErrorException from line 264 of wiki/includes/exception/MWExceptionHandler.php: Fatal Error: Uncaught TypeError: Argument 1 passed to MWExceptionHandler::handleException() must be an instance of Exception, instance of Error given in wiki/includes/exception/MWExceptionHandler.php:153
Stack trace:
#0 [internal function]: MWExceptionHandler::handleException(Object(Error))
#1 {main}
  thrown
#0 [internal function]: MWExceptionHandler::handleFatalError()
#1 {main}

However, it doesn't provide any useful stack trace (no trace of the original exception). I've seen other similar reports and this is something that needs to be fixed in MediaWiki. Maybe the way to know what's the error here is to find MWExceptionHandler::handleException and remove the "Exception" type hint...

星耀晨曦 (talkcontribs)

@Bekircem, What version of PHP are you using?

Bekircem (talkcontribs)

What can we do for that?

My version is PHP 7.0.

星耀晨曦 (talkcontribs)

What version of MediaWiki are you using? Please note that only MediaWiki 1.27 and later is officially supported on PHP 7.

Bekircem (talkcontribs)

My Mediawiki version is 1.25.1. I did not know that. I am hosted my wiki on the Digital Ocean with Serverpilot, so i can change PHP version to 5.6 if it neccessary.

Mediawiki and PHP version mismatch could it be causing that problem? Also, i tried update my Mediawiki to 1.3 but it gives me error, after that i restored from my backup wiki.

Ciencia Al Poder (talkcontribs)

MediaWiki 1.25 doesn't support PHP7, and it's also outdated

Bekircem (talkcontribs)

Am i must upgrade Mediawiki 1.25 to 1.30 with PHP 5.6? I am tried to upgrade Mediawiki but after the upgrade index page is blank... So i restore from the backup.

星耀晨曦 (talkcontribs)

A blank page, there may be a HTTP 500 error. See also Manual:Upgrading to upgrade your wiki.

Reply to "Mediawiki mail settings for password reset and registration"