I have installed gpg-mailgate from this repository on my server as stated in the INSTALL file.
It does seem to work, partially. As it would be expected, when sending an e-mail to an account on my server for which there is no GPG public key available, gpg-mailgate just forwards that e-mail. In the header, there is a gpg-mailgate status that says that there is no public key available and thus the message has not been encrypted.
I specify the e-mail addresses and the corresponding public key in the configuration file and send an e-mails to that account and according to the header information, it works. It says that it has used the saved public key to encrypt the message. However, it just seems to remove the body of the e-mail. The e-mails still arrive on the correct e-mail account on the server, but without any text in the body.
How can I make it work properly?
EDIT:
/etc/postfix/master.cf
:
smtp inet n - n - - smtpd
submission inet n - n - - smtpd
-o smtpd_tls_security_level=encrypt
-o smtpd_sasl_auth_enable=yes
smtps inet n - n - - smtpd
-o smtpd_tls_wrappermode=yes
-o smtpd_sasl_auth_enable=yes
pickup unix n - n 60 1 pickup
cleanup unix n - n - 0 cleanup
qmgr unix n - n 300 1 qmgr
tlsmgr unix - - n 1000? 1 tlsmgr
rewrite unix - - n - - trivial-rewrite
bounce unix - - n - 0 bounce
defer unix - - n - 0 bounce
trace unix - - n - 0 bounce
verify unix - - n - 1 verify
flush unix n - n 1000? 0 flush
proxymap unix - - n - - proxymap
proxywrite unix - - n - 1 proxymap
smtp unix - - n - - smtp
relay unix - - n - - smtp
showq unix n - n - - showq
error unix - - n - - error
retry unix - - n - - error
discard unix - - n - - discard
local unix - n n - - local
virtual unix - n n - - virtual
lmtp unix - - n - - lmtp
anvil unix - - n - 1 anvil
scache unix - - n - 1 scache
gpg-mailgate unix - n n - - pipe
flags= user=nobody argv=/usr/local/bin/gpg-mailgate.py ${recipient}
127.0.0.1:10028 inet n - n - 10 smtpd
-o content_filter=
-o receive_override_options=no_unknown_recipient_checks,no_header_body_checks
-o smtpd_helo_restrictions=
-o smtpd_client_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o mynetworks=127.0.0.0/8
-o smtpd_authorized_xforward_hosts=127.0.0.0/8
/etc/gpg-mailgate.conf
:
[default]
# whether gpg-mailgate should add a header after it has processed an email
# this may be useful for debugging purposes
add_header = yes
# whether we should only sign emails if they are explicitly defined in
# the key mappings below ([keymap] section)
# this means gpg-mailgate won't automatically detect PGP recipients
keymap_only = yes
[gpg]
# the directory where gpg-mailgate public keys are stored
# (see INSTALL for details)
keyhome = /var/gpg/.gnupg
[logging]
# For logging to syslog. 'file = syslog', otherwise use path to the file.
file = /tmp/gpg-mailgate.log
#verbose = yes
[relay]
# the relay settings to use for Postfix
# gpg-mailgate will submit email to this relay after it is done processing
# unless you alter the default Postfix configuration, you won't have to modify this
host = 127.0.0.1
port = 10028
[database]
# uncomment the settings below if you want
# to read keys from a gpg-mailgate-web database
#enabled = yes
#name = gpgmw
#host = localhost
#username = gpgmw
#password =
[keymap]
# You can find these by running the following command:
# gpg --list-keys --keyid-format long user@example.com
# Which will return output similar to:
# pub 1024D/AAAAAAAAAAAAAAAA 2007-10-22
# uid Joe User <user@example.com>
# sub 2048g/BBBBBBBBBBBBBBBB 2007-10-22
# You want the AAAAAAAAAAAAAAAA not BBBBBBBBBBBBBBBB.
#user@example.com = <gpg key id>
phil@phkr.de = 88A512E52095FF45
`/etc/postfix/main.cf (replaced my domain names and ssl paths for publication):
queue_directory = /var/spool/postfix
command_directory = /usr/bin
daemon_directory = /usr/lib/postfix/bin
data_directory = /var/lib/postfix
mail_owner = postfix
myhostname = www.myhostname.de
mydomain = myhostname.de
mydestination = localhost
unknown_local_recipient_reject_code = 550
alias_maps = hash:/etc/postfix/aliases
alias_database = $alias_maps
recipient_delimiter = +
home_mailbox = Maildir/
debug_peer_level = 2
debugger_command =
PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/bin/sendmail
newaliases_path = /usr/bin/newaliases
mailq_path = /usr/bin/mailq
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /etc/postfix/sample
readme_directory = /usr/share/doc/postfix
inet_protocols = ipv4
virtual_mailbox_domains = mydomain1.de mydomain2.de …
virtual_mailbox_base = /mail
virtual_mailbox_maps = hash:/etc/postfix/vmailbox
virtual_minimum_uid = 50
virtual_uid_maps = static:73
virtual_gid_maps = static:73
virtual_alias_maps = hash:/etc/postfix/virtual
mailbox_size_limit = 102400000
virtual_mailbox_limit = 0
# SASL SUPPORT FOR CLIENTS
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
broken_sasl_auth_clients = no
smtpd_sasl_security_options = noanonymous
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, check_relay_domains
smtpd_tls_security_level=may
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = mycert
smtpd_tls_key_file = mykeyfile
smtpd_tls_loglevel = 1
content_filter = gpg-mailgate
The versions:
$ postconf -d | grep mail_version
mail_version = 3.0.1
$ python2 --version
Python 2.7.10
EDIT 2:
(1) When sending an e-mail without gpg-mailgate enabled
/tmp/gpg-mailgate.log
:
Recipient (phil@phkr.de) not in domain list.
No encrypted recipients.
Sending email to: <phil@phkr.de>
(2) When sending an e-mail with gpg-mailgate enabled
/tmp/gpg-mailgate.log
:
Encrypting email to: phil@phkr.de
Sending email to: <phil@phkr.de>
EDIT 3:
gpg-mailgate disabled;
Return-Path: <phil.kraemer@student.uni-siegen.de>
X-Original-To: phil@phkr.de
Delivered-To: phil@phkr.de
Received: from www.phkr.de (localhost.localdomain [127.0.0.1])
by www.phkr.de (Postfix) with ESMTP id 812B1160BFB
for <phil@phkr.de>; Wed, 24 Jun 2015 18:51:29 +0200 (CEST)
Received: from esa-public.zimt.uni-siegen.de (esa-public.zimt.uni-siegen.de
[141.99.10.66]) by www.phkr.de (Postfix) with ESMTP id 3FAA915FC4E
for <phil@phkr.de>; Wed, 24 Jun 2015 18:51:29 +0200 (CEST)
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: A2DYBABE34pV/0ULY41bh2K5B4pjAQEBAQEBgQuETFUgHRYLAgsDAgECAUsNCAEBiC+nLo9flnaTP4FDBZQFlAOQBiaBSQELAYImgzUBAQE
X-IronPort-AV: E=Sophos;i="5.13,673,1427752800"; d="scan'208,217";a="22305746"
Received: from mail2.ad.uni-siegen.de (HELO mail.uni-siegen.de)
([141.99.11.69])
by esa-private.zimt.uni-siegen.de with ESMTP/TLS/AES128-SHA;
24 Jun 2015 18:51:27 +0200
Received: from phil-macbookpro.local (37.201.192.53) by mail.uni-siegen.de
(141.99.11.69) with Microsoft SMTP Server (TLS) id 14.3.224.2; Wed, 24 Jun
2015 18:51:26 +0200
Message-ID: <558AE00E.5000607@student.uni-siegen.de>
Date: Wed, 24 Jun 2015 18:51:26 +0200
From: =?UTF-8?B?UGhpbCBLcsOkbWVy?= <phil.kraemer@student.uni-siegen.de>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10;
rv:31.0) Gecko/20100101 Thunderbird/31.7.0
MIME-Version: 1.0
To: "phil@phkr.de" <phil@phkr.de>
Subject: Test
Content-Type: multipart/alternative;
boundary="------------030808040405090507040509"
X-PMWin-Version: 3.1.2.0, Antivirus-Engine: 3.55.0, Antivirus-Data: 5.14G
X-GPG-Mailgate: Not encrypted, public key not found
--------------030808040405090507040509
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo
ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis
dis parturient montes, nascetur ridiculus mus. Donec quam felis,
ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa
quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget,
arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.
Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras
dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend
tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac,
enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus.
Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean
imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper
ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus
eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing
sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar,
hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec
vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit
amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris
sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget
bibendum sodales, augue velit cursus nunc,
--------------030808040405090507040509
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: 7bit
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean
commodo ligula eget dolor. Aenean massa. Cum sociis natoque
penatibus et magnis dis parturient montes, nascetur ridiculus mus.
Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem.
Nulla consequat massa quis enim. Donec pede justo, fringilla vel,
aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut,
imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede
mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum
semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula,
porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem
ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra
nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet.
Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies
nisi. Nam eget dui.
Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem
quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam
quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem.
Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut
libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci
eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit
amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget
bibendum sodales, augue velit cursus nunc,
</body>
</html>
--------------030808040405090507040509--
gpg-mailgate enabled:
Return-Path: <phil.kraemer@student.uni-siegen.de>
X-Original-To: phil@phkr.de
Delivered-To: phil@phkr.de
Received: from www.phkr.de (localhost.localdomain [127.0.0.1])
by www.phkr.de (Postfix) with ESMTP id A8008160BFB
for <phil@phkr.de>; Wed, 24 Jun 2015 18:54:06 +0200 (CEST)
Received: from esa-public.zimt.uni-siegen.de (esa-public.zimt.uni-siegen.de
[141.99.10.65]) by www.phkr.de (Postfix) with ESMTP id 53AB5160BF9
for <phil@phkr.de>; Wed, 24 Jun 2015 18:54:06 +0200 (CEST)
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: A2DYBAA/4IpV/0cLY41bh2K5B4pjAQEBAQEBgQuETFUgHRYLAgsDAgECAUsNCAEBiC+nJY9flnWTP4FDBZQFlAOQBiaBSQELAYImgzUBAQE
X-IronPort-AV: E=Sophos;i="5.13,673,1427752800"; d="scan'208,217";a="22900624"
Received: from mail4.ad.uni-siegen.de (HELO mail.uni-siegen.de)
([141.99.11.71])
by esa-private.zimt.uni-siegen.de with ESMTP/TLS/AES128-SHA;
24 Jun 2015 18:54:05 +0200
Received: from phil-macbookpro.local (37.201.192.53) by mail.uni-siegen.de
(141.99.11.71) with Microsoft SMTP Server (TLS) id 14.3.224.2; Wed, 24 Jun
2015 18:54:05 +0200
Message-ID: <558AE0AC.1000302@student.uni-siegen.de>
Date: Wed, 24 Jun 2015 18:54:04 +0200
From: =?UTF-8?B?UGhpbCBLcsOkbWVy?= <phil.kraemer@student.uni-siegen.de>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10;
rv:31.0) Gecko/20100101 Thunderbird/31.7.0
MIME-Version: 1.0
To: "phil@phkr.de" <phil@phkr.de>
Subject: Test
Content-Type: multipart/alternative;
boundary="------------000505080606000302060009"
X-PMWin-Version: 3.1.2.0, Antivirus-Engine: 3.55.0, Antivirus-Data: 5.14G
X-GPG-Mailgate: Encrypted by GPG Mailgate
--------------000505080606000302060009
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
--------------000505080606000302060009
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: 7bit
--------------000505080606000302060009--