Reputation: 27685
How to use this python library from the command line?
https://pypi.python.org/pypi/dkimpy
I have a raw email message I want to validate the DKIM signature.. But how.. Can't find any docs about the usage
The raw message is a string/stream
Upvotes: 1
Views: 2180
Reputation: 5728
First I needed a test message, this is how I got one:
~/original_msg.txt
I then opened up a terminal window and made sure I was in my home directory:
$ cd ~
Then I installed dkimpy:
$ pip install dkimpy
Annoyingly, dkimverify --help
didn't work, but man
came to the rescue:
$ man dkimverify
dkimverify(1)
NAME
dkimverify - Script for DKIM verifying messages on stdin
DESCRIPTION
dkimverify reads an RFC822 message on standard input, and returns with exit code 0
if the signature verifies successfully. Otherwise, it returns with exit code 1.
so I verified my downloaded Gmail message:
$ cat original_msg.txt | dkimverify
signature ok
$ echo $?
0
And just to make sure it failed as expected, I created a bogus message:
$ echo "bogus-header:bogus email" > bogus_msg.txt
And then tried to validate it:
$ cat bogus_msg.txt | dkimverify
signature verification failed
$ echo $?
1
Upvotes: 2