Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

V9द's avatar
Level 3

Swift_TransportException Connection to tcp://mail.xxxx.com:465 Timed Out

Hi, I am new to laravel and I am want to send registration information to user to their email id, but I am getting error every time "Swift_TransportException Connection to tcp://mail.xxxx.com:465 Timed Out". I already define the mail configuration in mail.php under config folder and in .env file. Please tell me the solution to resolve this issue.

0 likes
7 replies
RamjithAp's avatar

Show your mail.php config (Except email password) so we can help you.

V9द's avatar
Level 3

@RamjithAp Thank you for your reply here is mail.php

 return [

 
    'driver' => env('MAIL_DRIVER', 'smtp'),

  

    'host' => env('MAIL_HOST', 'smtp.mailgun.org'),

   

    'port' => env('MAIL_PORT', 465),

 

    'from' => [
        'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
        'name' => env('MAIL_FROM_NAME', 'xxxx'),
    ],


    'encryption' => env('MAIL_ENCRYPTION', 'tls'),

   

    'username' => env('[email protected]'),

    'password' => env('xxxxx'),

  

    'sendmail' => '/usr/sbin/sendmail -bs',

  

    'markdown' => [
        'theme' => 'default',

        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],

];

RamjithAp's avatar

First change your mail_driver to mailgun and try. If not work, then go to your env file add this details.

MAIL_DRIVER=mailgun
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
[email protected] //get this from mailgun dashboard
MAIL_PASSWORD=8aXXX029XXXXXXXXXX4fXXXX4bd //get this from mailgun dashboard
MAIL_ENCRYPTION=tls
MAILGUN_DOMAIN=yourdomain.com 
MAILGUN_SECRET=key-4d3XXXXXXXXXXXXXX4XXX7843 //get this from mailgun dashboard

Make sure your domain name in mailgun account dashboard is in active status.

V9द's avatar
Level 3

@RamjithAp I am not using mailgun When I put MAIL_HOST "mail.xxxx.com" still issue is same.

V9द's avatar
V9द
OP
Best Answer
Level 3

Yeah! I got solution of that issue I am useing mail instead of smtp corresponding to MAIL_DRIVER.

4 likes
mutuku's avatar

I notice in /config/mail.php , I see

'encryption' => env('MAIL_ENCRYPTION', 'tls'),

By updating it to

'encryption' => env('MAIL_ENCRYPTION', 'ssl'),

Now, it is working fine. My email is sending out now.

1 like
onyashed's avatar

I tied on debug mail on localhost..still I get this error thrown. Swift_TransportException with message 'Connection to mail.[medomain].co.ke:465 Timed Out'

Please or to participate in this conversation.