phpmailer用于订单确认电子邮件的安全性

问题描述 投票:0回答:1

我不知道使用phpmailer进行确认电子邮件是否安全。

页面顺序如下:

order_confirmation.phpcheckout_process.php(用户从技术上看不到,这是页面定单确认信息发送到/电子邮件发送给用户并将订单添加到数据库)checkout_success.php

在checkout_process页面上,尽管我正在更改使用phpmailer发送电子邮件的方式,因为我们已经看到交换服务器/ gmail帐户将我们的电子邮件退回。

电子邮件现在可以正常工作,但是我想知道在checkout_process.php页面上保存我们的服务器信息/密码是否安全:

   try {
        //Server settings
        $mail->SMTPDebug = false;                      // Enable verbose debug output
        $mail->isSMTP();                                            // Send using SMTP
        $mail->Host       = 'smtp.office365.com';                    // Set the SMTP server to send through
        $mail->SMTPAuth   = true;                                   // Enable SMTP authentication
        $mail->Username   = '[email protected]';                     // SMTP username
        $mail->Password   = 'our actual password';                               // SMTP password
        $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;         // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` also accepted
        $mail->Port       = 587;                                    // TCP port to connect to

        //Recipients
        $mail->setFrom('[email protected]', 'company name');
        $mail->addAddress($order->customer['email_address'], $order->customer['firstname']);     // Add a recipient
        $mail->addReplyTo('[email protected]', 'company');




        // Content
        $mail->isHTML(true);                                  // Set email format to HTML
        $mail->Subject = EMAIL_TEXT_SUBJECT;
        $mail->Body    = $email_order;
        $mail->AltBody = 'Your order with our company has shipped';

        $mail->send();
        echo 'order confirmation sent to order#:<br/>';
    } catch (Exception $e) {
        echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
php security office365 phpmailer
1个回答
1
投票

为了使用任何邮件服务器,您必须提供秘密凭证,例如密码。这样做本身并不会使任何事情变得不安全。如果有人设法入侵您的服务器,他们可以看到此文件,因此也可以看到密码,但是,如果将其存储在其他位置,则他们可以遵循该文件将其提取的相同路径。 (例如,如果将其加密存储在数据库中,则该文件仍需要从黑客也可以访问的位置获取数据库凭据和解密密钥。)

就是说,如果这里的代码位于某种代码存储库中(可能是这样),那么not此处是包含密码的合适位置。除了入侵您的服务器之外,现在有人可以入侵您的存储库以获取密码。为避免此潜在问题,您的密码应存储在该文件可以引用的其他位置。如今,通常的做法是使用.env文件获取此类详细信息,而该文件仅存在于服务器上,而不存在于任何存储库中。附带的好处是,它无需更改代码即可轻松更改凭据(用于开发服务器等)。

© www.soinside.com 2019 - 2024. All rights reserved.