YunoHost-Apps / 2FAuth_ynh

2FAuth package for YunoHost
https://docs.2fauth.app/
GNU General Public License v3.0
3 stars 5 forks source link

.env file: default email settings result in no emails being sent #72

Open cgKAF opened 5 months ago

cgKAF commented 5 months ago

Edit: I have learned since writing this -- by reading through the wiki for Vaultwarden on Github -- that these criteria can be provided by a third-party service such as MailJet.com. If you've already got this set up in Yunohost then I guess you can use your own SMTP server and so on, but for most people, especially the non-technical, third-party services are much easier. So although this isn't strictly a bug, it would be nice if all this were explained in 2FAuth or in its entry in the Yunohost Apps catalogue somewhere.


Describe the bug

The default email settings in the .env file as installed by Yunohost result in no email being sent when in 2FAuth --> Admin --> "App setup" tab --> "Email configuration settings". When testing this by requesting a password reset email to be sent, the error message that appears says:

An error occured:

Unable to connect with STARTTLS: stream_socket_enable_crypto(): Peer certificate 

This message occurs regardless of how I change the values in the "Mail settings" in the .env file. If I do tweak things, this extra line appears: CN=`domain.tld' did not match (where "domain.tld" is my ynh.fr domain).

The default mail settings in .env are as follows:

#### Mail settings ####

# Refer your email provider documentation to configure your mail settings
# Set a value for every available setting to avoid issue

MAIL_DRIVER=smtp
MAIL_HOST=localhost
MAIL_PORT=587
MAIL_FROM=2fauth@auth.domain.tld
MAIL_USERNAME=2fauth
MAIL_PASSWORD=e16a065772f852d904dd34ee
MAIL_ENCRYPTION=starttls
#MAIL_FROM_NAME=null
#MAIL_FROM_ADDRESS=null

Context

Steps to reproduce

Expected behaviour

A password reset email or a test email to be received.

Logs

The Yunohost logs (webadmin --> Tools --> Logs) say nothing about the email issue.

The logs in /www/var/2fauth/storage/logs list 1 to ~70 entries, given below (domain.tld refers to my ynh.fr domain):

[2024-06-06 16:06:14] local.ERROR: Unable to connect with STARTTLS: stream_socket_enable_crypto(): Peer certificate CN=`domain.tld' did not match expected CN=`localhost' {"exception":"[object] (Symfony\\Component\\Mailer\\Exception\\TransportException(code: 0): Unable to connect with STARTTLS: stream_socket_enable_crypto(): Peer certificate CN=`domain.tld' did not match expected CN=`localhost' at /var/www/2fauth/vendor/symfony/mailer/Transport/Smtp/Stream/SocketStream.php:171) [stacktrace] #0 [internal function]: Symfony\\Component\\Mailer\\Transport\\Smtp\\Stream\\SocketStream->Symfony\\Component\\Mailer\\Transport\\Smtp\\Stream\\{closure}() #1 /var/www/2fauth/vendor/symfony/mailer/Transport/Smtp/Stream/SocketStream.php(174): stream_socket_enable_crypto() #2 /var/www/2fauth/vendor/symfony/mailer/Transport/Smtp/EsmtpTransport.php(152): Symfony\\Component\\Mailer\\Transport\\Smtp\\Stream\\SocketStream->startTLS() #3 /var/www/2fauth/vendor/symfony/mailer/Transport/Smtp/EsmtpTransport.php(118): Symfony\\Component\\Mailer\\Transport\\Smtp\\EsmtpTransport->doEhloCommand() #4 /var/www/2fauth/vendor/symfony/mailer/Transport/Smtp/SmtpTransport.php(254): Symfony\\Component\\Mailer\\Transport\\Smtp\\EsmtpTransport->executeCommand() #5 /var/www/2fauth/vendor/symfony/mailer/Transport/Smtp/SmtpTransport.php(277): Symfony\\Component\\Mailer\\Transport\\Smtp\\SmtpTransport->doHeloCommand() #6 /var/www/2fauth/vendor/symfony/mailer/Transport/Smtp/SmtpTransport.php(209): Symfony\\Component\\Mailer\\Transport\\Smtp\\SmtpTransport->start() #7 /var/www/2fauth/vendor/symfony/mailer/Transport/AbstractTransport.php(69): Symfony\\Component\\Mailer\\Transport\\Smtp\\SmtpTransport->doSend() #8 /var/www/2fauth/vendor/symfony/mailer/Transport/Smtp/SmtpTransport.php(137): Symfony\\Component\\Mailer\\Transport\\AbstractTransport->send() #9 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(573): Symfony\\Component\\Mailer\\Transport\\Smtp\\SmtpTransport->send() #10 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(335): Illuminate\\Mail\\Mailer->sendSymfonyMessage() #11 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Notifications/Channels/MailChannel.php(66): Illuminate\\Mail\\Mailer->send() #12 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(148): Illuminate\\Notifications\\Channels\\MailChannel->send() #13 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(106): Illuminate\\Notifications\\NotificationSender->sendToNotifiable() #14 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Support/Traits/Localizable.php(29): Illuminate\\Notifications\\NotificationSender->Illuminate\\Notifications\\{closure}() #15 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(101): Illuminate\\Notifications\\NotificationSender->withLocale() #16 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(79): Illuminate\\Notifications\\NotificationSender->sendNow() #17 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Notifications/ChannelManager.php(39): Illuminate\\Notifications\\NotificationSender->send() #18 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Notifications/RoutesNotifications.php(18): Illuminate\\Notifications\\ChannelManager->send() #19 /var/www/2fauth/app/Models/User.php(178): App\\Models\\User->notify() #20 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBroker.php(72): App\\Models\\User->sendPasswordResetNotification() #21 /var/www/2fauth/vendor/laravel/ui/auth-backend/SendsPasswordResetEmails.php(35): Illuminate\\Auth\\Passwords\\PasswordBroker->sendResetLink() #22 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): App\\Http\\Controllers\\Auth\\ForgotPasswordController->sendResetLinkEmail() #23 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(43): Illuminate\\Routing\\Controller->callAction() #24 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Routing/Route.php(259): Illuminate\\Routing\\ControllerDispatcher->dispatch() #25 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Routing/Route.php(205): Illuminate\\Routing\\Route->runController() #26 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Routing/Router.php(806): Illuminate\\Routing\\Route->run() #27 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(144): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}() #28 /var/www/2fauth/app/Http/Middleware/RejectIfDemoMode.php(25): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() #29 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): App\\Http\\Middleware\\RejectIfDemoMode->handle() #30 /var/www/2fauth/app/Http/Middleware/RejectIfAuthenticated.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() #31 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): App\\Http\\Middleware\\RejectIfAuthenticated->handle() #32 /var/www/2fauth/vendor/laravel/passport/src/Http/Middleware/CreateFreshApiToken.php(63): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() #33 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Laravel\\Passport\\Http\\Middleware\\CreateFreshApiToken->handle() #34 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() #35 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle() #36 /var/www/2fauth/app/Http/Middleware/SetLanguage.php(68): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() #37 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): App\\Http\\Middleware\\SetLanguage->handle() #38 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() #39 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle() #40 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() #41 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest() #42 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Session\\Middleware\\StartSession->handle() #43 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() #44 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle() #45 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() #46 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle() #47 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(119): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() #48 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Routing/Router.php(805): Illuminate\\Pipeline\\Pipeline->then() #49 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Routing/Router.php(784): Illuminate\\Routing\\Router->runRouteWithinStack() #50 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Routing/Router.php(748): Illuminate\\Routing\\Router->runRoute() #51 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Routing/Router.php(737): Illuminate\\Routing\\Router->dispatchToRoute() #52 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(200): Illuminate\\Routing\\Router->dispatch() #53 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(144): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}() #54 /var/www/2fauth/app/Http/Middleware/ForceJsonResponse.php(19): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() #55 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): App\\Http\\Middleware\\ForceJsonResponse->handle() #56 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() #57 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle() #58 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle() #59 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() #60 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle() #61 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle() #62 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() #63 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle() #64 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(99): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() #65 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle() #66 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() #67 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Http\\Middleware\\HandleCors->handle() #68 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(39): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() #69 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Http\\Middleware\\TrustProxies->handle() #70 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(119): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() #71 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(175): Illuminate\\Pipeline\\Pipeline->then() #72 /var/www/2fauth/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(144): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter() #73 /var/www/2fauth/public/index.php(51): Illuminate\\Foundation\\Http\\Kernel->handle() #74 {main} "}
CodeShakingSheep commented 1 month ago

Same.