What are the potential risks of sending unencrypted sensitive data through email in a PHP application?

Sending unencrypted sensitive data through email in a PHP application can expose the information to potential interception by malicious actors. To mitigate this risk, it is important to encrypt the data before sending it through email using secure encryption methods such as OpenSSL.

// Encrypt sensitive data before sending it through email
$plaintext = "Sensitive data to be encrypted";
$key = openssl_random_pseudo_bytes(32);
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-cbc'));
$ciphertext = openssl_encrypt($plaintext, 'aes-256-cbc', $key, 0, $iv);

// Send the encrypted data through email
// Add code to send email with $ciphertext as the message body