chamilo / chamilo-lms

Chamilo is a learning management system focused on ease of use and accessibility
https://chamilo.org
GNU General Public License v3.0
807 stars 481 forks source link

Chamilo 1.11.12 not sending Mails #3625

Open atarallo opened 4 years ago

atarallo commented 4 years ago

Description We're testing Chamilo 1.11.12 on Centos 8.2 with PHP 7.2. The SMTP configuration was copied exactly from our production site. Our production site runs Chamilo 1.11.10 on Centos 7.8 with PHP 7.1. On both cases we use SMTP as mail transport, connecting to our corporate email server.

We tested Conectivity (Telnet) and we can send authenticated emails from the comand line of the test server. We discovered on the logs of php/fpm te following errors:

 _[DD-Nov-2020 HH:MM:ss Timezone] ERROR: mail not sent to user, surname (user@domain)  because of SMTP connect() failed. http://github.com/PHPMailer/wiki/Troubleshooting_

To Reproduce Steps to reproduce the behavior:

  1. Create a new Course, an email notification should be sent

  2. Create a new Announcement.

Expected behavior An email should be received when courses or announces are created

Desktop (please complete the following information):

**Server

Additional context We've comparing both production and testing. Notices that PHPmailer is present, but in different paths of the installation of chamilo. It seems to us that is not the same version or different/missing files

atarallo commented 4 years ago

We did further investigation. And managed to get mail notifications working.

On file: ${CHAMILO_ROOT_DIR}/vendor/phpmailer/phpmailer/src/PHPMailer.php changed to:

                             public $SMTPAutoTLS = false;  // It was set true

On file ${CHAMILO_ROOT_DIR}/app/config/mail.conf.php we did some changes, was no taking the name and email of the administrator to send notifications.

$platform_email['SMTP_FROM_EMAIL'] = (isset($administrator['email']) ? $administrator['email'] : 'chamiloadmin@mydomain.com');

$platform_email['SMTP_FROM_NAME'] = (isset($administrator['name']) ? $administrator['name'] : ' Chamilo administrator NAME');

We're willling to help to fix this bugs. We invested a lot of time investigating this. And deep dived on chamilo code, more than we intended to.

spacecabbie commented 3 years ago

Hi thanks for the feedback but I think you missed this entry in the documents: https://docs.chamilo.org/admin-guide/appendix/frequently_asked_questions/sending_e-mails_from_the_platform_doesnt_work So If you are using a external SMTP server then you need to set up its settings like explain above editing in vendor is not recommended since it wil be overwritten with updates. If you use a local smtp server or sendmail then this is quite odd and I recommend to look into /var/log/exim/mainlog

ywarnier commented 3 years ago

@atarallo we've updated the (previously very old) version of PHPMailer in 1.11.12, which might have caused the issue on your server. I do agree with @spacecabbie that there is a chance your SMTP_AUTH setting in mail.conf.php was set to 1 although the SMTP server did not require authentication and did not use TLS. Is there any chance you could confirm that in the next few days so we can move forward with finding a better config for all?

SMTPAutoTLS is only used once in the PHPMailer.php library, on this line:

                    //Automatically enable TLS encryption if:
                    // * it's not disabled
                    // * we have openssl extension
                    // * we are not already using SSL
                    // * the server offers STARTTLS
                    if ($this->SMTPAutoTLS && $sslext && 'ssl' !== $secure && $this->smtp->getServerExt('STARTTLS')) {
                        $tls = true;
                    }

Which only sets $tls to true if $secure is different from ssl, $secure being obtained from $this->SMTPSecure which is defined (through api_mail_html() in Chamilo) as the $platform_email['SMTP_SECURE'] setting from mail.conf.php.

So in short, if you set $platform_email['SMTP_SECURE'] to anything else than ssl, then it considers it is tls, not without first checking if the SMTP server answers something about STARTTLS...

Anyway, I think there could be something added to the default mail.conf.php as extra documentation, but I would need more information about the exact configuration of your own mail.conf.php in order to add the right documentation.

atarallo commented 3 years ago

Hi !!!

As stated before, the file mail.conf.php was copied from the production server. The$platform_email['SMTP_SECURE'] is commented. This puzzled us, the onsite admin further investigated and found the "hack" of changing the value in PHPMailer to make mails go out.

We also found that $platform_email['SMTP_FROM_EMAIL'] does not take $administrator[´email] even though its defined, Same situation with $platform_email['SMTP_FROM_MAIL'].

This is not the first bug we found when installing this version of chamillo. We found duplicated functions as commented in bug #3523

Feel free to ask if need further details, I have to forward to the site admins.

R0sy commented 3 years ago

Hello, I have the same problem, could you help me by indicating how to solve it, in advance thank you very much for the contribution.

atarallo commented 3 years ago

Hi!!!

On previous mails of this thread you'll find how we solved it. Be warned: this solved our problem, might not solve yours.

Andrés

El lun, 17 may 2021 a las 19:39, R0sy @.***>) escribió:

Hello, I have the same problem, could you help me by indicating how to solve it, in advance thank you very much for the contribution.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/chamilo/chamilo-lms/issues/3625#issuecomment-842688176, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE4DM3R7NTSEG6PKSRKE6GTTOGLKDANCNFSM4TTOJFMQ .

R0sy commented 3 years ago

Good morning, in my case I have the same problem regarding the sending of notifications by email, since it only sends them to the administrator's email but if it is tried with other users, the message does not arrive, the version of chamilo installed is 1.11. 12 on a server with Ubuntu operating systems. It doesn't even send the username and password. I hope you can help me with my problem, below I share the log that appears when I try to send a message:

May 18 16:20:01 sm-msp-queue [8824]: My unqualified host name (ip-192-168-10-24) unknown; sleeping for retry May 18 16:21:01 sm-msp-queue [8824]: unable to qualify my own domain name (ip-192-168-10-24) - using short name

Gazzxy commented 3 years ago

can there just be a way to Edit the mailer settings in the admin page? this is literally the only thing we run on our server where I have to go rummaging around for files to have it maybe work and its highly frustrating.

ywarnier commented 3 years ago

@Gazzxy this is in the roadmap for future releases. It's annoying for us too, but the files management, the languages management and the fact that we don't accept structural changes between minor versions has slowed this down considerably.

Gazzxy commented 3 years ago

heh fair enough... am at the stage where it looks right... sounds right.. but don't think its working.. and well its too hot in this office so ran outa the ability to care for today :(