PHP的mail()函数已经加密了吗?
请告诉我PHP的mail()函数是否已经加密,或者我必须自己加密,我想安全地发送电子邮件。mail()函数将使用本地邮件程序(Linux)或连接到标准端口25(Windows)。绝对没有办法:PHP的mail()函数已经加密了吗?,php,email,Php,Email,请告诉我PHP的mail()函数是否已经加密,或者我必须自己加密,我想安全地发送电子邮件。mail()函数将使用本地邮件程序(Linux)或连接到标准端口25(Windows)。绝对没有办法: 使其使用另一个端口作为加密通道 提供身份验证数据 如果安全性(或可靠性)是一个问题,请不惜一切代价避免它。要将SSL或TLS与mail()一起使用,您必须配置“php.ini”(服务器上需要SSL): 但是,如果您更改服务器,则必须再次更改,因此我建议您不要使用mail()使用SMTP,而是使用现成
- 使其使用另一个端口作为加密通道
- 提供身份验证数据
如果安全性(或可靠性)是一个问题,请不惜一切代价避免它。要将SSL或TLS与
mail()
一起使用,您必须配置“php.ini”(服务器上需要SSL):
但是,如果您更改服务器,则必须再次更改,因此我建议您不要使用mail()
使用SMTP,而是使用现成的类,请参阅:
PHPMailer下载:
带有TLS的PHP编译器示例:
<?php
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'user@example.com'; // SMTP username
$mail->Password = 'secret'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
$mail->From = 'from@example.com';
$mail->FromName = 'Mailer';
$mail->addAddress('joe@example.net', 'Joe User'); // Add a recipient
$mail->addAddress('ellen@example.com'); // Name is optional
$mail->addReplyTo('info@example.com', 'Information');
$mail->addCC('cc@example.com');
$mail->addBCC('bcc@example.com');
$mail->WordWrap = 50; // Set word wrap to 50 characters
$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
安全旅行?使用https
将保护您的表单,直到邮递员从酒吧回来;如果他在那里成功了,并且/或者完整地回来了。电子邮件永远不会安全。这完全取决于您的SMTP服务器。mail
是最低级别的API。不,它没有加密功能。你在说什么样的加密?@Fred ii-?我想你是指SSL。
<?php
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'user@example.com'; // SMTP username
$mail->Password = 'secret'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
$mail->From = 'from@example.com';
$mail->FromName = 'Mailer';
$mail->addAddress('joe@example.net', 'Joe User'); // Add a recipient
$mail->addAddress('ellen@example.com'); // Name is optional
$mail->addReplyTo('info@example.com', 'Information');
$mail->addCC('cc@example.com');
$mail->addBCC('bcc@example.com');
$mail->WordWrap = 50; // Set word wrap to 50 characters
$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}