1

I was using Laravel 8.64, and my emails were working fine both on prod and dev servers. However, after upgrading to 9.0.2, I have an issue with sending emails. Of course, I followed all instructions, but still, I get errors when I try to send an email.

User is not set. {"exception":"[object] (Symfony\Component\Mailer\Exception\IncompleteDsnException(code: 0): User is not set.

After some reasearch in vendor folder i found class AbstractTransportFactory that contains getUser method.

protected function getUser(Dsn $dsn): string
{
    $user = $dsn->getUser();
    if (null === $user) {
        throw new IncompleteDsnException('User is not set.');
    }

    return $user;
}

When I return ''; in this if statement, everything is working fine instead of throwing an exception. Does anyone know the solution for this and why this is happening

Karl Hill
  • 12,937
  • 5
  • 58
  • 95
Aleksandar Đokić
  • 2,118
  • 17
  • 35

1 Answers1

9

I had the same issue.

Make sure that your .env file contains: MAILGUN_DOMAIN=your.domain.com MAILGUN_SECRET=your.mailgun.secret

This would be reflected as the username/password for the DSN.

Cheers

Ika Balzam
  • 176
  • 2
  • Thats solution! Thank you very much. But where did you find it? I could not find env() check for those anywhere since i have them setup in mail.php – Aleksandar Đokić Feb 12 '22 at 18:00
  • 1
    I didn't find it as well, so I started tracking down the flow until I found where it was pulling the user, and I realized it was looking for those details. – Ika Balzam Feb 16 '22 at 20:22
  • 1
    Found it in docs here https://laravel.com/docs/9.x/mail#driver-prerequisites – dfeva Feb 07 '23 at 03:00