Membuat Penerusan Surel dengan postfix di VPS Digital Ocean

Postfix_logo

Task awal. Meneruskan email dari hello@domain.com ke akun gmail menggunakan postfix. Caranya:

  1. Set domain untuk mengarah ke vps DO. Address maupun mx.

  2. Login ke vps
  3. Install postfix
    #apt install postfix
  4. Atur konfigurasi postfix
    # /etc/postfix/main.cf
    
    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
    
    # 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_use_tls=yes
    smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
    smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
    
    # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
    # information on enabling SSL in the smtp client.
    
    smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
    myhostname = domain.com
    alias_maps = hash:/etc/aliases
    alias_database = hash:/etc/aliases
    virtual_alias_domains = domain.com
    virtual_alias_maps = hash:/etc/postfix/virtual
    myorigin = /etc/mailname
    mydestination = domain, localhost.localdomain, localhost
    relayhost =
    mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
    mailbox_size_limit = 0
    recipient_delimiter = +
    inet_interfaces = all
    inet_protocols = ipv4
  5. Atur email alias
    # /etc/postfix/virtual
    hello@domain.com youremail@gmail.com
  6. Remap and reload postfix
    # postmap /etc/postfix/virtual
    # service postfix reload
  7. Lakukan testing dari konsole komputer lokal, dan cek kotak masuk gmail anda (even spam box too)
    # echo "\n-- BEGIN MESSAGE --\nHi All,\nThere is a new testing "test-fordward-mail".\nYour Dev Friend, Tuan Bot\n-- END MESSAGE --" | mail -s "test-fordward-mail" "hello@domain.com"
    # tail -f /var/log/mail.log

Kelar! Next Task, bikin SMTP Relay

Selamat utik-utik
Estu yang lagi ketik-ketik

Bacaan:

[0] http://www.kevinsweet.com/forwarding-email-digital-ocean-ubuntu/