Config Forwarding Email Exim

Cara membuat email forwarding dengan Exim Server.
Setelah selama seminggu pusing dengan cara membuat forward email, inilah hasil yang telah sukses.
Alasan saya menggunakan Exim karena untuk mengatur forward email pada exim sangatlah mudah.
karena begitu data diubah, otomatis langsung terupdate tanpa harus melakukan restart/reload.

Install Exim.
Setelah berhasil install, ubah file exim.conf
cari dan ganti dengan ini:

domainlist local_domains = @ : localhost : dsearch;/etc/exim/virtual

Kemudian pada bagian begin routers tambahkan ini:

virtual_aliases:
  driver = redirect
  allow_defer
  allow_fail
  domains = dsearch;/etc/exim/virtual
  data = ${expand:${lookup{$local_part}lsearch*@{/etc/exim/virtual/$domain}}}
  retry_use_local_part
  pipe_transport   = address_pipe
  file_transport   = address_file
  no_more

Selanjutnya buat folder /etc/exim/virtual/
Pada folder ini nantinya akan berisi file dengan nama domain
Contoh:
Forward email [email protected] ke [email protected]
Forward email [email protected] ke [email protected]
Forward email [email protected] ke pipe untuk proses autoreply
Set default email di forward ke [email protected]
maka buat file xtrsyz.org pada folder /etc/exim/virtual/
pada file tersebut tambahkan seperti berikut:

contact: [email protected]
satria: [email protected]
autoreply: "|php -q /home/user/pipe.php"
*: [email protected]

Forward email [email protected] ke [email protected]
Forward email [email protected] ke [email protected]
maka buat file mig33.us pada folder /etc/exim/virtual/
pada file tersebut tambahkan seperti berikut:

admin: [email protected]
support: [email protected]

Berikut contoh file exim.conf yang telah jadi

#primary_hostname = 
domainlist local_domains = @ : localhost : dsearch;/etc/exim/virtual
domainlist relay_to_domains =
hostlist   relay_from_hosts = 127.0.0.1

acl_smtp_mail = acl_check_mail
acl_smtp_rcpt = acl_check_rcpt
acl_smtp_data = acl_check_data
acl_smtp_mime = acl_check_mime

tls_advertise_hosts = *
tls_certificate = /etc/pki/tls/certs/exim.pem
tls_privatekey = /etc/pki/tls/private/exim.pem

daemon_smtp_ports = 25 : 465 : 587
tls_on_connect_ports = 465

never_users = root
host_lookup = *
auth_advertise_hosts =
rfc1413_hosts = *
rfc1413_query_timeout = 2s
ignore_bounce_errors_after = 2d
timeout_frozen_after = 7d

begin acl
acl_check_mail:

  deny condition = ${if eq{$sender_helo_name}{} {1}}
       message = Nice boys say HELO first

  warn condition = ${if eq{$sender_host_name}{} {1}}
       set acl_m_greylistreasons = Host $sender_host_address lacks reverse DNS\n$acl_m_greylistreasons

  accept
acl_check_rcpt:

  accept  hosts = :
          control = dkim_disable_verify

  deny    message       = Restricted characters in address
          domains       = +local_domains
          local_parts   = ^[.] : ^.*[@%!/|]

  deny    message       = Restricted characters in address
          domains       = !+local_domains
          local_parts   = ^[./|] : ^.*[@%!] : ^.*/\\.\\./

  accept  local_parts   = postmaster
          domains       = +local_domains

  require verify        = sender

  accept  hosts         = +relay_from_hosts
          control       = submission
          control       = dkim_disable_verify

  accept  authenticated = *
          control       = submission
          control       = dkim_disable_verify

  require message = relay not permitted
          domains = +local_domains : +relay_to_domains

  require verify = recipient

  accept
acl_check_data:

  warn    condition  = ${if !def:h_Message-ID: {1}}
          set acl_m_greylistreasons = Message lacks Message-Id: header. Consult RFC2822.\n$acl_m_greylistreasons

  accept
acl_check_mime:

  deny message = Blacklisted file extension detected
       condition = ${if match \
                        {${lc:$mime_filename}} \
                        {\N(\.exe|\.pif|\.bat|\.scr|\.lnk|\.com)$\N} \
                     {1}{0}}
  accept
begin routers
virtual_aliases:
  driver = redirect
  allow_defer
  allow_fail
  domains = dsearch;/etc/exim/virtual
  data = ${expand:${lookup{$local_part}lsearch*@{/etc/exim/virtual/$domain}}}
  retry_use_local_part
  pipe_transport   = address_pipe
  file_transport   = address_file
  no_more
dnslookup:
  driver = dnslookup
  domains = ! +local_domains
  transport = remote_smtp
  ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8
  no_more
system_aliases:
  driver = redirect
  allow_fail
  allow_defer
  data = ${lookup{$local_part}lsearch{/etc/aliases}}
  file_transport = address_file
  pipe_transport = address_pipe
userforward:
  driver = redirect
  check_local_user
  file = $home/.forward
  allow_filter
  no_verify
  no_expn
  check_ancestor
  file_transport = address_file
  pipe_transport = address_pipe
  reply_transport = address_reply
procmail:
  driver = accept
  check_local_user
  require_files = ${local_part}:+${home}/.procmailrc:/usr/bin/procmail
  transport = procmail
  no_verify
localuser:
  driver = accept
  check_local_user
  transport = local_delivery
  cannot_route_message = Unknown user
begin transports
remote_smtp:
  driver = smtp
remote_msa:
  driver = smtp
  port = 587
  hosts_require_auth = *
procmail:
  driver = pipe
  command = "/usr/bin/procmail -d $local_part"
  return_path_add
  delivery_date_add
  envelope_to_add
  user = $local_part
  initgroups
  return_output
local_delivery:
  driver = appendfile
  file = /var/mail/$local_part
  delivery_date_add
  envelope_to_add
  return_path_add
  group = mail
  mode = 0660
address_pipe:
  driver = pipe
  return_output
address_file:
  driver = appendfile
  delivery_date_add
  envelope_to_add
  return_path_add
address_reply:
  driver = autoreply
begin retry
*                      *           F,2h,15m; G,16h,1h,1.5; F,4d,6h
begin rewrite
begin authenticators

Download File Config

Facebook Comments

Leave a Reply

Your email address will not be published. Required fields are marked *