From b8fdec8fd586b7847f9575cb0848102d0f2747c2 Mon Sep 17 00:00:00 2001 From: Wolfgang Jentner Date: Sat, 22 Aug 2015 22:59:51 +0200 Subject: [PATCH] Added an example file explaining how to send signed emails --- examples/signed-mail.phps | 82 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 examples/signed-mail.phps diff --git a/examples/signed-mail.phps b/examples/signed-mail.phps new file mode 100644 index 000000000..a9c3140a1 --- /dev/null +++ b/examples/signed-mail.phps @@ -0,0 +1,82 @@ +setFrom('from@example.com', 'First Last'); +//Set an alternative reply-to address +$mail->addReplyTo('replyto@example.com', 'First Last'); +//Set who the message is to be sent to +$mail->addAddress('whoto@example.com', 'John Doe'); +//Set the subject line +$mail->Subject = 'PHPMailer mail() test'; +//Read an HTML message body from an external file, convert referenced images to embedded, +//convert HTML into a basic plain-text alternative body +$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__)); +//Replace the plain text body with one created manually +$mail->AltBody = 'This is a plain-text message body'; +//Attach an image file +$mail->addAttachment('images/phpmailer_mini.png'); + +//signing the email +$mail->sign('/path/to/cert.crt', //the location of your certificate file + '/path/to/cert.key', //the location of your private key file + 'yourSecretPrivateKeyPassword'); //the password you protected your private key with (may be empty but parameter can not mit omitted!) + //!!!! This is not the Import Password !!!! + +//send the message, check for errors +if (!$mail->send()) { + echo "Mailer Error: " . $mail->ErrorInfo; +} else { + echo "Message sent!"; +} + +/** + * REMARKS: + * If your email client does not support S/MIME it will most likely just show an attachment smime.p7s which is the signature contained in the email. + * Other clients, such as Thunderbird support S/MIME natively and will validate the signature automatically and report the result in some way. + */ +?> \ No newline at end of file