Simple and clean mail server based on postfix (DKIM, TLS, SMTP, IMAP).
373
Assuming you have basic knowledge of Docker Containers and what they do. If not - please, go watch some online video presentation about that. Basically it's almost virtual machine, but not so bloated and resource hungry.
git clone https://github.com/kandev/postfix
cd postfix
docker-compose build
docker-compose up -d
Connecting to container:
docker exec -ti mail1 bash
docker create -h mail1 --name mail1 --network dmz --ip 172.20.0.3 -v mail1_config:/var/config -v /volumes/mail1/domains:/var/mail/domains:rw -v /volumes/mail1/letsencrypt:/etc/letsencrypt:rw -v /etc/localtime:/etc/localtime:ro kandev/postfix:latest
docker start mail1
DKIM key is automatically generated on image creation. Both private and publik keys are stored at /var/config directory. Please use the content of dkim_public.key to create TXT records in all required DNS zones.
default._domainkey 14400 IN TXT "v=DKIM1; k=rsa; p=MIGfMA0GCSqGS.....QAB"
If you want to create new key. Please use the following commands.
openssl genrsa -out /var/config/dkim_private.key 1024
openssl rsa -in /var/config/dkim_private.key -pubout | sed '1d;$d' | tr -d '\n' > /var/config/dkim_public.key
All accepted domains are filled in /var/config/postfix/mailbox_domains.
example.com
example.net
example.org
All mailboxes should be listed in /var/config/mailbox_maps, using the following format:
[email protected] example.com/ivan/
[email protected] example.org/petar/
Don't forget to run postmap mailbox_maps after update.
Specifyng SMTP address and mailbox directory where all the messages will be stored.
Access credentials are stored in /var/config/users
[email protected]:{CRAM-MD5}b1a3aca8da01c45eb94aa9e64d317d36785e7056b42t67e0ac1d6925ca1b11d7
Password is generated using doveadm pw.
Aliases are created in alias_maps.
Don't forget to run postmap alias_maps after update.
Addresses are listed in sender_access file. You should whitelist all backup mail servers, otherwise SPF will block all emails from them!
promocia.info REJECT You suck but yo mama sweet
1.2.3.4 REJECT
4.3.2.1 OK
[email protected] BCC [email protected]
You can use full email addresses, domains, ip addresses of mail servers. Full list of actions can be seen here. And of course - dont forget postmap sender_access after each update.
This means locking all authenticated users to send emails only as their own address. Permissions to another address can be given in login_maps.pcre.
/[email protected]/ [email protected]
/^(.*)$/ ${1}
This example allows authenticated user [email protected] to send emails as [email protected].
Initial creation of the certificate is manual.
certbot certonly --agree-tos -n --standalone -d mail.example.com
Daily cron job is running to automatically renew any expiring certificates.
To enable autodiscovery of server configuration parameters, create file named config-v1.1.xml with the following example content:
<?xml version="1.0" encoding="UTF-8"?>
<clientConfig version="1.1">
<emailProvider id="example.com">
<domain>example.com</domain>
<displayName>Example Corp Ltd.</displayName>
<displayShortName>Example</displayShortName>
<incomingServer type="imap">
<hostname>mail.example.com</hostname>
<port>143</port>
<socketType>STARTTLS</socketType>
<authentication>password-cleartext</authentication>
<username>%EMAILADDRESS%</username>
</incomingServer>
<outgoingServer type="smtp">
<hostname>mail.example.com</hostname>
<port>25</port>
<socketType>STARTTLS</socketType>
<authentication>password-cleartext</authentication>
<username>%EMAILADDRESS%</username>
</outgoingServer>
</emailProvider>
</clientConfig>
Update your server name and domain, then upload this file to your web server where example.com web site is hosted, in the following path - /.well-known/autoconfig/mail/.
If for some reason the client application which you use can't find your server details, you should fill them manually.
Here are some additional spices, which will make your mail service taste better :)
Content type
Image
Digest
Size
108.9 MB
Last updated
about 6 years ago
docker pull kandev/postfix