salesagility / SuiteCRM

SuiteCRM - Open source CRM for the world
https://www.suitecrm.com
GNU Affero General Public License v3.0
4.45k stars 2.08k forks source link

Can't reply to emails #10124

Open Kapustlo opened 1 year ago

Kapustlo commented 1 year ago

Issue

500 error when clicking on the "reply" button on an email page.

Expected Behavior

200 ok response rendering the reply page.

Actual Behavior

500 error. Error from logs:

PHP Fatal error:  Uncaught Error: Call to a member function getAddresses() on null in /bitnami/suitecrm/vendor/javanile/php-imap2/src/Polyfill.php:73
Stack trace:
#0 /bitnami/suitecrm/vendor/javanile/php-imap2/bootstrap.php(1515): Javanile\Imap2\Polyfill::rfc822ParseHeaders()
#1 /bitnami/suitecrm/vendor/javanile/php-imap2/bootstrap.php(1521): imap_rfc822_parse_headers()
#2 /bitnami/suitecrm/include/Imap/Imap2Handler.php(874): imap2_rfc822_parse_headers()
#3 /bitnami/suitecrm/modules/InboundEmail/InboundEmail.php(5387): Imap2Handler->rfc822ParseHeaders()
#4 /bitnami/suitecrm/modules/Emails/EmailsController.php(806): InboundEmail->returnImportedEmail()
#5 /bitnami/suitecrm/modules/Emails/EmailsController.php(654): EmailsController->composeBean()
#6 /bitnami/suitecrm/include/MVC/Controller/SugarController.php(522): EmailsController->action_ReplyTo()
#7 /bitnami/suitecrm/include/MVC/Controller/SugarController.php(491): SugarController->do_action()
#8 /bitnami/suitecrm/include/MVC/Controller/SugarController.php(465): SugarController->handle_action()
#9 /bitnami/suitecrm/include/MVC/Controller/SugarController.php(361): SugarController->process()
#10 /bitnami/suitecrm/include/MVC/SugarApplication.php(101): SugarController->execute()
#11 /bitnami/suitecrm/index.php(52): SugarApplication->execute()
#12 {main}
  thrown in /bitnami/suitecrm/vendor/javanile/php-imap2/src/Polyfill.php on line 73

The problem seems to be in the rfc822ParseHeaders function that's in the include/Imap/Imap2Handler.php file. For some reason "From:" header that's in the $headers is missing the email address part there only containing the sender's name but the "Reply-To" email is fine. For example: From: JohnDoe Reply-To: john.doe@example.com

Steps to Reproduce

  1. Create an inbound email account with corporate email
  2. Load inbound emails
  3. Reply to an email

Your Environment

PHP 8.0.29 (cli) (built: Jul 24 2023 21:31:00) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.29, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.29, Copyright (c), by Zend Technologies
pgorod commented 1 year ago

You didn't fill in your PHP version...

Make sure it's within the Matrix: https://docs.suitecrm.com/admin/compatibility-matrix/

Kapustlo commented 1 year ago

@pgorod I use the official Docker image, I'm not sure what PHP version is there. I'll try to check

Kapustlo commented 1 year ago

docker exec -it suitecrm php --version:

PHP 8.0.29 (cli) (built: Jul 24 2023 21:31:00) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.29, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.29, Copyright (c), by Zend Technologies
Kapustlo commented 1 year ago

Actually after debugging a little bit more, all keys in the $ret (rfc822ParseHeaders) look fine, including the "From" header but I'm not sure where to look, so I'll give some more information if needed