Encrypting and Sending Secure Emails Using S/MIME : mail « Utility Function « PHP






Encrypting and Sending Secure Emails Using S/MIME

 
<?php
$message_headers = array('To: p@example.com',
                         'From: b@example.com',
                         'Subject: Summary');
if (openssl_pkcs7_encrypt('espionage_summary.txt', 'espionage_summary.pkcs7',
 file_get_contents('phboss.crt'), $message_headers)) {
  mail('phboss@thingy.exmaple.com',
       'Espionage Summary',
       file_get_contents('espionage_summary.pkcs7'),
       $message_headers);
} else {
  die(openssl_error_string());
}
?>

<?php
$cert = file_get_contents('bob.crt');
$pkey = file_get_contents('bob.pem');
if (!openssl_pkcs7_decrypt('new_instructions.pkcs7',
                           'new_instructions.txt',
                           $cert, $pkey)) {
  die(openssl_error_string());
}
? >
  
  








Related examples in the same category

1.Add both name and address values into the email address
2.mail() function mails information to a given recipient.
3.mail-javascript.php
4.Using mail() to redirect user information
5.send-email-multiple-recipients-2.php
6.send-email-with-headers.php
7.send-mail-multiple-recipients.php
8.send-plaintext-email.php
9.Sending user-requested information
10.Sends a HTML mail from a given email address:
11.Sending Internet Mail
12.Sending Mail
13.Sending a message with mail()