Home > Software engineering >  SMTP Working good on hostinger and not working on bamboozle.me host?
SMTP Working good on hostinger and not working on bamboozle.me host?

Time:05-22

could folks please assist me with the following error? I'm using a smtp php mailer that worked fine on hostinger with no errors, and I did receive the email, but it's not working on my bamboozle-hosted website. Please assist me.

2022-05-21 16:29:18 SERVER -> CLIENT: 220-cp-dxb-001.bamboozle.me ESMTP Exim 4.95 #2 Sat, 21 
May 2022 20:29:18  0400 220-We do not authorize the use of this system to transport 
unsolicited, 220 and/or bulk e-mail.
2022-05-21 16:29:18 CLIENT -> SERVER: EHLO www.eighty6.shop
2022-05-21 16:29:18 SERVER -> CLIENT: 250-cp-dxb-001.bamboozle.me Hello www.eighty6.shop 
[185.93.244.110]250-SIZE 52428800250-8BITMIME250-PIPELINING250-PIPE_CONNECT250-AUTH PLAIN 
LOGIN250 HELP
2022-05-21 16:29:18 CLIENT -> SERVER: AUTH LOGIN
2022-05-21 16:29:18 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2022-05-21 16:29:18 CLIENT -> SERVER: [credentials hidden]
2022-05-21 16:29:18 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2022-05-21 16:29:18 CLIENT -> SERVER: [credentials hidden]
2022-05-21 16:29:21 SERVER -> CLIENT: 535 Incorrect authentication data
2022-05-21 16:29:21 SMTP ERROR: Password command failed: 535 Incorrect authentication data
SMTP Error: Could not authenticate.
2022-05-21 16:29:21 CLIENT -> SERVER: QUIT
2022-05-21 16:29:21 SERVER -> CLIENT: 221 cp-dxb-001.bamboozle.me closing connection
2022-05-21 16:29:21 SMTP ERROR: Failed to connect to server: (0)
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Something is wrong:
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

that's my code

<?php

// Subscribe my channel if you are using this code
// Subscribe my channel if you are using this code
// Subscribe my channel if you are using this code
// Subscribe my channel if you are using this code
// Subscribe my channel if you are using this code


use PHPMailer\PHPMailer\PHPMailer;
function sendmail(){
    $name = "EX - Joey";  // Name of your website or yours
    $to = "[email protected]";  // mail of reciever
    $subject = "Tutorial or any subject";
    $body = "Send Mail Using PHPMailer - MS The Tech Guy";
    $from = "[email protected]";  // you mail
    $password = "pass";  // your mail password

    // Ignore from here

    require_once "PHPMailer/PHPMailer.php";
    require_once "PHPMailer/SMTP.php";
    require_once "PHPMailer/Exception.php";
    $mail = new PHPMailer();

    // To Here

    //SMTP Settings
    $mail->isSMTP();
    $mail->SMTPDebug = 2;                           
    $mail->Host = "smtp.gmail.com"; // smtp address of your email
    $mail->SMTPAuth = true;
    $mail->Username = $from;
    $mail->Password = $password;
    $mail->Port = 465;  // port
    $mail->SMTPSecure = "ssl";  // tls or ssl
    $mail->smtpConnect([
    'ssl' => [
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
        ]
    ]);

    //Email Settings
    $mail->isHTML(true);
    $mail->setFrom($from, $name);
    $mail->addAddress($to); // enter email address whom you want to send
    $mail->Subject = ("$subject");
    $mail->Body = $body;
    if ($mail->send()) {
        echo "Email is sent!";
    } else {
        echo "Something is wrong: <br><br>" . $mail->ErrorInfo;
    }
}


    // sendmail();  // call this function when you want to

    if (isset($_GET['sendmail'])) {
        sendmail();
    }
?>


 <html>
   <head>
      <title>Send Mail</title>
   </head>
  <body>
    <form method="get">
        <button type="submit" name="sendmail">sendmail</button>
    </form>
  </body>
</html>

Also i tried to change port value nothing happened thou same code with same credentials and smtp settings worked on hostinger.

CodePudding user response:

Notice how you're asking to connect to smtp.gmail.com in your script, but it's actually connecting to cp-dxb-001.bamboozle.me?

That's because your hosting provider is redirecting your SMTP traffic to their mail server, as described in the troubleshooting guide.

Unfortunately you disabled TLS certificate verification, so it connected anyway, and as a result you gave away the credentials to your gmail account, and now you'll need to change your password. The lesson here is to read the error message, and don't disable certificate verification.

You will either need to use their mail server, convince them to stop redirecting your SMTP traffic, or find a better hosting provider.

  • Related