Describe the issue or problem
Encountered an error on a site I maintain whereby, when clicking on reset password button, the mentioned error occurs. The expected behavior is that the system should send an email with a link to the user to reset their password.
Steps I took leading up to the issue
- Click on login
- Click on ‘forgot your password?’
- Enter existing user’s email
- Click reset password and the error occurs
What application are you using?
OJS 3.4.0-4
Additional information
I was running OJS 3.4.0-3 when I first encountered this error. I then upgraded to 3.4.0-4 hoping the error would go away but it persisted even in 3.4.0-4
The error is shown below
Fatal error: Uncaught Symfony\Component\Mime\Exception\LogicException: An email must have a "From" or a "Sender" header. in .../ojs/lib/pkp/lib/vendor/symfony/mime/Message.php:132 Stack trace: #0 .../ojs/lib/pkp/lib/vendor/symfony/mime/Email.php(417): Symfony\Component\Mime\Message->ensureValidity() #1 .../ojs/lib/pkp/lib/vendor/symfony/mailer/SentMessage.php(33): Symfony\Component\Mime\Email->ensureValidity() #2 .../ojs/lib/pkp/lib/vendor/symfony/mailer/Transport/AbstractTransport.php(68): Symfony\Component\Mailer\SentMessage->__construct(Object(Symfony\Component\Mime\Email), Object(Symfony\Component\Mailer\DelayedEnvelope)) #3 .../ojs/lib/pkp/lib/vendor/symfony/mailer/Transport/Smtp/SmtpTransport.php(136): Symfony\Component\Mailer\Transport\AbstractTransport->send(Object(Symfony\Component\Mime\Email), Object(Symfony\Component\Mailer\DelayedEnvelope)) #4 .../ojs/lib/pkp/classes/mail/Mailer.php(155): Symfony\Component\Mailer\Transport\Smtp\SmtpTransport->send(Object(Symfony\Component\Mime\Email), Object(Symfony\Component\Mailer\DelayedEnvelope)) #5 .../ojs/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(287): PKP\mail\Mailer->sendSymfonyMessage(Object(Symfony\Component\Mime\Email)) #6 .../ojs/lib/pkp/classes/mail/Mailer.php(120): Illuminate\Mail\Mailer->send('We have receive...', Array, Object(Closure)) #7 .../ojs/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Mail/Mailable.php(204): PKP\mail\Mailer->send('We have receive...', Array, Object(Closure)) #8 .../ojs/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Support/Traits/Localizable.php(19): Illuminate\Mail\Mailable->Illuminate\Mail\{closure}() #9 .../ojs/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Mail/Mailable.php(197): Illuminate\Mail\Mailable->withLocale(NULL, Object(Closure)) #10 .../ojs/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(309): Illuminate\Mail\Mailable->send(Object(PKP\mail\Mailer)) #11 .../ojs/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(253): Illuminate\Mail\Mailer->sendMailable(Object(PKP\mail\mailables\PasswordResetRequested)) #12 .../ojs/lib/pkp/classes/mail/Mailer.php(120): Illuminate\Mail\Mailer->send(Object(PKP\mail\mailables\PasswordResetRequested), Array, NULL) #13 .../ojs/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Mail/MailManager.php(554): PKP\mail\Mailer->send(Object(PKP\mail\mailables\PasswordResetRequested)) #14 .../ojs/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(338): Illuminate\Mail\MailManager->__call('send', Array) #15 .../ojs/lib/pkp/pages/login/LoginHandler.php(253): Illuminate\Support\Facades\Facade::__callStatic('send', Array) #16 [internal function]: PKP\pages\login\LoginHandler->requestResetPassword(Array, Object(APP\core\Request)) #17 .../ojs/lib/pkp/classes/core/PKPRouter.php(334): call_user_func(Array, Array, Object(APP\core\Request)) #18 .../ojs/lib/pkp/classes/core/PKPPageRouter.php(277): PKP\core\PKPRouter->_authorizeInitializeAndCallRequest(Array, Object(APP\core\Request), Array, false) #19 .../ojs/lib/pkp/classes/core/Dispatcher.php(165): PKP\core\PKPPageRouter->route(Object(APP\core\Request)) #20 .../ojs/lib/pkp/classes/core/PKPApplication.php(388): PKP\core\Dispatcher->dispatch(Object(APP\core\Request)) #21 .../ojs/index.php(21): PKP\core\PKPApplication->execute() #22 {main} thrown in .../ojs/lib/pkp/lib/vendor/symfony/mime/Message.php on line 132
Proposed Solution
I am not sure if other OJS users have encountered this error but the solution I have implemented is by making the following change in lib/pkp/pages/login/LoginHandler.php
Use $context->getContactEmail()
and $context->getContactName()
instead of using $site->getLocalizedContactEmail()
and $site->getLocalizedContactName()
as shown below