SMTP Server with Roundcube Webmail on Ubuntu 22.04


### buat sub domain baru

nano /etc/bind/db.saptonoisme.ac.id.db


#tambahkan pada bagian bawah

dns     IN      A       192.168.26.100

mail    IN      A       192.168.26.100


systemctl restart bind9


### rubah resolv.conf

nameserver 192.168.26.100

nameserver 127.0.0.53


### Install Postfix

apt -y install postfix sasl2-bin

#pilih No configuration  


cp /usr/share/postfix/main.cf.dist /etc/postfix/main.cf

nano /etc/postfix/main.cf


mail_owner = postfix

myhostname = mail.saptonoisme.ac.id

mydomain = saptonoisme.ac.id

myorigin = $mydomain

inet_interfaces = all

mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

local_recipient_maps = unix:passwd.byname $alias_maps

mynetworks_style = subnet

mynetworks = 127.0.0.0/8, 192.168.26.0/24

alias_maps = hash:/etc/aliases

alias_database = hash:/etc/aliases

home_mailbox = Maildir/

#smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)

smtpd_banner = $myhostname ESMTP

sendmail_path = /usr/sbin/postfix

newaliases_path = /usr/bin/newaliases

mailq_path = /usr/bin/mailq

setgid_group = postdrop

#html_directory =

#manpage_directory =

#sample_directory =

#readme_directory =

inet_protocols = all

#tambahkan pada bagian bawah

disable_vrfy_command = yes

smtpd_helo_required = yes

message_size_limit = 10240000

smtpd_sasl_type = dovecot

smtpd_sasl_path = private/auth

smtpd_sasl_auth_enable = yes

smtpd_sasl_security_options = noanonymous

smtpd_sasl_local_domain = $myhostname

smtpd_recipient_restrictions = permit_mynetworks, permit_auth_destination, permit_sasl_authenticated, reject


newaliases

systemctl restart postfix


### Install Dovecot

apt -y install dovecot-core dovecot-pop3d dovecot-imapd

sudo apt-get install dovecot-mysql

nano /etc/dovecot/dovecot.conf


listen = *, ::


nano /etc/dovecot/conf.d/10-auth.conf


disable_plaintext_auth = no

auth_mechanisms = plain login


nano /etc/dovecot/conf.d/10-mail.conf


mail_location = maildir:~/Maildir


nano /etc/dovecot/conf.d/10-master.conf


# Postfix smtp-auth

  unix_listener /var/spool/postfix/private/auth {

    mode = 0666

    user = postfix

    group = postfix

  }


(opsional)

### Buat SSL Certificate

apt -y install certbot

certbot certonly --webroot -w /var/www/html -d dns.saptonoisme.ac.id

(Enter 'c' to cancel): root@mail.saptonoisme.ac.id

Y

Y

(opsional)


### buat database baru dengan nama roundcube serta diberi password


### Install roundcube webmail

apt update

apt -y install roundcube roundcube-mysql

#pilih no

cd /usr/share/dbconfig-common/data/roundcube/install

mariadb -u roundcube -D roundcube -p < mysql

nano /etc/roundcube/debian-db.php


$dbuser='roundcube';

$dbpass='password';

$basepath='';

$dbname='roundcube';

$dbserver='localhost';

$dbport='3306';

$dbtype='mysql';


nano /etc/roundcube/config.inc.php


$config['default_host'] = 'mail.saptonoisme.ac.id';

$config['smtp_server'] = 'mail.saptonoisme.ac.id';

$config['smtp_port'] = 587;

$config['smtp_user'] = '%u';

$config['smtp_pass'] = '%p';

$config['product_name'] = 'Saptonoisme Webmail';


#tambahkan pada bagian paling bawah

$config['default_port'] = 143;


# specify SMTP auth type

$config['smtp_auth_type'] = 'LOGIN';


# specify SMTP HELO host

$config['smtp_helo_host'] = 'mail.saptonoisme.ac.id';


# specify domain name

$config['mail_domain'] = 'saptonoisme.ac.id';


# specify UserAgent

$config['useragent'] = 'Saptonoisme Webmail';


# specify SMTP and IMAP connection option

$config['imap_conn_options'] = array(

  'ssl'         => array(

    'verify_peer' => true,

    'CN_match' => 'saptonoisme.ac.id',

    'allow_self_signed' => true,

    'ciphers' => 'HIGH:!SSLv2:!SSLv3',

  ),

);

$config['smtp_conn_options'] = array(

  'ssl'         => array(

    'verify_peer' => true,

    'CN_match' => 'saptonoisme.ac.id',

    'allow_self_signed' => true,

    'ciphers' => 'HIGH:!SSLv2:!SSLv3',

  ),

);



nano /etc/apache2/conf-enabled/roundcube.conf


Alias /roundcube /var/lib/roundcube/public_html