-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathemail_server_setup.sh
More file actions
66 lines (51 loc) · 1.61 KB
/
email_server_setup.sh
File metadata and controls
66 lines (51 loc) · 1.61 KB
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
58
59
60
61
62
63
64
65
66
#!/bin/bash
if [ $(id -u) != 0 ]
then
echo "\033[1;37;40mThis script must be run as root user . \nGo back and try again as root user\033[0m"
exit 1
fi
echo $(hostname)
echo '\033[1;37;40m Updating and installing packages \033[0m'
sudo apt-get update
sudo apt-get install -y postfix dovecot-common dovecot-pop3d dovecot-imapd mailutils
echo '\033[1;37;40m'
service dovecot status
service postfix status
echo '\033[0m'
#changing in postfix file
touch aliases transport
#chaing in main.cf
printf '\n transport_maps = hash:/etc/postfix/transport \n'
sed -i 's/.*inet_interfaces.*/inet_interfaces = all /' /etc/postfix/main.cf
sed -i 's/.*inet_interfaces = localhost.*/#inet_interfaces = localhost /' /etc/postfix/main.cf
#update aliases transport databases
postalias aliases
postmap transport
postmap hash:/etc/postfix/transport
# changing in dovecot confg file
#file path /etc/dovecot/conf.d/10-mail.conf
sed -i 's/.*mail_privileged.*/mail_privileged_group = mail /' /etc/dovecot/conf.d/10-mail.conf
sed -i 's/.*mail_location.*/mail_location = mbox:~/mail:INBOX=/var/mail/%u /' /etc/dovecot/conf.d/10-mail.conf
service dovecot restart
service postfix restart
echo '\033[1;37;40m'
echo 'For any error see log file\npath = /var/log/mail.log'
echo '\033[0m'
while true
do
echo 'If you want to add new user press (y or n)'
read choice
if [ "$choice" = "y" ]
then
echo 'Enter New User name'
read name
echo 'Enter password'
read password
echo "$password\n$password\n\n\n\n\ny"|sudo adduser $name
echo ' \n \033[1;37;40m'
echo $name
echo 'added successfully as a user \033[0m\n'
else
break
fi
done