PHPmailer gives error CLIENT -> SERVER: EHLO localhost
<p>I am using PHPMailer.</p>

<p>When I try to send mail using gmail mail id eg.</p>

<p><code>$mail-&gt;Username = 'email@gmail.com';</code> </p>

<p>it sends successfully but when I try by using private mail server mail id means which is accessible within the campus only eg.</p>

<p><code>$mail-&gt;Username = 'email@privateserver.com';</code></p>

<p>it gives an following error</p>

<p>CLIENT -> SERVER: EHLO localhost</p>

<p>below is my whole code</p>

<pre><code>$mail = new PHPMailer;
    $mail-&gt;isSMTP();
    //$mail-&gt;SMTPDebug = 1;
    $mail-&gt;Host = 'hostname';
    $mail-&gt;SMTPAuth = true;
    //$mail-&gt;SMTPSecure = 'ssl';
    $mail-&gt;SMTPSecure = 'tls';
    $mail-&gt;Port = 587;
    $mail-&gt;Username = 'mail@privateserver.com';
    $mail-&gt;Password = 'pass';

    $mail-&gt;From = 'mail@privateserver.com';
    $mail-&gt;FromName = '';
    $mail-&gt;addAddress($email, $fullName);

    $mail-&gt;WordWrap = 50;
    $mail-&gt;isHTML(true);
    $mail-&gt;Body = '&lt;html&gt;&lt;head&gt;&lt;/head&gt;';

    if (!$mail-&gt;send()) {
        echo 'Message could not be sent.';
        echo 'Mailer Error: ' . $mail-&gt;ErrorInfo;
        exit;
    } else {
        return TRUE;
    }
</code></pre>