lprice's avatar
Level 21

Mailer problem: scheme is not supported; supported schemes for mailer "smtp" are: "smtp", "smtps"

Sending of email via SMTP stopped working since last composer update with error: "The "" scheme is not supported; supported schemes for mailer "smtp" are: "smtp", "smtps"."

I'm using mailpit:

MAIL_MAILER=smtp
MAIL_HOST=localhost
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"

Any ideas?

0 likes
11 replies
LaryAI's avatar
Level 58

The error you're encountering is related to the mail configuration in your Laravel application. The error message indicates that the scheme is not supported, which usually means there's an issue with the MAIL_ENCRYPTION setting.

In your .env file, you have:

MAIL_ENCRYPTION=null

The MAIL_ENCRYPTION setting should be either null, tls, or ssl. However, when you set it to null, it might be interpreted incorrectly. To resolve this issue, you should explicitly set it to an empty string if you don't want to use encryption. Here's how you can update your .env file:

MAIL_MAILER=smtp
MAIL_HOST=localhost
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"

By setting MAIL_ENCRYPTION= (an empty string), you ensure that no encryption is used, which is appropriate for local development with tools like Mailpit.

After making this change, don't forget to clear your configuration cache to ensure the changes take effect:

php artisan config:clear

This should resolve the issue and allow you to send emails using SMTP without encryption.

1 like
ajjacklin's avatar

Hi, I just ran into the same issue and this fixed it.

  1. added 'scheme' => 'smtp' to app/config/mail.php under mail.mailers.smtp
  2. Changed MAIL_HOST in .env to MAIL_HOST=mailpit (the service name in docker-compose.yml)

I'm using Sail 1.26 with PHP 8.2. If you're not using Sail #1 might be all you need.

11 likes
N3rdwar3's avatar

@ajjacklin Thanks, gonna share this on the Beginner Course where it goes over email sending in Laravel because that is where I got stuck on this issue

1 like
seanburlington's avatar

This seems to be a recent bug github.com/laravel/framework/issues/53721

This change fixed it for me

diff --git a/config/mail.php b/config/mail.php
index e894b2e..0cfe144 100644
--- a/config/mail.php
+++ b/config/mail.php
@@ -44,6 +44,7 @@
             'password' => env('MAIL_PASSWORD'),
             'timeout' => null,
             'local_domain' => env('MAIL_EHLO_DOMAIN'),
+            'scheme' => env('MAIL_SCHEME', 'smtp'), // smtp or smtps
         ],
5 likes
jamesautodude's avatar

I did a composer update on everything today and it seems to be fixed, knock on wood...

1 like

Please or to participate in this conversation.