PHP send mail is not working

This is the code I am using for send mail in php:

<?php 

        require_once './mail/vendor/autoload.php';

        $subject = 'text';

        $from = 'name';
    // Compose a simple HTML email message
        $message = '<!DOCTYPE html>
    <head>
    <title> text</title>
    </head>
    <body>
    <p style="font-family:Helvetica Neue,Arial,sans-serif; font-size: 20px; text-align: center;">Welcome to text!</p> 
    </body>
    </html>';

            sendMail($subject, '[email protected]', $from, $message);            

        function sendMail($subject, $to, $from, $senMsg) {
            echo 'mail';
            // Create the Transport
            $transport = (new Swift_SmtpTransport('formrly.co', 465, 'ssl'))
              ->setUsername('user_email_id')
              ->setPassword('password')
            ;

            // Create the Mailer using your created Transport
            $mailer = new Swift_Mailer($transport);

            // Create a message
            $message = (new Swift_Message($subject))
              ->setFrom(['user email id' => $from])
              ->setTo([$to])
              ->setBody($senMsg)
              ;
              $message->setContentType("text/html");

            // Send the message
            $result = $mailer->send($message);
            echo $result;
        }

    ?>

This is the error I am getting:

Fatal error: Uncaught exception ‘Swift_TransportException’ with message ‘Connection could not be established with host smtp.gmail.com [Connection refused #111]’ in /home/formrlypanel/public_html/phase2/providers/mail/vendor/‌​swiftmailer/swiftmai‌​ler/lib/classes/Swif‌​t/Transport/StreamBu‌​ffer.php:268 Stack trace: #0 (113): Swift_Transport_StreamBuffer->initialize(Array) #2 /home/formrlypanel/public_html/phase2/providers/mail/vendor/‌​swiftmailer/swiftmai‌​ler/lib/classes/Swif‌​t/Mailer.php(79)