snipe / snipe-it

A free open source IT asset/license management system
https://snipeitapp.com
GNU Affero General Public License v3.0
10.28k stars 3.05k forks source link

Office 365 (direct send) Email Issue #14471

Open PP-JN-RL opened 3 months ago

PP-JN-RL commented 3 months ago

Debug mode

Describe the bug

I am using the latest docker version of snipe-it and are experiencing some issues using the email notifications. The environment variables for the email settings are as follows:

  - MAIL_DRIVER=smtp
  - MAIL_HOST=myorg.mail.protection.outlook.com
  - MAIL_PORT=25
  - MAIL_USERNAME=
  - MAIL_PASSWORD=
  - MAIL_ENCRYPTION=null
  - MAIL_FROM_ADDR=snipe@myorg.com
  - MAIL_FROM_NAME='Snipe-IT Admin'
  - MAIL_REPLYTO_ADDR=snipe@myorg.com
  - MAIL_REPLYTO_NAME='Snipe-IT Admin'
  - MAIL_AUTO_EMBED=true
  - MAIL_AUTO_EMBED_METHOD=base64

When testing the email function in the settings page I get the following error: image

However, we receive stock alerts every night completely fine without any issues.

I could live with that error but the issue is that when a user tries to request an item, the webserver throws an error 500 because the email settings are not correct.

Any advice would be greatly appreciated.

Reproduction steps

  1. Set environment variables in docker compose file
  2. Restart container
  3. Open general settings page
  4. Press "Send Test"

Expected behavior

Test should be successful as the email notifications for low stock get delivered correctly.

Screenshots

No response

Snipe-IT Version

v6.3.3 build 12903 (g0f63fa23e)

Operating System

Docker

Web Server

Docker

PHP Version

v6.3.3 build 12903 (g0f63fa23e)

Operating System

Windows 11

Browser

Edge

Version

Version 122.0.2365.92 (Official build) (64-bit)

Device

No response

Operating System

No response

Browser

No response

Version

No response

Error messages

No error message present in debug mode when pressing the "Sent Test" button but when i try to request an item it fails with the following:

Swift_TransportException
Expected response code 354 but got code "503", with message "503 5.5.2 Need rcpt command [LO1PEPF000028CC.GBRP265.PROD.OUTLOOK.COM 2024-03-21T09:05:23.110Z 08DC464AAF10B5F4] "

Swift_Transport_AbstractSmtpTransport::assertResponseCode
vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:459

Additional context

No response

snipe commented 3 months ago

All of the mail within the system uses the same settings, so not really sure why some mail would come through fine and others would not.

PP-JN-RL commented 3 months ago

Are there any additional checks happening when a user requests an item? Because this is when it throws an error 500. If so, is there a way to turn those checks off?

snipe commented 3 months ago

No, nothing extra. Everything in the system uses the triggers in the app/Notifications:

https://github.com/snipe/snipe-it/blob/6dd6b45829d139da4c7528c02efeb55f73c83f4f/app/Notifications/RequestAssetNotification.php#L100-L124

The test email button uses this API controller:

https://github.com/snipe/snipe-it/blob/6dd6b45829d139da4c7528c02efeb55f73c83f4f/app/Http/Controllers/Api/SettingsController.php#L146-L165

Which just calls this code:

https://github.com/snipe/snipe-it/blob/6dd6b45829d139da4c7528c02efeb55f73c83f4f/app/Notifications/MailTest.php#L39-L44

PP-JN-RL commented 2 months ago

Thank you for the additional info, I will look into this and report back.

PP-JN-RL commented 2 months ago

What I found so far: It seems to work when the email is fired via a background task, i.e. low inventory alerts that come through at midnight. Anything triggered via the UI fails.

How are the mail notifications called that run as background tasks? Can I trigger them manually for testing?

YoBii commented 2 months ago

Might be related: https://github.com/snipe/snipe-it/issues/13872