Membangun Servermail (Postfix & Courier) dan Webmail (Roundcube) di Ubuntu

 Untuk melakukan instalasi Webmail Client seperti Roundcube terlebih dahulu kita harus wajib memiliki Mail Server. dan untuk membuat Mail Server hal utama yang diperlukan adalah sebuah DNS Server yang telah memiliki MX Record.



IP Address :             172.23.2.189
Distributor ID: Ubuntu
Description:         Ubuntu 22.04 LTS
Release:                 22.04
Codename:         jammy

Setup DNS Server

1. Install paket bind9

root@server1:~# apt install bind9

2. Buka direktori konfigurasi bind di /etc/bind/ dan konfigurasi file forward serta reverse ditambah konfig zone

root@server1:~# cd /etc/bind
root@server1:/etc/bind# cp db.127 db.reverse
root@server1:/etc/bind# cp db.local db.forward

  • konfig file forward

root@server1:/etc/bind# vim db.forward 


;
; BIND data file for local loopback interface
;
$TTL    604800
@       IN      SOA     zekzek.care. root.zekzek.care. (
                              2         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      zekzek.care.
           IN      MX    172 zekzek.care.
@       IN       A       172.23.2.189
www     IN    A       172.23.2.189
mail    IN      A      172.23.2.189
blog    IN      CNAME   www

  • konfig file reverse

;
; BIND reverse data file for local loopback interface
;
$TTL    604800
@       IN      SOA     zekzek.care. root.zekzek.care. (
                              1         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      zekzek.care.
189     IN      PTR     zekzek.care.

  • konfig named.conf.default-zone

// prime the server with knowledge of the root servers
zone "zekzek.care" {
        type master;
        file "/etc/bind/db.forward";
};
zone "2.23.172.in-addr.arpa" {
        type master;
        file "/etc/bind/db.reverse";
};

  • Edit file conf.local.option
options {
        directory "/var/cache/bind";

        // If there is a firewall between you and nameservers you want
        // to talk to, you may need to fix the firewall to allow multiple
        // ports to talk.  See http://www.kb.cert.org/vuls/id/800113

        // If your ISP provided one or more IP addresses for stable
        // nameservers, you probably want to use them as forwarders.
        // Uncomment the following block, and insert the addresses replacing
        // the all-0's placeholder.

        // forwarders {
        //      8.8.8.8;
        // };

        //========================================================================
        // If BIND logs error messages about the root key being expired,
        // you will need to update your keys.  See https://www.isc.org/bind-keys
        //========================================================================
        dnssec-validation no;

        listen-on-v6 { any; };
};


4. Restart service bind

root@server1:/etc/bind# systemctl restart bind9

5. Install resolvconf untuk persisten nameserver

root@server1:/etc/bind# apt install resolvconf

6. Tambahkan namserver di head
root@server1:~# vim /etc/resolvconf/resolv.conf.d/head 
nameserver 172.23.2.189

dan ganti yang ada di /etc/resolv.con dengan nameserver 172.23.2.189

7. Cek hasil dns dengan perintah seperti berikut

 root@server1:~# nslookup 172.23.2.189
189.2.23.172.in-addr.arpa name = zekzek.care.

root@server1:~# nslookup zekzek.care
Server: 172.23.2.189
Address: 172.23.2.189#53

Name: zekzek.care
Address: 172.23.2.189

Instalasi Servermail menggunakan postfix & courier




1. Cek konfigurasi mail exchanger 

root@server1:~# nslookup
> set q=mx
> zekzek.care
Server: 172.23.2.189
Address: 172.23.2.189#53

zekzek.care mail exchanger = 172 zekzek.care.

2. install postfix dan courir 

root@server1:~# apt install postfix courier-imap courier-pop

3. Selama proses instalasi terdapat pop up yang muncul seperti berikut, ikuti seperti pada gambar







4.  Buat direktori untuk mail dan konfigurasi posfix

root@server1:~# maildirmake /etc/skel/Maildir
root@server1:~# maildirmake $HOME/Maildir
root@server1:~# nano /etc/postfix/main.cf

  • Konten

# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 3.6 on
# fresh installs.
compatibility_level = 3.6



# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_security_level=may

smtp_tls_CApath=/etc/ssl/certs
smtp_tls_security_level=may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache


smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = server1
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, zekzek.care, localhost, localhost.localdomain, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 0.0.0.0/0
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
home_mailbox = Maildir/


5.  Restart postfix
root@server1:~# systemctl restart postfix

6. Pengujian

  • Buat User 
            root@server1:~# adduser jak
            root@server1:~# adduser mark

  • Akses telnet karena smtp aktif
 root@server1:~# telnet zekzek.care 25
Trying 172.23.2.189...
Connected to zekzek.care.
Escape character is '^]'.
220 server1 ESMTP Postfix (Ubuntu)
mail from:jak@zekzek.care
250 2.1.0 Ok
rcpt to:mark@zekzek.care
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
Selamat kamu mendapatkan voucher untuk klaim tesla silahkan klik link ini zakrmdn.blogspot.com                                                    
.
250 2.0.0 Ok: queued as D3D8DE511F

  • Dan untuk membaca hasil mailnya berikut
root@server1:~# telnet zekzek.care 110
Trying 172.23.2.189...
Connected to zekzek.care.
Escape character is '^]'.
+OK Hello there.
user mark
+OK Password required.
pass 123
+OK logged in.
stat
+OK 1 472
retr 1
+OK 472 octets follow.
Return-Path: <jak@zekzek.care>
X-Original-To: mark@zekzek.care
Delivered-To: mark@zekzek.care
Received: from zekzek.care (zekzek.care [172.23.2.189])
by server1 (Postfix) with SMTP id D3D8DE511F
for <mark@zekzek.care>; Mon, 12 Sep 2022 05:43:46 +0000 (UTC)
Message-Id: <20220912054400.D3D8DE511F@server1>
Date: Mon, 12 Sep 2022 05:43:46 +0000 (UTC)
From: jak@zekzek.care

Selamat kamu mendapatkan voucher untuk klaim tesla silahkan klik link ini.blogspot.com
.

Instalasi Webmail (Roundcube)

Roundcube merupakan salah satu webmail populer yang hingga saat ini masih banyak digunakan dikarenakan konfigurasinya yang mudah serta tampilan hingga fungsi-fungsi yang bisa dicustom secara manual. 


1. Install paket roundcube

root@server1:~# apt install -y roundcube

    Akana ada beberapa popup konfigurasi core dari roundcube yang dimana roundcube meminta untuk mengakses database agar mengamnahkan database roundcube



2. Config 

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

uncomment kan Alias 
# Those aliases do not work properly with several hosts on your apache server
# Uncomment them to use it or adapt them to your configuration
    Alias /roundcube /var/lib/roundcube/public_html

3. Restart apache

root@server1:~# systemctl restart apache2

4. Edit file /var/lib/roundcube/config/config.inc.php

?php

/*
 +-----------------------------------------------------------------------+
 | Local configuration for the Roundcube Webmail installation.           |
 |                                                                       |
 | This is a sample configuration file only containing the minimum       |
 | setup required for a functional installation. Copy more options       |
 | from defaults.inc.php to this file to override the defaults.          |
 |                                                                       |
 | This file is part of the Roundcube Webmail client                     |
 | Copyright (C) The Roundcube Dev Team                                  |
 |                                                                       |
 | Licensed under the GNU General Public License version 3 or            |
 | any later version with exceptions for skins & plugins.                |
 | See the README file for a full license statement.                     |
 +-----------------------------------------------------------------------+
*/

$config = [];

// Do not set db_dsnw here, use dpkg-reconfigure roundcube-core to configure database!
include_once("/etc/roundcube/debian-db-roundcube.php");

// The IMAP host chosen to perform the log-in.
// Leave blank to show a textbox at login, give a list of hosts
// to display a pulldown menu or set one host as string.
// Enter hostname with prefix ssl:// to use Implicit TLS, or use
// prefix tls:// to use STARTTLS.
// Supported replacement variables:
// %n - hostname ($_SERVER['SERVER_NAME'])
// %t - hostname without the first part
// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
// %s - domain name after the '@' from e-mail address provided at login screen
// For example %n = mail.domain.tld, %t = domain.tld
$config['default_host'] = 'zekzek.care';

// SMTP server host (for sending mails).
// Enter hostname with prefix ssl:// to use Implicit TLS, or use
// prefix tls:// to use STARTTLS.
// Supported replacement variables:
// %h - user's IMAP hostname
// %n - hostname ($_SERVER['SERVER_NAME'])
// %t - hostname without the first part
// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
// %z - IMAP domain (IMAP hostname without the first part)
// For example %n = mail.domain.tld, %t = domain.tld
// To specify different SMTP servers for different IMAP hosts provide an array
// of IMAP host (no prefix or port) and SMTP server e.g. ['imap.example.com' => 'smtp.example.net']
$config['smtp_server'] = 'zekzek.care';

// SMTP port. Use 25 for cleartext, 465 for Implicit TLS, or 587 for STARTTLS (default)
$config['smtp_port'] = 24;

// SMTP username (if required) if you use %u as the username Roundcube
// will use the current username for login
$config['smtp_user'] = '';

// SMTP password (if required) if you use %p as the password Roundcube
// will use the current user's password for login
$config['smtp_pass'] = '';

// provide an URL where a user can get support for this Roundcube installation
// PLEASE DO NOT LINK TO THE ROUNDCUBE.NET WEBSITE HERE!
$config['support_url'] = '';

// Name your service. This is displayed on the login screen and in the window title
$config['product_name'] = 'Roundcube Webmail';

// This key is used to encrypt the users imap password which is stored
// in the session record. For the default cipher method it must be
// exactly 24 characters long.
// YOUR KEY MUST BE DIFFERENT THAN THE SAMPLE VALUE FOR SECURITY REASONS
$config['des_key'] = '2EmQ9g71Mn9jnWpfm5gv5pIG';

// List of active plugins (in plugins/ directory)
// Debian: install roundcube-plugins first to have any
$config['plugins'] = [
    // 'archive',
    // 'zipdownload',
];

// skin name: folder from skins/
$config['skin'] = 'elastic';

// Disable spellchecking
// Debian: spellchecking needs additional packages to be installed, or calling external APIs
//         see defaults.inc.php for additional informations
$config['enable_spellcheck'] = false;


5. Pengujian

  •     akses di web browser 172.23.2.189/roundcube maka akan ada authentifikasi


  • Dan ini halaman dashboard dari roundcube ditambah ada pesan yang tadi kita kirim lewat courire sebelumnya



Komentar

Postingan populer dari blog ini

Konfigurasi DNS Server (Master Zone, Slave Zone, RPZ Zone) di RedHat

Bahas Firewalld di Redhat