简体   繁体   中英

What is correct settings for sending email through godaddy SMTP?

I am using GoDaddy Professional Email (NOT Workspace Email) under Email & Office. For my website, I want to email users using PHPMailer. I have used all the credentials according to GoDaddy Email Server infos.

According to GoDaddy, the outgoing server settings are:

  • SMTP Host : 'smtpout.secureserver.net'
  • Port: 465
  • Security : 'ssl'

I have set my PHPMailer code as follows:

<?php

try
{
    $email = new PHPMailer(TRUE);
    $email->isSMTP();
    $email->SMTPDebug = 2;
    $email->SMTPAuth = TRUE;
    $email->SMTPAutoTLS = FALSE;
    $email->SMTPSecure = "ssl";
    $email->Host = "smtpout.secureserver.net";
    $email->Port = 465;
    $email->Username = "myUserName";
    $email->Password = "MyPassword";

    $email->setFrom("address@from.com", "Name");
    $email->addAddress("address@to.com", "Name");
    $email->isHTML(TRUE);
    $email->Body = "My HTML Code";
    $email->Subject = "My Subject";
    $email->send();
}
catch (Exception $e)
{
    // $email->ErrorInfo;
}

?>

The above code throwing following error:

2019-08-14 10:55:58 SMTP ERROR: Failed to connect to server: Connection refused (111) SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

I have searched for solutions. Some Stackoverflow questions discuss about GoDaddy Workspace Email. But I am frustrated to find a solution till now. Please help me if I am doing anything wrong.

I have found the following setting working. This may be useful.

Use 80 as port

<?php

try
{
    $email = new PHPMailer(TRUE);
    $email->isSMTP();
    $email->SMTPDebug = 2;
    $email->SMTPAuth = TRUE;
    $email->SMTPAutoTLS = FALSE;
    $email->SMTPSecure = "tls";
    $email->Host = "smtpout.secureserver.net";
    $email->Port = 80;
    $email->Username = "GoDaddy Professional Email Username";
    $email->Password = "GoDaddy Professional Email Password";

    $email->setFrom("address@from.com", "Name");
    $email->addAddress("address@to.com", "Name");
    $email->isHTML(TRUE);
    $email->Body = "My HTML Code";
    $email->Subject = "My Subject";
    $email->send();
}
catch (Exception $e)
{
    // $email->ErrorInfo;
}

?>`

My answer is to say that: Hiranmoy's suggestion on Aug 14 at 14:56 should be the approved answer. The amount of headaches Godaddy causes with this simple piece of functionality deserves a tested, working solution and Hiranmoy's is the only one I have found after many hours of searching. Here is Hiranmoy's snippet with missing includes added:

    <?php
    use PHPMailer\PHPMailer\PHPMailer;
    use PHPMailer\PHPMailer\Exception;

    require 'Exception.php';
    require 'PHPMailer.php';
    require 'SMTP.php';

    try
    {
        $email = new PHPMailer(TRUE);
        $email->isSMTP();
        $email->SMTPDebug = 2;
        $email->SMTPAuth = TRUE;
        $email->SMTPAutoTLS = FALSE;
        $email->SMTPSecure = "tls";
        $email->Host = "smtpout.secureserver.net";
        $email->Port = 80;
        $email->Username = "GoDaddy Professional Email Username";
        $email->Password = "GoDaddy Professional Email Password";

        $email->setFrom("address@from.com", "Name");
        $email->addAddress("address@to.com", "Name");
        $email->isHTML(TRUE);
        $email->Body = "My HTML Code";
        $email->Subject = "My Subject";
        $email->send();
    }
    catch (Exception $e)
    {
        // $email->ErrorInfo;
    }
    ?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM