cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SMTP ERROR: Failed to connect to server: Connection refused (111)

I know this has been an ongoing issue with many related topics/issues posted; However, I am still receiving this error after searching through countless boards and consulting the PHPMailer documentation. I am using a Linux CPanel hosting for my site and have two different contact forms, both using PHPMailer (one of which offers attachments). Both are returning the same error. 

 

The following is my php code for the form with attachments:

<?php

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

include "PHPMailer/src/PHPMailer.php";
include "PHPMailer/src/Exception.php";
include "PHPMailer/src/SMTP.php";


if(isset($_POST['submit']))
{
    $name = $_POST['name'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];
    $skill = $_POST['skill'];
    $time = $_POST['time'];

    $message="From: $name <br> Email: $email <br> Phone Number: $phone <br> Skill: $skill <br> Best Time to Contact: $time";

    $to = "jobs@circaservice.com";
    try{
        $mailer = new PHPMailer\PHPMailer\PHPMailer(true);


        $mailer->SetFrom($email);
        $mailer->Subject = "Job Inquiry";
        $mailer->Body = $message;
        $mailer->AddAddress($to);
        $mailer->isHTML(true);

        //Tell PHPMailer to use SMTP
        $mailer->isSMTP();
        $mailer->SMTPDebug = 2;
        $mailer->Host = 'relay-hosting.secureserver.net';
        $mailer->Port = 25;
        $mailer->SMTPAuth = false;
        $mailer->SMTPSecure = false;

        if(isset($_FILES['resume'])){
            
            $file_name = $_FILES['resume']['name'];
            $file_size = $_FILES['resume']['size'];
            $file_tmp = $_FILES['resume']['tmp_name'];
            $file_type = $_FILES['resume']['type'];

            move_uploaded_file($file_tmp,"attachment/".$file_name);

            $mailer->addAttachment("attachment/".$file_name);
        }
        if(!$mailer->Send()) {
            echo "Mailer Error: " . $mailer->ErrorInfo;
        } else {
            echo "Email Sent";
        }
    }catch(Exception $e)
    {
        echo $e->getMessage();
    }
    
    
}

I have tried using 'localhost' in place of 'relay-hosting.secureserver.net' but the error is the same.

 

I also created (per recommendation from another board) a new record to try to remedy my problem:

Capture.PNG

 

Any further assistance would be greatly appreciated?

 

Thanks

 

Andrew