blob: ffa7eeaaf04701c537af3636e4ddaba2d5d27b07 (
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
|
#!/bin/sh
#this script was written based off information from this github issue: https://github.com/LukeSmithxyz/emailwiz/issues/124
address="$1"
#retrieve the system mail name used during the inital postfix setup
sysmailname=$(cat /etc/mailname)
#the expression "%%@*" means start at the @ symbol, delete it and everything after it
createunixuser() {
useradd -m -G mail ${address%%@*}
passwd ${address%%@*}
}
#if the address entered doesn't use the system mail name add a virtual alias entry
#to direct all mail sent to that address to the appropriate user's mailbox
virtualalias() {
echo "$address ${address%%@*}" >> /etc/postfix/virtual
postmap /etc/postfix/virtual
systemctl reload postfix
}
#check if the address entered contains the system mail name
#the expression "##*@" means start at the @ symbol, delete it and everything in front of it
if [ $sysmailname = ${address##*@} ]; then
createunixuser
else
createunixuser
virtualalias
fi
echo "Successfully added $address!"
|