Pergunta

I want to create a new email account which only receives encrypted email. Unfortunately, I cannot modify the mail server configuration so I considered checking incoming email every 2 minutes with a cronjob and automatically rejecting those messages which are not encrypted.

So far I did this:

$body = imap_body($mbox, $i);
if (substr($body,0,27) == "-----BEGIN PGP MESSAGE-----")
    $encrypted = true;
else
    $encrypted = false;

Works, but I'm pretty sure I don't capture all encrypted email. I didn't find a unique option in the header which would tell me that a message is encrypted. Enigmail left a message though:

X-Enigmail-Version: 1.5.1

This, however, does not help me in any way. Is it enough to just grep for the BEGIN PGP MESSAGE string as I did above?

Foi útil?

Solução

As a student of computational linguistics my first idea was to try it statistically:

As far as I know encrypted messages do not contain spaces. So you could tokenize the email body into words, and calculate the average length of the words. Try this on some other mails or texts and see how the average length differs.

It may be a bit extravagant, but is more effective than looking for a substring: for example someone may send a webpage or text dealing with encryption or the latest NSA leaks ;-)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top