0

For a customer (doctor) I have created a contact form. In the mailer.php configuration the email password is entered in plain text in an array. Of course, a doctor is not allowed to give me his password, otherwise I would have access from his confidential mails.

$hash = '$2y$10$d8QH/GEteeeZIHf8ohw.1eKtr7p0G92OaQDo6fFNN3fMi73BsS0WC'; // password: 123

$config['smtp'] = array(
'host' => 'mailout.server.com',
'port' => 465,
'username' => 'the-username',
'password' => '123', // i wanna use $hash instead of plaintext password
'encryption' => 'ssl'
);   

How can I use a hashed password in the array? The password_verify function is unnecessary for this, as no password is entered into a form and needs to be verified. It's just a matter of not entering the password in plain text in the configuration. Unfortunately I have not found a solution for this.

Many thanks for your support!

3
  • 4
    If you want to authenticate the user on another server (like an SMTP) using PHP, you will need the password in plain text. There's not really any way around it, unless the mail server has some alternative API using OAuth or similar. That SMTP server won't accept a hash, it will expect the password in plain text. The reason you hash passwords are so no one can read it and use it. If you could use a hash instead of the plain text password, it would make hashing them completely useless. Commented Jan 22, 2023 at 10:39
  • Thank you for the detailed explanation. I used a different solution and created a new email account and used the credentials from it. This works very well in my case. I am sure there are better concepts for this, however I have not found an alternative due to lack of time. Commented Jan 22, 2023 at 13:17
  • “Doctor”, “password” and “email”, when used together, raise flags. You say “lack of time” but I hope you revisit this. Commented Jan 22, 2023 at 15:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.