md5 password with phpMailer

前端 未结 2 1990
生来不讨喜
生来不讨喜 2021-01-16 07:22

I use the following code...

      $mail = new PHPMailer();  
      $mail->IsSMTP(); // send via SMTP
      $mail->SMTPAuth = true; // turn on SMTP auth         


        
2条回答
  •  攒了一身酷
    2021-01-16 07:52

    You have to send plain password to SMTP. Hash functions are one-way, they just "obfuscates" the input, so SMTP can not authenticate you with it.

    You could encrypt the password, probably AES, and you store the ciphertext, and the secret (maybe as env. variable), and pass the decoded pass to mailer.

    Example:

    Username = $USR_EMAIL; // SMTP username
    $mail->Password = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $secret_key, $cipher, MCRYPT_MODE_ECB); // SMTP password
    ?>
    

提交回复
热议问题