Tuesday, 28 August 2018

Asking for SMTP Authentication in mail server PHPMailer

I'm trying to use PHPmailer to send mails. My webhost has said if the mail is relayed through their datacenter, no credentials are required. This is my code:

$mail->SMTPOptions = array(
    'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
    )
);

$mail->SMTPSecure = 'tls';
$mail->SMTPDebug    = 2;
$mail->isSMTP();

$mail->Host         = 'smtpgateway.webhost.com';
$mail->SMTPAuth     = false;
$mail->SMTPSecure   = false;
$mail->port         = 25;
$mail->setFrom('info@mydomain.com', 'Test');
$mail->Subject      = $email_subject;
$mail->Body         = $email_body;
$mail->addAddress($email, $name);
$mail->isHTML(true);
if($mail->send())
{
    echo "Success";
}

But I get this error when trying to send email:

2018-08-21 10:07:03 CLIENT -> SERVER: MAIL FROM: info@mydomain.com

2018-08-21 10:07:03 SERVER -> CLIENT: 250 OK

2018-08-21 10:07:03 CLIENT -> SERVER: RCPT TO:test@example.com

2018-08-21 10:07:03 SERVER -> CLIENT: 550-Please turn on SMTP Authentication in your mail client. (mydomain.com)550-[10.100.15.115]:41032 is not permitted to relay through this server without550 authentication.

2018-08-21 10:07:03 SMTP ERROR: RCPT TO command failed: 550-Please turn on SMTP Authentication in your mail client (mydomain.com)550-[10.100.15.115]:41032 is not permitted to relay through this server without550 authentication.



from Asking for SMTP Authentication in mail server PHPMailer

No comments:

Post a Comment