snipe-it icon indicating copy to clipboard operation
snipe-it copied to clipboard

SMTP not working - Mail could not be sent - no app logs

Open YoBii opened this issue 1 year ago • 10 comments

Debug mode

Describe the bug

Test mail returns Mail could not be sent. No additional error message provided. Check your mail settings and your app log.

However application log (storage/logs/laravel.log) (or log tab in debug panel) doesn't show anything.

Reproduction steps

  1. Set mail options in env file
  2. (perform php artisan cache:clear and php artisan config:clear)
  3. Use test mail button

Expected behavior

I expect test mail and sending mail in general to work.

Screenshots

image

Snipe-IT Version

v6.2.3 build 11936 (gb47e734b3)

Operating System

Debian 11 (bullseye)

Web Server

apache2

PHP Version

7.4.33

Operating System

Windows

Browser

Firefox

Version

119

Device

No response

Operating System

No response

Browser

No response

Version

No response

Error messages

[2023-11-10 13:45:59] production.ERROR: Your APP_URL in your .env is misconfigured - it is: inventory.sub.domain.com. Many things will work strangely unless you fix it.
[2023-11-10 13:45:59] production.ERROR: Your APP_URL in your .env is misconfigured - it is: inventory.sub.domain.com. Many things will work strangely unless you fix it.
[2023-11-10 13:45:59] production.ERROR: Your APP_URL in your .env is misconfigured - it is: inventory.sub.domain.com. Many things will work strangely unless you fix it.
[2023-11-10 13:45:59] production.ERROR: Your APP_URL in your .env is misconfigured - it is: inventory.sub.domain.com. Many things will work strangely unless you fix it.
[2023-11-10 13:46:00] production.ERROR: Your APP_URL in your .env is misconfigured - it is: inventory.sub.domain.com. Many things will work strangely unless you fix it.
[2023-11-10 13:46:32] production.ERROR: Your APP_URL in your .env is misconfigured - it is: inventory.sub.domain.com. Many things will work strangely unless you fix it.
[2023-11-10 13:46:34] production.ERROR: Your APP_URL in your .env is misconfigured - it is: inventory.sub.domain.com. Many things will work strangely unless you fix it.
[2023-11-10 13:56:18] production.ERROR: Your APP_URL in your .env is misconfigured - it is: inventory.sub.domain.com. Many things will work strangely unless you fix it.
[2023-11-13 10:14:39] production.ERROR: Error: Class 'Laravel\Socialite\SocialiteServiceProvider' not found in /var/www/html/snipe-it/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepos
itory.php:208
Stack trace:
#0 /var/www/html/snipe-it/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php(144): Illuminate\Foundation\ProviderRepository->createProvider()
#1 /var/www/html/snipe-it/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php(61): Illuminate\Foundation\ProviderRepository->compileManifest()
#2 /var/www/html/snipe-it/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(659): Illuminate\Foundation\ProviderRepository->load()
#3 /var/www/html/snipe-it/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterProviders.php(17): Illuminate\Foundation\Application->registerConfiguredProviders()
#4 /var/www/html/snipe-it/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(237): Illuminate\Foundation\Bootstrap\RegisterProviders->bootstrap()
#5 /var/www/html/snipe-it/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(310): Illuminate\Foundation\Application->bootstrapWith()
#6 /var/www/html/snipe-it/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(127): Illuminate\Foundation\Console\Kernel->bootstrap()
#7 /var/www/html/snipe-it/artisan(35): Illuminate\Foundation\Console\Kernel->handle()
#8 {main}

Additional context

Laravel: 8.83.27 DB: mysql SELinux: disabled Context: Application has been used in production for some time. Mail was always set to log as I didn't need it. Things have changed - now I want mail to work.

Unfortunately I can't get a working setup of SMTP in snipe-it. Test mail returns Mail could not be sent. No additional error message provided. Check your mail settings and your app log.

However nothing is printed to the application log (storage/logs/laravel.log) (or log tab in debug panel). I provided error messages from the log but I think those were unrelated and I was able to fix both of them. More details on this below. Point is, these were the only two types of errors in the log. Nothing else. Nothing about mail specifically.

.env These are my mail settings. I am trying to use an SMTP relay account on Office 365. This works for all other applications I am hosting. I double checked the credentials.

MAIL_DRIVER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=redacted
MAIL_ENCRYPTION=null
[email protected]
MAIL_FROM_NAME='Snipe-IT'
[email protected]
MAIL_REPLYTO_NAME='Snipe-IT'
MAIL_AUTO_EMBED_METHOD='attachment'

