Skip to content
Advertisement

PHPMailer doesnt seem to work with Hostgator Hosting

I am using PHPMailer on core PHP with Hostgator hosting business account and im getting the following error in SMTPDebug:

2020-01-13 13:16:54 SERVER -> CLIENT: 220-gator4001.hostgator.com ESMTP Exim 4.92 #2 Mon, 13 Jan 2020 07:16:54 -0600 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.
2020-01-13 13:16:54 CLIENT -> SERVER: EHLO www.domainname.com
2020-01-13 13:16:54 SERVER -> CLIENT: 250-gator4001.hostgator.com Hello www.domainname.com [192.185.16.229]250-SIZE 52428800250-8BITMIME250-PIPELINING250-AUTH PLAIN LOGIN250 HELP
2020-01-13 13:16:54 CLIENT -> SERVER: AUTH LOGIN
2020-01-13 13:16:54 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2020-01-13 13:16:54 CLIENT -> SERVER: ZG9ub3RyZXBseUBjaGFpbnRoZWFwcC5jb20=
2020-01-13 13:16:54 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2020-01-13 13:16:54 CLIENT -> SERVER: YThoZkhON3FpKG9A
2020-01-13 13:16:54 SERVER -> CLIENT: 235 Authentication succeeded
2020-01-13 13:16:54 CLIENT -> SERVER: MAIL FROM:<donotreply@domainname.com>
2020-01-13 13:16:54 SERVER -> CLIENT: 250 OK
2020-01-13 13:16:54 CLIENT -> SERVER: RCPT TO:<my@emailaddress.com>
2020-01-13 13:16:54 SERVER -> CLIENT: 250 Accepted
2020-01-13 13:16:54 CLIENT -> SERVER: DATA
2020-01-13 13:16:54 SERVER -> CLIENT: 354 Enter message, ending with "." on a line by itself
2020-01-13 13:16:54 CLIENT -> SERVER: Date: Mon, 13 Jan 2020 16:16:54 +0300
2020-01-13 13:16:54 CLIENT -> SERVER: To: Taha Khan <my@emailaddress.com>
2020-01-13 13:16:54 CLIENT -> SERVER: From: Chain <donotreply@domainname.com>
2020-01-13 13:16:54 CLIENT -> SERVER: Subject: Chain account please activate your account
2020-01-13 13:16:54 CLIENT -> SERVER: Message-ID: <KvZPwFu2gMzFcs5f9XiBML51sazZsNQRXMqmxiuo@www.domainname.com>
2020-01-13 13:16:54 CLIENT -> SERVER: X-Mailer: PHPMailer 6.0.1 (https://github.com/PHPMailer/PHPMailer)
2020-01-13 13:16:54 CLIENT -> SERVER: MIME-Version: 1.0
2020-01-13 13:16:54 CLIENT -> SERVER: Content-Type: multipart/alternative;
2020-01-13 13:16:54 CLIENT -> SERVER: tboundary="b1_KvZPwFu2gMzFcs5f9XiBML51sazZsNQRXMqmxiuo"
2020-01-13 13:16:54 CLIENT -> SERVER: Content-Transfer-Encoding: 8bit
2020-01-13 13:16:54 CLIENT -> SERVER: 
2020-01-13 13:16:54 CLIENT -> SERVER: This is a multi-part message in MIME format.
2020-01-13 13:16:54 CLIENT -> SERVER: --b1_KvZPwFu2gMzFcs5f9XiBML51sazZsNQRXMqmxiuo
2020-01-13 13:16:54 CLIENT -> SERVER: Content-Type: text/plain; charset=us-ascii
2020-01-13 13:16:54 CLIENT -> SERVER: 
2020-01-13 13:16:54 CLIENT -> SERVER: This is a test html email
2020-01-13 13:16:54 CLIENT -> SERVER: 
2020-01-13 13:16:54 CLIENT -> SERVER: --b1_KvZPwFu2gMzFcs5f9XiBML51sazZsNQRXMqmxiuo
2020-01-13 13:16:54 CLIENT -> SERVER: Content-Type: text/html; charset=us-ascii
2020-01-13 13:16:54 CLIENT -> SERVER: 
2020-01-13 13:16:54 CLIENT -> SERVER: This is a test html email
2020-01-13 13:16:54 CLIENT -> SERVER: 
2020-01-13 13:16:54 CLIENT -> SERVER: 
2020-01-13 13:16:54 CLIENT -> SERVER: --b1_KvZPwFu2gMzFcs5f9XiBML51sazZsNQRXMqmxiuo--
2020-01-13 13:16:54 CLIENT -> SERVER: 
2020-01-13 13:16:54 CLIENT -> SERVER: .
2020-01-13 13:16:54 SERVER -> CLIENT: 250 OK id=1iqzaQ-000Ars-TL
2020-01-13 13:16:54 CLIENT -> SERVER: QUIT
2020-01-13 13:16:54 SERVER -> CLIENT: 221 gator4001.hostgator.com closing connection

the first line of the log says We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail. but at the same time PHPMailer is giving me response Mail sent.

What could be the issue here and how do i resolve it?

Also instead of my@emailaddress.com and domainname.com I’ve used my actual email address and actual website address. Just writing this here, apparently people point out the weirdest stuff here lol.

edit

Please find the php code below:

<?php
use PHPMailerPHPMailerPHPMailer;
use PHPMailerPHPMailerException;

require 'Exception.php';
require 'PHPMailer.php';
require 'SMTP.php';


$mail = new PHPMailer(true);                              
try {
    //Server settings
    $mail->SMTPDebug = 2;
    $mail->isSMTP();
    $mail->Host = 'domainname.com';
    $mail->SMTPAuth = true;
    $mail->Username = 'donotreply@domainname.com';
    $mail->Password = 'mypassword';
    $mail->SMTPSecure = 'ssl';
    $mail->Port = 465;
    //Recipients
    $mail->setFrom('donotreply@domainname.com', 'MyTestEmail');
    $mail->addAddress('info@domainname.com', 'Khan');

    //Content
    $mail->isHTML(true);
    $mail->Subject = 'Test Email body';
    $mail->Body    = 'Test Email body';
    $mail->AltBody = 'Test Email body';

    $mail->send();
    return "SUCCESS";
} catch (Exception $e) {
    return "FAIL";
    // Use the line below to display error
    // echo 'Mailer Error: ' . $mail->ErrorInfo;
}   

?>

** UPDATE **

I’ve received bounced back email on donotreply@domainname.com with the following error:

The mail system

<info@domainname.com>: host mail.domainname.com[192.185.30.71] said:
    550-Verification failed for <donotreply@domainname.com> 550-No Such User
    Here 550 Sender verify failed (in reply to RCPT TO command)
Reporting-MTA: dns; gateway21.websitewelcome.com
X-Postfix-Queue-ID: 14259400E4AA1
X-Postfix-Sender: rfc822; donotreply@domainname.com
Arrival-Date: Mon, 13 Jan 2020 08:02:26 -0600 (CST)

Final-Recipient: rfc822; info@domainname.com
Original-Recipient: rfc822;info@domainname.com
Action: failed
Status: 5.0.0
Remote-MTA: dns; mail.domainname.com
Diagnostic-Code: smtp; 550-Verification failed for <donotreply@domainname.com>
    550-No Such User Here 550 Sender verify failed

Advertisement

Answer

The issue was basically with the newly created email donotreply@domainname.com itself. The first two email addresses that were tested using PHPMailer bounced back in the inbox. If you are facing exactly the same issue as myself then i’d suggest you go through the following troubleshooting:

Make sure that Debug is not set to 0

$mail->SMTPDebug = 2

Test your code and check if PHPMailer is firing success at the end.

Check if PHPMailer echoes SUCCESS

As pointed out by @ADyson the following error/notice does not mean that the PHPMailer is not working.

SERVER -> CLIENT: 220-gator4001.hostgator.com ESMTP Exim 4.92 #2 Mon, 13 Jan 2020 07:16:54 -0600 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.

Secondly test your code by sending email to different domains on different servers

Test sending email to Gmail, Hotmail, Yahoo, Other Emails hosted on another server.

Check your inbox for any bounced back messages.

If you’ve received a bounced back message; It is certain that PHPMailer is working fine.

Contact your Host for more details by providing them with error details in the bounced email.

My issue was resolved by hostgator because the email to few email addresses would bounce back while it worked perfectly fine with Gmail and Hotmail

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement