0
votes

I'm Trying to send email via php by using php mailer, but it's showing SMTP connect() failed. here is my code. can't find out what is problem in that. if somebody help to track error it will be very helpful for me.

$mail = new PHPMailer;

$mail->isSMTP();                                   // Set mailer to use SMTP
$mail->Host = 'dds.uemtv.com';                    // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                            // Enable SMTP authentication
$mail->Username = '[email protected]';          // SMTP username
$mail->Password = 'pssword'; // SMTP password
$mail->SMTPSecure = 'tls';                         // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;                                 // TCP port to connect to

$mail->setFrom('[email protected]', 'title');
$mail->addReplyTo($email, '$name');
$mail->addAddress($email);   // Add a recipient
//$mail->addCC('[email protected]');
//$mail->addBCC('[email protected]');

$mail->isHTML(true);  // Set email format to HTML


$bodyContent = '<h1>Your Registration Completed. </h1>'
$mail->Subject = 'Verify Account- Rozgar';
$mail->Body    = $bodyContent;
if(!$mail->send()) {

    echo $data->msg = $mail->ErrorInfo;
} else {
    // echo 'Message has been sent';
    echo $data->msg="Please Verify Your Email Address";
}

Showing this error.

2017-06-07 05:36:44 SERVER -> CLIENT: 220-dds.uemtv.com ESMTP Exim 4.89 #1 Wed, 07 Jun 2017 10:36:40 +0500 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.
2017-06-07 05:36:44 CLIENT -> SERVER: EHLO localhost
2017-06-07 05:36:44 SERVER -> CLIENT: 250-dds.uemtv.com Hello localhost [182.186.132.245] 250-SIZE 52428800 250-8BITMIME 250-PIPELINING 250-STARTTLS 250 HELP
2017-06-07 05:36:44 CLIENT -> SERVER: STARTTLS
2017-06-07 05:36:45 SERVER -> CLIENT: 220 TLS go ahead
2017-06-07 05:36:46 CLIENT -> SERVER: EHLO localhost
2017-06-07 05:36:47 SERVER -> CLIENT: 250-dds.uemtv.com Hello localhost [182.186.132.245] 250-SIZE 52428800 250-8BITMIME 250-PIPELINING 250-AUTH PLAIN LOGIN 250 HELP
2017-06-07 05:36:47 CLIENT -> SERVER: AUTH LOGIN
2017-06-07 05:36:47 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2017-06-07 05:36:47 CLIENT -> SERVER: xxx=
2017-06-07 05:36:47 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2017-06-07 05:36:47 CLIENT -> SERVER: xxx
2017-06-07 05:36:49 SERVER -> CLIENT: 535 Incorrect authentication data
2017-06-07 05:36:49 SMTP ERROR: Password command failed: 535 Incorrect authentication data
2017-06-07 05:36:49 SMTP Error: Could not authenticate.
2017-06-07 05:36:49 CLIENT -> SERVER: QUIT
2017-06-07 05:36:50 SERVER -> CLIENT: 221 dds.uemtv.com closing connection
2017-06-07 05:36:50 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

2
The issue is in the log. Message from the SMTP server: "We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail". The code works, you're simply getting blocked by the SMTP-server.Magnus Eriksson
I don't think that's the error, the error is down further where the 535 incorrect authentication data part is.David Findlay
@DavidFindlay Oh, look at that. You're absolutely right: "SMTP Error: Could not authenticate."Magnus Eriksson
Yes, that "We do not authorize..." message is just part of the "welcome" banner; it's not an error.Synchro

2 Answers

1
votes

There's probably nothing wrong with your code. The server you are using doesn't allow relaying without authentication. There's authentication errors in your log, so perhaps you're using incorrect credentials.

1
votes

it seems not a code issue, and as such not something we can fix for you. Talk to your ISP, read their docs.

So either your Host setting is wrong, or you are being redirected by your ISP. Either way, this is all covered in the troubleshooting guide the error message pointed you at, which is why it's there.