diff options
authorCaleb Noelke <cjn075@sheriffmediocre.xyz>2023-02-22 14:59:27 -0500
committerCaleb Noelke <cjn075@sheriffmediocre.xyz>2023-02-22 14:59:27 -0500
commitcb549e1a98a1e936a98348517d507826defc2f68 (patch)
parente0ddb093fe333ad4c71080ccba062ef8de87acb5 (diff)
add readmeHEADmaster
2 files changed, 57 insertions, 2 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..ce250d9
--- /dev/null
+++ b/README.md
@@ -0,0 +1,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
+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
+*@example1.tld mail_domainkey.example1.tld
+*@example2.tld mail_domainkey.example2.tld
+*@example3.tld mail_domainkey.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.
diff --git a/addmailacc.sh b/addmailacc.sh
index 505346f..ffa7eea 100755
--- a/addmailacc.sh
+++ b/addmailacc.sh
@@ -2,8 +2,6 @@
#this script was written based off information from this github issue: https://github.com/LukeSmithxyz/emailwiz/issues/124
-#I plan on further expanding the functionality to include adding new domains to the appropriate postfix and opendkim configuration files and finally incorporate everything into the main emailwiz script
#retrieve the system mail name used during the inital postfix setup