What are the potential security risks of using unencrypted usernames and passwords in PHP scripts for accessing POP3 mailboxes?

Storing usernames and passwords in plain text within PHP scripts poses a significant security risk as anyone with access to the code can easily view and misuse these credentials. To mitigate this risk, it is recommended to store sensitive information in a secure manner, such as using encryption or secure storage methods.

// Example of securely storing credentials using environment variables
$host = 'pop.example.com';
$port = 110;
$username = getenv('POP_USERNAME');
$password = getenv('POP_PASSWORD');

// Connect to POP3 mailbox using secure credentials
$connection = new \Swoole\Coroutine\Client(SWOOLE_SOCK_TCP);
$connection->connect($host, $port);
$connection->send("USER $username\r\n");
$connection->send("PASS $password\r\n");

// Rest of the POP3 functionality here