Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SMTP ERROR: Password command failed: 535 Login incorrect -ERR #2910

Closed
EfeErdem7 opened this issue Jun 9, 2023 · 1 comment
Closed

SMTP ERROR: Password command failed: 535 Login incorrect -ERR #2910

EfeErdem7 opened this issue Jun 9, 2023 · 1 comment

Comments

@EfeErdem7
Copy link

I keep getting this error and I tried different things I found in the web. I can't send emails with smtp. Dropping the code I am using

<?php 
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;

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

$name = $_POST["name"];
$email = $_POST["email"];
$subject = $_POST["subject"];
$message = $_POST["message"];

 $mail = new PHPMailer();

 $mail->SMTPDebug = 1;                      //Enable verbose debug output
 $mail->isSMTP();                                            //Send using SMTP
 $mail->Host       = 'mail.example.com';                     //Set the SMTP server to send through
 $mail->SMTPAuth   = true;                                   //Enable SMTP authentication
 $mail->Username   = '[email protected]';                     //SMTP username
 $mail->Password   = 'my-password';                               //SMTP password
 $mail->SMTPSecure = "tls";            //Enable implicit TLS encryption
 $mail->Port       = 587;          //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
 $mail->smtpConnect([
        'ssl' => [
            'verify_peer' => false,
            'verify_peer_name' => false,
            'allow_self_signed' => true
        ]
        ]);
  $mail->From = "[email protected]";
  $mail->CharSet    = 'UTF-8'; 
  $mail->setLanguage('tr');

    //Recipients
  $mail->setFrom('[email protected]', 'Form');
  $mail->addAddress('[email protected]');     //Add a recipient
    
  $mail->Subject = $subject;
  $mail->Body    = $message;

  if(!$mail->Send())
  {
   echo "There is an error occured. <p>";
   echo "Mailer Error: " . $mail->ErrorInfo;
   exit;
  }
  $mail->send();
  echo "Message sent";
?>

and there is the error :

2023-06-09 19:22:55 CLIENT -> SERVER: EHLO example.com
2023-06-09 19:22:55 CLIENT -> SERVER: STARTTLS
2023-06-09 19:22:55 CLIENT -> SERVER: EHLO example.com
2023-06-09 19:22:55 CLIENT -> SERVER: AUTH LOGIN
2023-06-09 19:22:55 CLIENT -> SERVER: [credentials hidden]
2023-06-09 19:22:55 CLIENT -> SERVER: [credentials hidden]
2023-06-09 19:22:59 SMTP ERROR: Password command failed: 535 Login incorrect -ERR [email protected] password wrong or not a valid user
SMTP Error: Could not authenticate.
2023-06-09 19:22:59 CLIENT -> SERVER: QUIT
2023-06-09 19:22:59 CLIENT -> SERVER: EHLO akfetekstil.com
2023-06-09 19:22:59 CLIENT -> SERVER: STARTTLS
SMTP Hatası: SMTP sunucusuna bağlanılamadı. Connection failed. stream_socket_enable_crypto(): Peer certificate CN=*.kurumsaleposta.com' did not match expected CN=mail.example.com'
2023-06-09 19:22:59 CLIENT -> SERVER: QUIT
2023-06-09 19:22:59
SMTP connect() fonksiyonu başarısız. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

I am using Plesk. I have been looking the answer for days but I couldn't find any solution to this. What could be wrong with my code? I also did the Troubleshooting wiki log gave me.

@Synchro
Copy link
Member

Synchro commented Jun 9, 2023

SMTP Hatası: SMTP sunucusuna bağlanılamadı. Connection failed. stream_socket_enable_crypto(): Peer certificate CN=*.kurumsaleposta.com' did not match expected CN=mail.example.com'

This is the problem, and it's covered in the troubleshooting guide. By disabling certificate verification, you have exposed your credentials to a third party, though it's most likely your hosting provider. Your login doesn't work because you're not connecting to the server you asked for, but you disabled the mechanism that protects you against traffic interception attacks like that.

This really underlines that you really should not do that – disabling verification is simply hiding the symptom, which then means you go on to experience further failures that are a consequence, rather than fixing the cause of the problem.

@Synchro Synchro closed this as completed Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants