0

Hi my password 0028240Ba\ containt a backslash and can not working with my code PHP

$mail = new PHPMailer;
$mail->SMTPDebug = 3;                               // Enable verbose debug output
$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'smtp.example.ne.jp';  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'kazum@example.or.jp';                 // SMTP username
$mail->Password = '0028240Ba\'; //  SMTP password
$mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;                                    // TCP port to connect to
$mail->setFrom('kazum@example.or.jp', 'My cool website');  // The email address of your site goes here
$mail->addAddress('example@gmail.com', 'Important customer');     //Destination address and name

$mail->Subject = 'Just saying hi!'; //Title of your mail
$mail->Body    = '<h1> A test mail </h1>';
$mail->AltBody = 'Mail has been sent!';
if(!$mail->send()) {
    $data = array('mailissend' => false, 'message' => $mail->ErrorInfo);

} else {
    echo json_encode('Email is sended');
}

any solution to allowed backslash in the password area?

  • Add another slash to escape the first: `'0028240Ba\\'`. If you don't escape it, the backslash will be treated as an escape character for the `'`, giving you a syntax error. – M. Eriksson Jan 14 '22 at 21:31
  • @M. Eriksson im planing to make smtp tester i need to be able to put the smtp details using html inputs example https://www.emailier.com/smtp how i can solve backslash using input field ? – anchor luxury Jan 14 '22 at 22:12
  • The problem with `\'` only exists if you write the string out in your code like in the example (when the PHP parser needs to parse it). If you get the value from a form, it will work as is. – M. Eriksson Jan 14 '22 at 22:18
  • @M. Eriksson solved thankyou – anchor luxury Jan 14 '22 at 23:06

0 Answers0