我的网站上有SSL。
我想加密来自我服务器的外发电子邮件。我一直在挖这个,我真的不知道从哪里开始。
这是我的PHP电子邮件脚本,因此您可以了解我正在使用的内容:
public function email($to, $title, $message){
$from = "angela@mysite.com";
$headers = "From: {$from}\r\n";
$headers .= "X-Confirm-Reading-To: {$from}\r\n";
$headers .= "Reply-To: {$from}\r\n";
$headers .= "Organization: InfiniSys, inc.\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=ISO-8859-1\r\n";
$headers .= "X-Priority: 3\r\n";
$headers .= "X-Mailer: PHP". phpversion() ."\r\n";
$subject = $title;
mail($to, $subject, $message, $headers);
}
Ubuntu 14.04
我不确定这是服务器设置还是编程配置。
非常有趣的帖子:(不记得我在哪里得到它)
<?php
// Setup mail headers.
$headers = array("From" => "someone@example.com",
"To" => "someone-else@example.com",
"Cc" => "spam@somewhere.org",
"Subject" => "Encrypted mail readable with most clients",
"X-Mailer" => "PHP/".phpversion()
);
// Get the public key certificate.
$pubkey = file_get_contents("C:\test.cer");
// Remove some double headers for mail()
$headers_msg = $headers;
unset($headers_msg['To'], $headers_msg['Subject']);
$data = <<
This email is Encrypted!
You must have my certificate to view this email!
Me
EOD;
//write msg to disk
$fp = fopen("C:\msg.txt", "w");
fwrite($fp, $data);
fclose($fp);
// Encrypt message
openssl_pkcs7_encrypt("C:\msg.txt","C:\enc.txt",$pubkey,$headers_msg,PKCS7_TEXT,1);
// Seperate headers and body for mail()
$data = file_get_contents("C:\enc.txt");
$parts = explode("\n\n", $data, 2);
// Send mail
mail($headers['To'], $headers['Subject'], $parts[1], $parts[0]);
// Remove encrypted message (not fot debugging)
//unlink("C:\msg.txt");
//unlink("C:\enc.txt");
?>
答案 0 :(得分:2)
尝试使用PHPMAILER它非常简单 您可以从Cpanel电子邮件帐户选项中找到所有用户名和密码
$to= "example@gmail.com";
require 'phpmailerlibrary/PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'mail.example.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'support@example.com'; // SMTP username
$mail->Password = '*****'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 25; // TCP port to connect to
$mail->setFrom('support@twekr.com', 'example Inc.');
$mail->addAddress($to); // Add a recipient
$mail->addReplyTo('support@example.com', 'Support');
$mail->addCC($to);
$mail->addBCC($to);
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Subject of Email';
$mail->Body = 'Content of your html email';
$mail->AltBody = 'Please Upgrade Your Browser to view this email';
if(!$mail->send()) {
echo "Unable to send email"; exit;
}
你应该使用TLS,因为它也是90%网站使用的加密方法,包括google。
答案 1 :(得分:0)