0
votes

I have an email account with zoho.com that is configured and running. On GoDaddy, I am hosting my site and have configured my mail such that any mail sent via the website is received at zoho mail. This setup worked fine till last week. Now I am getting errors and I have no idea what triggers them.

I get the following error on GoDaddy server when I try to send a mail to any account:

SMTP -> ERROR: Failed to connect to server: Connection refused (111) SMTP Error: Could not connect to SMTP host.

AND the following error on localhost for the same script:

SMTP -> ERROR: Failed to connect to server: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (10060)

I have tried the following to correct the errors (on both localhost and GoDaddy) by:

  • Changed port number to 25,465 and 587

  • Changed smtp server from smtp.zoho.com to relay-hosting.secureserver.net

  • Changed ssl to tls and vice versa

  • Removed the SMTPSecure Parameter altogether

  • Increased timeout variable to 1000

  • Verified that the mail accounts exist and are up and running

  • Verified that mail accounts have valid passwords and usernames.

A working demo can be found here.I have echoed the errors out as well as the message to be sent just for the purpose of this question.

Edit 1 I commented out "$mail->Host="smtp.zoho.com" and got the following error:

SMTP -> FROM SERVER: SMTP -> FROM SERVER: SMTP -> ERROR: EHLO not accepted from server: SMTP -> FROM SERVER: SMTP -> ERROR: HELO not accepted from server: SMTP -> ERROR: AUTH not accepted from server: SMTP -> NOTICE: EOF caught while checking if connectedSMTP Error: Could not authenticate.

Does this mean that GoDaddy is not authenticating the credentials?

Edit 2: My settings on zoho mail are:

Incoming server: poppro.zoho.com, Port: 995, SSL (POP)
Incoming server: imappro.zoho.com, Port: 993, SSL (IMAP) Outgoing server: smtp.zoho.com, Port: 465, SSL (POP and IMAP)

1
One assumes you have changed the password above.Progrock
No, the email and the password are as mentioned in the question. At my wits end :(Fabulous
Add one more parameter in try block $mail->Mailer = 'smtp';Rahul Singh
@RahulSingh No change! same error on godaddy server :(Fabulous
If you comment out the host (zoho mx), you'll probably default to trying to send mail through the localhost, that is probably not what you desire.Progrock

1 Answers

2
votes

Try Using Following Code:

<?php
require_once('class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch

$mail->IsSMTP(); // telling the class to use SMTP

try {
    //SMTP needs accurate times, and the PHP time zone MUST be set
    //This should be done in your php.ini, but this is how to do it if you don't have access to that
    #require '../PHPMailerAutoload.php';

    //Create a new PHPMailer instance
    $mail = new PHPMailer;

    //Tell PHPMailer to use SMTP
    $mail->isSMTP();
    //Enable SMTP debugging
    // 0 = off (for production use)
    // 1 = client messages
    // 2 = client and server messages
    $mail->SMTPDebug = 3;

    //Ask for HTML-friendly debug output
    $mail->Debugoutput = 'html';

    //Set the hostname of the mail server
    $mail->Host = 'smtp.zoho.com';

    // use
    // $mail->Host = gethostbyname('smtp.zoho.com');
    // if your network does not support SMTP over IPv6

    //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
    $mail->Port = 465;

    //Set the encryption system to use - ssl (deprecated) or tls
    //$mail->SMTPSecure = 'tls';

    //Whether to use SMTP authentication
    $mail->SMTPAuth = true;

    //Username to use for SMTP authentication - use full email address for gmail
    $mail->Username = "[email protected]";

    //Password to use for SMTP authentication
    $mail->Password = "care@subillion";

    //Set who the message is to be sent from
    $mail->setFrom('[email protected]', '[email protected]');

    //Set an alternative reply-to address
    #$mail->addReplyTo('[email protected]', 'First Last');

    //Set who the message is to be sent to
    $mail->AddAddress($touser, $username);

    $mail->Subject = $subject;
    $mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
    $mail->MsgHTML($msg);
    echo $msg;
    //$mail->AddAttachment('img/logo-dark.png');      
    $mail->Send();

    // echo "Message Sent OK</p>\n";
} catch (Exception $e) {
    // echo $e->getMessage(); //Boring error messages from anything else!
}
?>

EDIT: if still not working then you must have proper configuration settings as below(as example):

Non-SSL Settings
(NOT Recommended)
Username:   [email protected]
Password:   Use the email account’s password.
Incoming Server:    mail.domain.com
IMAP Port: 143
POP3 Port: 110
Outgoing Server:    mail.domian.com
SMTP Port: 25
Authentication is required for IMAP, POP3, and SMTP.