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

phpmailer V6.0 settings that work(ed for me)

I spent many hours trying to get phpmailer settings right so that GoDaddy would not send back a "SMTP Failed to connect to server: Connection refused (111)" error.  In an effort to hopefully help save someone else's time   I won't suggest that this has been fully tested for all of phpmailer's options, but it does send out simple emails for me.  Here's what I have done:


<!DOCTYPE html>
        <meta charset="UTF-8">
            use PHPMailer\PHPMailer\PHPMailer;
            use PHPMailer\PHPMailer\Exception;
            use PHPMailer\PHPMailer\SMTP;
            require 'mail/Exception.php';  //my phpmailer scripts are in a 'mail' subdirectory
            require 'mail/PHPMailer.php';
            require 'mail/SMTP.php';
            $to_email = $_SESSION['email'];  //email address of the person logged in, set elsewhere
        echo "Testing PHPmail 2<br>";
        $mail = new PHPMailer();
        $mail->SMTPDebug = 0; // set to 3 for verbose debug output
        $mail->Host = "";  //specific to my cPanel
        $mail->Port = 25;
        $mail->SMTPSecure = "none";
        $mail->SMTPAuth = false;
        $mail->ENCRYPTION = "none";  //this is essential
        $mail->setFrom('', 'Admin');
        $mail->AddAddress($to_email);   //I set this elsewhere. you can put in a static value for testing.
        $mail->CharSet = 'utf-8';
        $mail->Subject = "PHPMailer Message test ";
        $mail->Body = "Hi! \n\n This is my first e-mail sent through PHPMailer.";

        if (!$mail->send()) {
            $msg .= "Mailer Error: " . $mail->ErrorInfo;
            echo $msg;
        } else {
            $msg .= "Message sent!";
            echo $msg;

Please know that I do not have the tech expertise to help anyone troubleshoot.  I arrived at success only through reading a myriad of posts, then throwing spaghetti at the wall to see what stuck.  What I found that cleared the path to making GoDaddy servers happy was the "$mail->ENCRYPTION = 'none'" setting.