YunoHost-Apps / opensondage_ynh

OpenSondage for YunoHost
https://framadate.org/
GNU Affero General Public License v3.0
16 stars 14 forks source link

Cannot create poll, phpmailer error? #95

Open eauchat opened 7 months ago

eauchat commented 7 months ago

Context

Steps to reproduce

When creating a poll, everything's fine until I arrive to the last step and validate. The request results in a 500 error.

Nginx logs contain the following:

2024/01/30 22:22:30 [error] 1718162#1718162: *154687 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught PHPMailer\PHPMailer\Exception: SMTP Error: Could not connect to SMTP host. in /var/www/opensondage/vendor/phpmailer/phpmailer/src/PHPMailer.php:2157
Stack trace:
#0 /var/www/opensondage/vendor/phpmailer/phpmailer/src/PHPMailer.php(1981): PHPMailer\PHPMailer\PHPMailer->smtpConnect()
#1 /var/www/opensondage/vendor/phpmailer/phpmailer/src/PHPMailer.php(1653): PHPMailer\PHPMailer\PHPMailer->smtpSend()
#2 /var/www/opensondage/vendor/phpmailer/phpmailer/src/PHPMailer.php(1491): PHPMailer\PHPMailer\PHPMailer->postSend()
#3 /var/www/opensondage/app/classes/Framadate/Services/MailService.php(67): PHPMailer\PHPMailer\PHPMailer->send()
#4 /var/www/opensondage/create_date_poll.php(213): Framadate\Services\MailService->send()
#5 {main}
  thrown in /var/www/opensondage/vendor/phpmailer/phpmailer/src/PHPMailer.php on line 2157" while reading response header from upstream, client: XX.XXX.XX.XXX, server: domain.tld, request: "POST /create_date_poll.php HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php8.0-fpm-opensondage.sock:", host: "domain.tld", referrer: "https://domain.tld/create_date_poll.php"

Anyone has an idea of what may be going on? Thanks for any suggestion :)

dupdupf commented 7 months ago

Hye

I'm in the exact same situation, have you found a solution since then?

eauchat commented 7 months ago

Nope, not yet :/

alexAubin commented 7 months ago

Discussion ongoing in https://forum.yunohost.org/t/new-survey-after-new-install-of-opensondage-delivers-only-empty-page/28055

isAAAc commented 6 months ago

same error here, old install failed, a fresh reinstall gives the same

root@krashboyz:/var/log# yunohost app info opensondage
description: Service for planning an appointment or making a decision quickly and easily
domain_path: date.krashboyz.org/
name: OpenSondage
version: 1.1.19~ynh3
root@krashboyz:/var/log# yunohost --version
yunohost: 
  repo: stable
  version: 11.2.10.3
yunohost-admin: 
  repo: stable
  version: 11.2.4.1
moulinette: 
  repo: stable
  version: 11.2
ssowat: 
  repo: stable
  version: 11.2
2024/03/12 17:02:05 [error] 597507#597507: *3033751 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught PHPMailer\PHPMailer\Exception: SMTP Error: Could not authenticate. in /var/www/opensondage/vendor/phpmailer/phpmailer/src/PHPMailer.php:2170
Stack trace:
#0 /var/www/opensondage/vendor/phpmailer/phpmailer/src/PHPMailer.php(1981): PHPMailer\PHPMailer\PHPMailer->smtpConnect()
#1 /var/www/opensondage/vendor/phpmailer/phpmailer/src/PHPMailer.php(1653): PHPMailer\PHPMailer\PHPMailer->smtpSend()
#2 /var/www/opensondage/vendor/phpmailer/phpmailer/src/PHPMailer.php(1491): PHPMailer\PHPMailer\PHPMailer->postSend()
#3 /var/www/opensondage/app/classes/Framadate/Services/MailService.php(67): PHPMailer\PHPMailer\PHPMailer->send()
#4 /var/www/opensondage/create_date_poll.php(213): Framadate\Services\MailService->send()
#5 {main}
  thrown in /var/www/opensondage/vendor/phpmailer/phpmailer/src/PHPMailer.php on line 2170" while reading response header from upstream, client: 2001:67c:288:2::235, server: date.krashboyz.org, request: "POST /create_date_poll.php HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php8.2-fpm-opensondage.sock:", host: "date.krashboyz.org", referrer: "https://date.krashboyz.org/create_date_poll.php"

same error if i don't use a dedicated subdomain but the main domain name of the ynh:

