add X-gpgmymail-Status header
This commit is contained in:
parent
182e1ceb43
commit
f5a31997cf
2 changed files with 21 additions and 2 deletions
11
README.md
11
README.md
|
@ -1,7 +1,14 @@
|
||||||
# gpgmymail
|
# gpgmymail
|
||||||
|
|
||||||
Takes an email from stdin and encrypts it using the recipient's PGP key,
|
Takes an email from stdin and encrypts it to stdout using the recipient's PGP
|
||||||
provided as an argument when calling the script.
|
key, provided as an argument when calling the script.
|
||||||
|
|
||||||
|
Leaves a `X-gpgmymail-Status` header on the email, which has the following
|
||||||
|
statuses:
|
||||||
|
|
||||||
|
* `entered` - the email has entered the encryption function, but not been
|
||||||
|
encrypted
|
||||||
|
* `encrypted` - the encryption function has encrypted the email
|
||||||
|
|
||||||
Written to be a Sieve filter to be used with `sieve_extprograms`. Can be used
|
Written to be a Sieve filter to be used with `sieve_extprograms`. Can be used
|
||||||
in a Sieve filter e.g.:
|
in a Sieve filter e.g.:
|
||||||
|
|
12
gpgmymail
12
gpgmymail
|
@ -24,6 +24,12 @@ works well for emails created with this tool. When encrypting, the tool
|
||||||
preserves all headers in the original email in the encrypted part, and
|
preserves all headers in the original email in the encrypted part, and
|
||||||
copies relevant headers to the output. When decrypting, any headers are
|
copies relevant headers to the output. When decrypting, any headers are
|
||||||
ignored, and only the encrypted headers are restored.
|
ignored, and only the encrypted headers are restored.
|
||||||
|
|
||||||
|
Emails exiting this script will have the 'X-gpgmymail-Status' header, which has
|
||||||
|
the following options:
|
||||||
|
|
||||||
|
- entered: the email has entered the encrypt() function
|
||||||
|
- encrypted: the email has been encrypted
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
@ -219,6 +225,9 @@ def encrypt(
|
||||||
blocks. find ignore_errors to see instances where this occurs
|
blocks. find ignore_errors to see instances where this occurs
|
||||||
|
|
||||||
:return: The encrypted email as a string"""
|
:return: The encrypted email as a string"""
|
||||||
|
|
||||||
|
# mark the email as having passed through us
|
||||||
|
set_email_header(message, 'X-gpgmymail-Status', 'entered')
|
||||||
|
|
||||||
# exclusion criteria:
|
# exclusion criteria:
|
||||||
# some mail clients like Thunderbird don't like twice-encrypted emails,
|
# some mail clients like Thunderbird don't like twice-encrypted emails,
|
||||||
|
@ -280,6 +289,9 @@ def encrypt(
|
||||||
set_email_header(encmsg, 'Subject', PEP_SUBJECT)
|
set_email_header(encmsg, 'Subject', PEP_SUBJECT)
|
||||||
set_email_header(encmsg, 'X-pEp-Version', '2.1')
|
set_email_header(encmsg, 'X-pEp-Version', '2.1')
|
||||||
|
|
||||||
|
# we have encrypted the email, set our gpgmymail header appropriately
|
||||||
|
set_email_header(encmsg, 'X-gpgmymail-Status', 'encrypted')
|
||||||
|
|
||||||
return encmsg.as_string()
|
return encmsg.as_string()
|
||||||
|
|
||||||
def decrypt(message: email.message.Message, *, encoding: str = DEFAULT_ENCODING) -> str:
|
def decrypt(message: email.message.Message, *, encoding: str = DEFAULT_ENCODING) -> str:
|
||||||
|
|
Loading…
Reference in a new issue