Add send_pgp_mime usage example.
authorW. Trevor King <wking@drexel.edu>
Sat, 20 Nov 2010 11:39:55 +0000 (06:39 -0500)
committerW. Trevor King <wking@drexel.edu>
Sat, 20 Nov 2010 11:45:40 +0000 (06:45 -0500)
posts/send_pgp_mime.mdwn

index e213a0c05fa6ca2838a3aafc11348f6a0324976b..ddc269f9c3e48d4f8b53996c2f873424a53d5461 100644 (file)
@@ -10,15 +10,30 @@ a script to automatically email grades out to my students (not that
 any of the student's care about PGP, but it's the principle of the
 thing ;), since there's no way I'm going to send them raw gpg output
 (they would die) and there's also no way I'm going to hold Mutt's hand
-while it signs the emails.  I dunno why Mutt doesn't have some --batch
-mode options to support PGP, but there it is.
+while it signs the emails.  I dunno why Mutt doesn't have some
+`--batch` mode options to support PGP, but there it is.
 
-So I wrote my own.  Not very complicated really, just implementing the
-[RFC 3156](http://www.ietf.org/rfc/rfc3156.txt) specs.  There's
-obviously room for improvement, but it works well enough to make me
-happy at the momemt.  You're welcome to [take a
-look](/~wking/code/python/send_pgp_mime) and [[email me|contact]] with
-[encrypted!] feedback.
+So I [wrote my own][send_pgp_mime.py].  Not very complicated really,
+just implementing the [RFC 3156][] specs.  There's obviously room for
+improvement, but it works well enough to make me happy at the momemt.
+[[Email me|contact]] with (encrypted!) feedback.
+
+    echo 'use_agent' >> ~/.gnupg/gpg.conf
+    export GPG_TTY=$(tty)
+    eval $(gpg-agent --daemon)
+    FROM="From: me@example.edu"
+    for student in $(cat big_list); do
+        HEAD=$(echo -e "$FROM\nTo: $STUDENT@example.edu\nSubject: Grades")
+        BODY=$(echo -e "$STUDENT,\n\nGood job!")
+        send_pgp_mime -H <(echo "$HEAD") -B <(echo "$BODY") --mode sign
+    done
+
+Note that I'm brushing some `gpg-agent` details under the rug.  `man
+gpg-agent` does a reasonable job of clarifying.
+
+[send_pgp_mime.py]: http://www.physics.drexel.edu/~wking/code/git/gitweb.cgi?p=be.git;a=blob;f=interfaces/email/interactive/send_pgp_mime.py
+[RFC 3156]: http://www.ietf.org/rfc/rfc3156.txt
 
 [[!tag tags/linux]]
 [[!tag tags/programming]]
+[[!tag tags/python]]