1

I am using PHPMailer.

When I try to send mail using gmail mail id eg.

$mail->Username = 'email@gmail.com';

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

$mail->Username = 'email@privateserver.com';

it gives an following error

CLIENT -> SERVER: EHLO localhost

below is my whole code

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

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

    $mail->WordWrap = 50;
    $mail->isHTML(true);
    $mail->Body = '<html><head></head>';

    if (!$mail->send()) {
        echo 'Message could not be sent.';
        echo 'Mailer Error: ' . $mail->ErrorInfo;
        exit;
    } else {
        return TRUE;
    }
Tejas Khutale
  • 84
  • 2
  • 19

0 Answers0