Connection Refused using PHPMailer with Namecheap Accounts

徘徊边缘 提交于 2019-12-23 01:12:30

问题


I have been using the code below to try to send emails out to people who sign up on my website however I can not get the code to work with my namecheap hosted email account. This namecheap email configuration was used but it seems to still give me an error. I have tried the same code with the hotmail settings and it works just fine.

Error

2016-06-17 09:28:33 SMTP ERROR: Failed to connect to server: Connection refused (61) 2016-06-17 09:28:33    SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Mailer: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

Code

require_once('PHPMailerAutoload.php');
    function sendmail($host, $username, $password, $to, $subject, $message, $fromName, $toName, $port, $debug) {
        $mail = new PHPMailer();
        $body = $message;
        $mail->IsSMTP();
        $mail->Host = $host;
        if ($debug) $mail->SMTPDebug = 2;
        $mail->SMTPAuth = true;
        $mail->SMTPSecure = "tls"; 
        $mail->Port = $port;
        $mail->Username = $username;
        $mail->Password = $password;
        $mail->SetFrom($to, $name);
        $mail->AddReplyTo($to, $name);
        $mail->Subject = $subject;
        $mail->AltBody = $message;
        $mail->MsgHTML($body);

        $address = $to;
        $mail->AddAddress($address, $name);
        if($mail->Send()) {
            echo "Message sent";
        } else {
            echo "Mailer: " . $mail->ErrorInfo;
        }
    }

echo sendMail("mail.privateemail.com", "noreply@example.com", "password", "recipient@example.com", "Subject", "Message", "Name", "Sender Name", 25, true);

回答1:


After talking to support it seems that there was some issues going on with their private email servers and the following message was displayed on the Namecheap accounts page:

Dear Private Email users, We are glad to let you know that the issues with Mailboxes Management functionality of Private Email section in Namecheap account have been fixed. Also, please be aware that non-secured ports (143, 110, 25, 587) are available and fully functional now. Please feel free to use them while setting up an email client. Should you have any questions feel free to contact our Support Team.

I have gone through each port and found 587 to work for me



来源:https://stackoverflow.com/questions/37877979/connection-refused-using-phpmailer-with-namecheap-accounts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!