aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: ce250d921be8ad00ae7ca2bccaa96b467e01ef3e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
## Automatically add mail accounts
This script will automatically create an account for a mail server configured with [emailwiz](https://github.com/lukesmithxyz/emailwiz).
It can also add accounts for separate domains configured for the mail server with postfix aliases.

I've written up a guide for setting up secondary domains based off of [this issue](https://github.com/LukeSmithxyz/emailwiz/issues/124).
You will need to add this to your server's configuration *before* you add accounts on secondary domains with this script.
I may or may not script this later on.
Add virtual aliases to /etc/postfix/virtual:

```
@example2.tld user2
@example3.tld user3 # forward mail to from a domain to a specific UNIX user

user2@example.tld user2
user3@example.tld user3 # forward mail - aliased - from a singular domain to multiple UNIX users
```
run postmap /etc/postfix/virtual so postfix will make/utilize a hashtable

Add these lines to /etc/postfix/main.cf:
```
relay_domains = example1.tld, example2.tld, example3.tld...
....
virtual_alias_maps = hash:/etc/postfix/virtual
virtual_alias_domains = $virtual_alias_maps
```

Add these lines to your opendkim configuration
```
/etc/postfix/dkim/keytable:

mail._domainkey.example1.tld example1.tld:mail:/etc/postfix/dkim/example1.tld/mail.private
mail._domainkey.example2.tld example2.tld:mail:/etc/postfix/dkim/example2.tld/mail.private
mail._domainkey.example3.tld example3.tld:mail:/etc/postfix/dkim/example3.tld/mail.private

/etc/postfix/dkim/signingtable

*@example1.tld mail_domainkey.example1.tld
*@example2.tld mail_domainkey.example2.tld
*@example3.tld mail_domainkey.example3.tld

/etc/postfix/dkim/trustedhosts
127.0.0.1
localhost
*.example1.tld
*.example2.tld
*.example3.tld
```


You need to manually generate dkim keys for each subsequent domain you use with the server
```
mkdir -p "/etc/postfix/dkim/example2.tld"
opendkim-genkey -D "/etc/postfix/dkim/example2.tld" -d "example2.tld" -s "mail"
chgrp -R opendkim /etc/postfix/dkim/*
chmod -R g+r /etc/postfix/dkim/*
```
Then you need to grab the keys from ```/etc/postfix/dkim/example2.tld/mail.txt``` and paste it into your registrar's txt records along with the dmarc and spf nonsense.