I also tried setting encryption to tls (btw it would be great if environment options like these were documented. I could only find null in https://snipe-it.readme.io/docs/configuration)

Networking As I am behind a firewall I tried to connect to the mail server on the specified port using telnet from the host running snipe-it. It works just fine so it's not a networking issue (I am running other applications that are using SMTP in the same network as well..)

Upgrade Today I updated SnipeIT and could do so successfully after solving some permission problems with composer. It wasn't able to write to /var/www/.cache and apparently that was related to the socialite error in the log. After solving this upgrade.php printed that all permissions check out. I carefully checked the output of the script for any errors during upgrade. Seems fine. However the problem with mail persists.

Previously Before all of this when I tried setting up mail the first time I noticed my lavarel.log was flooded with

[2023-11-10 13:36:17] production.ERROR: Your APP_URL in your .env is misconfigured - it is: inventory.sub.domain.com. Many things will work strangely unless you fix it.

I solved this by prepending the APP URL with https://. Error never reoccurred since then but that didn't change anything about mail not working. Just thought I mention this.

Summary Test mail is returning 500 internal server error and nothing is printed to lavarel.log.

Please let me know when there's anything missing I can provide.

Thanks for reading and all your work.

YoBii avatar Nov 13 '23 12:11 YoBii

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

welcome[bot] avatar Nov 13 '23 12:11 welcome[bot]

Are you running SELinux? https://snipe-it.readme.io/docs/linuxosx#notes-on-selinux

Snipe-IT Documentation
Setting up a web server can sound daunting for folks who don't normally do that kind of thing. This guide will help you walk through the configuration for Apache or Nginx on Linux and OSX.Using ApacheThe most common setup for Snipe-IT on a linux server is to use Apache, so if you're not sure what to...

snipe avatar Nov 23 '23 17:11 snipe

As stated above I am not running SELinux. Debian doesn't come with it and it wasn't installed manually either. I double checked this now.

YoBii avatar Nov 27 '23 12:11 YoBii

Can you provide a full stack trace of the mail error? The one above only includes the socialite issue.

snipe avatar Dec 05 '23 14:12 snipe

Sorry but I can't. Nothing is written to laravel.log when Send Test fails.

A while back I assumed this was a permission problem but I think I ruled that out. When I purposefully put a wrong APP_URL that will produce errors in laravel.log. So logging seems to work in general.

EDIT: The last entry in laravel.log is from 2023-11-13. I have APP_DEBUG=true in my .env file.

YoBii avatar Dec 13 '23 12:12 YoBii

We observed similar issue at Version v6.2.2 - build 11714 (master) on top of Ubuntu 22.04.3 LTS (Jammy Jellyfish) with all patches applied as of 2023-01-22. SMTP is set to smtp.gmail.com (Google Workspace Enterprise) with the email account fully tested.

esmsesms avatar Jan 23 '24 00:01 esmsesms

Having the same issue where using the IIS server.

yashas-tantri avatar Feb 23 '24 05:02 yashas-tantri

Can we provide any more info to help solve this issue?

YoBii avatar Apr 12 '24 08:04 YoBii

Experiencing the same issue with Docker running on Ubuntu 22.04.4. (Office 365).

/edit: Strangely when using port 25 it works! (took me a few hours until I've came to the conclusion)

In my case I'm using office 365 with a setup relay.

bibz0r avatar May 02 '24 09:05 bibz0r

@bibz0r hmm, I tried port 25 without success. Would you mind sharing you .env / mail configuration or check if mine is different from yours (you can see mine in the initial post)?

YoBii avatar May 06 '24 22:05 YoBii

I have the similar error. Using the latest Docker-Image. In the docker-env I have my settings. They are not working, even If I use MAIL_* from here or MAIL_ENV_* from here

Weird is that in the error-message it seems like none of my ENV-Vars is used as there is one dummy-entry (your_email_username):

[2024-05-30 15:28:57] production.ERROR: Failed to authenticate on SMTP server with username "your_email_username" using 2 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code "535", with message "535 5.7.8 Authentication credentials invalid.
". Authenticator PLAIN returned Expected response code 235 but got code "535", with message "535 5.7.8 Authentication credentials invalid.
". {"userId":3,"exception":"[object] (Swift_TransportException(code: 0): Failed to authenticate on SMTP server with username \"your_email_username\" using 2 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code \"535\", with message \"535 5.7.8 Authentication credentials invalid.
\". Authenticator PLAIN returned Expected response code 235 but got code \"535\", with message \"535 5.7.8 Authentication credentials invalid.
\". at /var/www/html/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php:191)

phw-lopa avatar May 30 '24 13:05 phw-lopa

Had same issue here with Docker install no logs in container or error. image

Winniepoom avatar Jul 09 '24 09:07 Winniepoom