2024/03/12 17:22:13 [error] 611042#611042: *3038095 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught PHPMailer\PHPMailer\Exception: SMTP Error: Could not authenticate. in /var/www/opensondage/vendor/phpmailer/phpmailer/src/PHPMailer.php:2170
Stack trace:
#0 /var/www/opensondage/vendor/phpmailer/phpmailer/src/PHPMailer.php(1981): PHPMailer\PHPMailer\PHPMailer->smtpConnect()
#1 /var/www/opensondage/vendor/phpmailer/phpmailer/src/PHPMailer.php(1653): PHPMailer\PHPMailer\PHPMailer->smtpSend()
#2 /var/www/opensondage/vendor/phpmailer/phpmailer/src/PHPMailer.php(1491): PHPMailer\PHPMailer\PHPMailer->postSend()
#3 /var/www/opensondage/app/classes/Framadate/Services/MailService.php(67): PHPMailer\PHPMailer\PHPMailer->send()
#4 /var/www/opensondage/create_date_poll.php(213): Framadate\Services\MailService->send()
#5 {main}
  thrown in /var/www/opensondage/vendor/phpmailer/phpmailer/src/PHPMailer.php on line 2170" while reading response header from upstream, client: 2001:67c:288:2::235, server: krashboyz.org, request: "POST /date/create_date_poll.php HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php8.2-fpm-opensondage.sock:", host: "krashboyz.org", referrer: "https://krashboyz.org/date/create_date_poll.php"
asandikci commented 5 months ago

I have same error with clean latest install and latest PR didn't worked for me

rodinux commented 5 months ago

I have same error !! I haven't realize before !!

rodinux commented 5 months ago

for me changing the user admin_user the mail with opensondage have resolve the issue

// Database administrator email
const ADRESSEMAILADMIN = 'opensondage@sondage.domain.tld';

and restart php8.2-fpm

yunohost service restart php8.2-fpm
zamentur commented 4 months ago

Important: in more of this last PR, you have to used a /etc/resolv.conf with nameserver 127.0.0.1 cause opensondage user is only allowed to login on local ip ::1 and 127.0.0.1/24 ...

lodewijkloos commented 2 months ago

I was able to work around ths in three ways:

  1. By disabling mail at all in Open Sondage:
    # edit /var/www/opensondage/app/inc/config.php
    use_smtp = false, # use_smpt setting basically meas if Open Sondage should use mail at all
  2. By editing config and code to allow extra SMTP options in order to allow mailing without checking for certificates, this can be done safely if using localhost to mail
    
    # edit /var/www/opensondage/app/inc/config.php 
    # add 'options' key
    'smtp_options' => [
    'host' => 'localhost',
    'auth' => true, 
    'username' => 'opensondage', 
    'password' => 'XXXXXXX',
    'secure' => 'tls', 
    'port' => 25,
    'options' => [
        'ssl' => [
            'verify_peer' => false,
            'verify_peer_name' => false,
            'allow_self_signed' => true,
        ],
    ],
    ],

edit /var/www/opensondage/app/classes/Framadate/Services/MailService.php

add 'options' to available options

$available_options = [ 'host' => 'Host', 'auth' => 'SMTPAuth', 'authtype' => 'AuthType', 'username' => 'Username', 'password' => 'Password', 'secure' => 'SMTPSecure', 'port' => 'Port', 'options' => 'SMTPOptions', ];

3. By using mail without SMTP which just works on Yunohost, which will then mail as local 'opensondage' Linux user 

edit /var/www/opensondage/app/classes/Framadate/Services/MailService.php

comment out the function that configures SMTP

//$this->configureMailer($mail);



I would say a good fix would require the upstream Framadate code to add some extra options:
* `use_mail` (instead of `use_smtp`)
* `use_smtp` (send mail with or without SMTP)
* `options` (extra options in case of sending with SMTP)

And a change to to the default config of Yunohost Open Sondage
isAAAc commented 2 months ago

any news from upstream ?

isAAAc commented 2 months ago

works for me:

By using mail without SMTP which just works on Yunohost, which will then mail as local 'opensondage' Linux user

# edit /var/www/opensondage/app/classes/Framadate/Services/MailService.php
# comment out the function that configures SMTP
//$this->configureMailer($mail);

& restart php

yunohost service restart php8.2-fpm
dupdupf commented 2 months ago

Work for me, thank you !!

KaiMartin commented 3 weeks ago

I chose method 3 (comment SMTP initialization. Result: 1) The poll gets created. Votes can be cast :-) 2) Emails are supposedly sent ("Your reminder has been successfully sent!") But unfortunately nothing arrives in my mailbox. :-|