PHP send mail is not working

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


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

        $subject = 'text';

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

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

        function sendMail($subject, $to, $from, $senMsg) {
            echo 'mail';
            // Create the Transport
            $transport = (new Swift_SmtpTransport('', 465, 'ssl'))

            // 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])

            // 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 [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)