Search code examples
smtpphpmailermailer

SMTP connection failed when set the username not email format


I'm using PHPMailer to send emails, when I set the config using a username not following email format it does not work. I use the same config on outlook to connect and it works fine.

"mail" => "smtp",
              "smtp"  => [
                  "host" => "mail.domain.com",
                  "port" => 25,
                  "auth" => true,
                  "secure" => "", // No need for ssl secure here
                  "user" => 'domain\username',
                  "pass" => 'P@$$w0rd'
              ]

I have another mailer config but the username is [email protected] and it is working fine.

The error that I got is:

> SMTP connect() failed.
> https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

Solution

  • When I upgrade the PHPMailer version it worked. Also, there was server issues they allowed requests from outside the list of IPs.