如何使用 PHP Mailer 并确保我的 SMTP 凭据安全?
How to use PHP Mailer and keep my SMTP credentials secure?
如果我听起来像菜鸟,我深表歉意,但我..正在学习!
我很难思考如何确保我的凭据安全?在我的网站上使用 PHPMailer 作为联系表格。
在 SMTP 参数中,您应该非常明确地输入您的凭据:
/* SMTP parameters. */
/* Tells PHPMailer to use SMTP. */
$mail->isSMTP();
/* SMTP server address. */
$mail->Host = 'smtp.example.com';
/* Use SMTP authentication. */
$mail->SMTPAuth = TRUE;
/* Set the encryption system. */
$mail->SMTPSecure = 'tls';
/* SMTP authentication username. */
$mail->Username = 'smtp@example.com';
/* SMTP authentication password. */
$mail->Password = 'password';
/* Set the SMTP port. */
$mail->Port = 587;
这些凭据怎么可能不容易被盗?有没有办法更安全地隐藏它们并以某种方式让它们通过?将这些 PHPMailer 文件放在我的服务器上的最佳位置在哪里?它们应该在我网站文件所在的 'public_HTML' 文件夹中吗?
谢谢!
基本上,PHP 输出由服务器上的解释器读取并输出(通常)为 HTML。
网络服务器配置可以控制网络服务器提供哪些文件并可供查看/下载。在典型的 Web 服务器配置中,php 文件仅被解释,源代码无法通过 http 获得。您应该与您的托管服务提供商联系。
但是,您可能对 $_ENV 全局变量感兴趣,在使用时,可以在上下文之外设置值(不是直接在脚本中)。这主要用于避免在 git
等版本控制系统中存储敏感信息
如果我听起来像菜鸟,我深表歉意,但我..正在学习!
我很难思考如何确保我的凭据安全?在我的网站上使用 PHPMailer 作为联系表格。
在 SMTP 参数中,您应该非常明确地输入您的凭据:
/* SMTP parameters. */
/* Tells PHPMailer to use SMTP. */
$mail->isSMTP();
/* SMTP server address. */
$mail->Host = 'smtp.example.com';
/* Use SMTP authentication. */
$mail->SMTPAuth = TRUE;
/* Set the encryption system. */
$mail->SMTPSecure = 'tls';
/* SMTP authentication username. */
$mail->Username = 'smtp@example.com';
/* SMTP authentication password. */
$mail->Password = 'password';
/* Set the SMTP port. */
$mail->Port = 587;
这些凭据怎么可能不容易被盗?有没有办法更安全地隐藏它们并以某种方式让它们通过?将这些 PHPMailer 文件放在我的服务器上的最佳位置在哪里?它们应该在我网站文件所在的 'public_HTML' 文件夹中吗?
谢谢!
基本上,PHP 输出由服务器上的解释器读取并输出(通常)为 HTML。
网络服务器配置可以控制网络服务器提供哪些文件并可供查看/下载。在典型的 Web 服务器配置中,php 文件仅被解释,源代码无法通过 http 获得。您应该与您的托管服务提供商联系。
但是,您可能对 $_ENV 全局变量感兴趣,在使用时,可以在上下文之外设置值(不是直接在脚本中)。这主要用于避免在 git
等版本控制系统中存储敏感信息