# node-pgp-mail

> Library to send PGP-encrypted and signed e-mails.

Latest version **0.0.1** (published 2013-06-14) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install node-pgp-mail
pnpm add node-pgp-mail
yarn add node-pgp-mail
bun add node-pgp-mail
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2013-06-14 |
| First published | 2013-06-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+10 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | cdauth |

## Links

- npm: https://www.npmjs.com/package/node-pgp-mail
- Repository: https://github.com/cdauth/node-pgp-postgres
- npm.io page: https://npm.io/package/node-pgp-mail

## Dependencies (4)

- [async](https://npm.io/package/async.md) 0.2.x
- [mimelib](https://npm.io/package/mimelib.md) 0.2.x
- [node-pgp](https://npm.io/package/node-pgp.md) 0.0.x
- [nodemailer](https://npm.io/package/nodemailer.md) 0.4.x

## Recent versions

- 0.0.1 (latest) — 2013-06-14

## README

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:

```javascript
var pgpMail = require("node-pgp-mail");

var keyring; // node-pgp keyring object
var mailer = new pgpMail(keyring, "SENDMAIL", { "path": "/usr/sbin/sendmail" });
```

The second and third parameter define the mail transport method, see
[the Nodemailer docu](https://github.com/andris9/Nodemailer#setting-up-a-transport-method)
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.

```javascript
var keyId = "012345678ABCDEFAB"; // 16-digit uppercase hex long key ID
mailer.getMailRecipient(keyId, function(err, recipient) {
	if(err)
		; // An error occurred

	// recipient is a string or null if none was found
});
```

sendEncryptedMail()
-------------------

```javascript
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 to
var headers = { "Reply-To": "test@example.com" }; // Optional additional e-mail headers
mailer.sendEncryptedMail(to, subject, body, toKeyId, function(err) {
	if(err)
		; // An error occurred
}, headers);
```


sendMail()
----------

Sends an **unencrypted** mail.

```javascript
var to = "test@example.org";
var subject = "Test e-mail";
var body = "Test e-mail";
mailer.sendMail(to, subject, body, function(err) {
	if(err)
		; // An error occurred
});
```

In order to specify additional headers, use a [Mime](#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:

```javascript
var contentType = "text/plain";
var content = "Test e-mail";
var headers = { "Reply-To": "test@example.com" };
var transferEncoding = "quoted-printable";
var body = new pgpMail.Mime(contentType, content, headers, transferEncoding);
```

This also supports multipart messages by specifying an array as content:

```javascript
var body = new pgpMail.Mime("multipart/mixed", [
    new pgpMail.Mime("text/plain", "Test part 1"),
    new pgpMail.Mime("text/plain", "Test part 2")
]);
```

---
_Source: https://npm.io/package/node-pgp-mail · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
