node-pgp-mail is a library to send PGP-encrypted e-mails. In the future, signing e-mails will also be supported.
Use the following code to initialise node-pgp-mail:
var pgpMail = ; var keyring; // node-pgp keyring objectvar mailer = keyring "SENDMAIL" "path": "/usr/sbin/sendmail" ;
The second and third parameter define the mail transport method, see the Nodemailer docu for the syntax.
getMailRecipient()
Finds out one e-mail address to send an e-mail to the owner of the key. Prefers the one of the primary identity, but if that does not contain one, uses the one of an arbitrary other identity.
var keyId = "012345678ABCDEFAB"; // 16-digit uppercase hex long key IDmailer;
sendEncryptedMail()
var to = "test@example.org";var subject = "Test e-mail";var body = "Test e-mail";var toKeyId = "012345678ABCDEFAB"; // 16-digit uppercase hex long key ID to encrypt tovar headers = "Reply-To": "test@example.com" ; // Optional additional e-mail headersmailer;
sendMail()
Sends an unencrypted mail.
var to = "test@example.org";var subject = "Test e-mail";var body = "Test e-mail";mailer;
In order to specify additional headers, use a Mime object instead of a string as text.
Mime
For the e-mail body, instead of a string, you can also specify a Mime object:
var contentType = "text/plain";var content = "Test e-mail";var headers = "Reply-To": "test@example.com" ;var transferEncoding = "quoted-printable";var body = contentType content headers transferEncoding;
This also supports multipart messages by specifying an array as content:
var body = "multipart/mixed" "text/plain" "Test part 1" "text/plain" "Test part 2";