LINUXOR.SK ... open source notes ...

2009 - Postfix + Dovecot + SquirrelMail + MailScanner + ClamAV

category: howtoz · date: 2009-01-10 · source: old.linuxor.sk/MAIL/POSTFIX-HOWTOs/user17/howto-postfix-dovecot-squirrelmail.txt

The Slovak original of this document: 2009 - Postfix + Dovecot + SquirrelMail + MailScanner + ClamAV (slovensky).

asciiart
##################################################################################
##                                                                              ##
##      user17 postfix && dovecot && squirrelmail && mailscanner && clamav       ##
##                                                                              ##
##################################################################################
poznamky:

- create a new user and group vmail to be set in postfix and dovecot
#groupadd -g 5000 vmail
#useradd -m -u 5000 -g 5000 -s /bin/bash vmail
- a nasledne v postfixe zmenit
#virtual_minimum_uid = 1000
#virtual_uid_maps = static:5000
#virtual_gid_maps = static:5000

##################################################################################

#apt-get install postfix

************************************************************************

#nano /etc/postfix/main.cf

##########################################
##      mail server user17 2009          ##
##########################################

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no

append_dot_mydomain = no
#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

#mydomain = partner.example
myhostname = mordor.partner.example
#alias_maps = hash:/etc/aliases
#alias_database = hash:/etc/aliases
myorigin = $mydomain
mydestination = localhost

#virtual_alias_domains = partner.example, client24.example, client50.example
#virtual_alias_maps = hash:/etc/postfix/virtual_alias

relayhost =
mynetworks =
        127.0.0.0/8
        192.168.1.0/24

mailbox_command = procmail -a "$EXTENSION"
home_mailbox = Maildir/
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all

## Kontrola hlavicky (MailScanner)
#header_checks = regexp:/etc/postfix/header_checks

# This system is the final destination for the list of domains named in the file virtual_domains
# ---------------------------------------------------------------------------------------------
virtual_mailbox_domains = /etc/postfix/virtual_domains

# Mapovanie email->subor_schranky
# -------------------------------
virtual_mailbox_maps = hash:/etc/postfix/virtual

# Umiestnenie virtualnych schranok
# --------------------------------
virtual_mailbox_base = /var/mail

# Virtualne aliasi
# ----------------
virtual_alias_maps = hash:/etc/postfix/virtual_alias

# The owner of the mailbox files (uid and gid)
# -------------------------------------
virtual_uid_maps = static:116
virtual_gid_maps = static:8
inet_protocols = ipv4

************************************************************************

#touch /etc/postfix/virtual
#nano /etc/postfix/virtual

## -----------------------------
## partner.example
## -----------------------------
info@partner.example      partner.example/info/
user17@partner.example     partner.example/user17/
user16@partner.example       partner.example/user16/
## client25.example
## -----------------------------
info@client25.example        client25.example/info/

#postmap /etc/postfix/virtual

************************************************************************

#touch /etc/postfix/virtual_alias
#nano /etc/postfix/virtual_alias

info@partner.example info@partner.example
user17@partner.example user17@partner.example
user16@partner.example user16@partner.example
info@client25.example info@client25.example

#postmap /etc/postfix/virtual_alias

************************************************************************

#touch /etc/postfix/virtual_domains
#nano /etc/postfix/virtual_domains

partner.example
client25.example

************************************************************************

# apt-get install dovecot dovecot-imapd

************************************************************************

#nano /etc/dovecot/dovecot.conf

##################################
##      dovecot user17 2009      ##
##################################

base_dir = /var/run/dovecot/
protocols = imap imaps pop3
#mail_extra_groups = mail

first_valid_uid = 116
last_valid_uid = 116

protocol imap {
    login_executable = /usr/lib/dovecot/imap-login
    mail_executable = /usr/lib/dovecot/imap
}

protocol pop3 {
    login_executable = /usr/lib/dovecot/pop3-login
    mail_executable = /usr/lib/dovecot/pop3
    pop3_uidl_format = %08Xu%08Xv
}

disable_plaintext_auth = no
shutdown_clients = yes

## Logging

log_path = /var/log/dovecot.log
info_log_path = /var/log/dovecot.info.log
log_timestamp = "%Y-%m-%d %H:%M:%S "

## SSL settings

#ssl_listen =
#ssl_disable = yes
ssl_cert_file = /etc/ssl/certs/dovecot.pem
ssl_key_file = /etc/ssl/private/dovecot.pem

## Login processes

login_dir = /var/run/dovecot/login
login_chroot = yes
login_user = dovecot
login_greeting = Dovecot ready.

## Mailbox locations and namespaces

#   %u - username
#   %n - user part in user@domain, same as %u if there's no domain
#   %d - domain part in user@domain, empty if there's no domain
#   %h - home directory

mail_location = maildir:/var/mail/%d/%n
mail_privileged_group = mail

## Mail processes

#mail_log_prefix = "%Us(%u): "

mmap_disable = no
valid_chroot_dirs = /var/spool/mail

#default_mail_env = maildir:/var/mail/%d/%n
#mail_chroot =

## Maildir-specific settings

#maildir_stat_dirs = no
#maildir_copy_with_hardlinks = no
#maildir_copy_preserve_filename = no

## IMAP specific settings

protocol imap {
  #login_executable = /usr/lib/dovecot/imap-login

  #   mail_executable = /usr/lib/dovecot/rawlog /usr/lib/dovecot/imap
  #
  # /tmp/gdbhelper.* files:
  #   mail_executable = /usr/libexec/dovecot/gdbhelper /usr/libexec/dovecot/imap
  #
  #mail_executable = /usr/lib/dovecot/imap

  #imap_max_line_length = 65536

  # Support for dynamically loadable plugins. mail_plugins is a space separated
  # list of plugins to load.
  #mail_plugins =
  #mail_plugin_dir = /usr/lib/dovecot/modules/imap
  #login_greeting_capability = no
  #imap_capability =
  #imap_client_workarounds = outlook-idle
}

## POP3 specific settings

protocol pop3 {

  #login_executable = /usr/lib/dovecot/pop3-login
  #mail_executable = /usr/lib/dovecot/pop3
  #pop3_no_flag_updates = no
  #pop3_enable_last = no
  #pop3_reuse_xuidl = no
  #pop3_lock_session = no

  #  %v - Mailbox's IMAP UIDVALIDITY
  #  %u - Mail's IMAP UID
  #  %m - MD5 sum of the mailbox headers in hex (mbox only)
  #  %f - filename (maildir only)
  #
  # If you want UIDL compatibility with other POP3 servers, use:
  #  UW's ipop3d         : %08Xv%08Xu
  #  Courier version 0   : %f
  #  Courier version 1   : %u
  #  Courier version 2   : %v-%u
  #  Cyrus (<= 2.1.3)    : %u
  #  Cyrus (>= 2.1.4)    : %v.%u
  #  Older Dovecots      : %v.%u
  #  tpop3d              : %Mf

  pop3_uidl_format = %08Xu%08Xv

  # POP3 logout format string:
  #  %t - number of TOP commands
  #  %p - number of bytes sent to client as a result of TOP command
  #  %r - number of RETR commands
  #  %b - number of bytes sent to client as a result of RETR command
  #  %d - number of deleted messages
  #  %m - number of messages (before deletion)
  #  %s - mailbox size in bytes (before deletion)
  #pop3_logout_format = top=%t/%p, retr=%r/%b, del=%d/%m, size=%s

  #mail_plugins =
  #mail_plugin_dir = /usr/lib/dovecot/modules/pop3

  # Workarounds for various client bugs:
  #   outlook-no-nuls:
  #     Outlook and Outlook Express hang if mails contain NUL characters.
  #     This setting replaces them with 0x80 character.
  #   oe-ns-eoh:
  #     Outlook Express and Netscape Mail breaks if end of headers-line is
  #     missing. This option simply sends it if it's missing.
  # The list is space-separated.
  #pop3_client_workarounds =
}

## MANAGESIEVE specific settings

protocol managesieve {
  #login_executable = /usr/libexec/dovecot/managesieve-login
  #mail_executable = /usr/libexec/dovecot/managesieve
  #managesieve_max_line_length = 65536
  sieve=~/.dovecot.sieve
  sieve_storage=~/sieve
  # mail_location = mbox:~/mail
  #managesieve_implementation_string = Cyrus timsieved v2.2.13
}

##
## LDA specific settings
##

protocol lda {
    postmaster_address = info@partner.example
    #hostname =
    #mail_plugins =
    #mail_plugin_dir = /usr/lib/dovecot/modules/lda
    #sendmail_path = /usr/lib/sendmail
    #auth_socket_path = /var/run/dovecot/auth-master
    # mail_plugins = cmusieve
}

## Authentication processes

auth_executable = /usr/lib/dovecot/dovecot-auth
auth_verbose = yes

#auth_debug = no
#auth_debug_passwords = no
#auth_worker_max_count = 30
#auth_gssapi_hostname =
#auth_krb5_keytab =

auth default {

    mechanisms = plain digest-md5
    userdb passwd-file {
        args = /etc/dovecot/users
    }
    passdb passwd-file {
        args = /etc/dovecot/passwd
    }
  user = root
}

#auth external {
#  socket connect {
#    master {
#      path = /var/run/dovecot/auth-master
#    }
#  }
#}

## Dictionary server settings

dict {
  #quota = mysql:/etc/dovecot-dict-quota.conf
}

## Plugin settings

plugin {

  #quota = maildir
  #acl = vfile:/etc/dovecot-acls
  #convert_mail = mbox:%h/mail
  #convert_skip_broken_mailboxes = no
  #trash = /etc/dovecot-trash.conf
  #lazy_expunge = .EXPUNGED/ .DELETED/ .DELETED/.EXPUNGED/
}

************************************************************************

#touch /etc/dovecot/adddovecotuser

#!/bin/bash

username=${1%%@*}
domain=${1#*@}

# create the user name in the user file
echo "$username@$domain::5000:5000::/var/mail/$domain/$username/:/bin/false::" >> /etc/dovecot/users

# create the maildir directory structure
/usr/bin/maildirmake.dovecot /var/mail/$domain/$username 5000:5000

# add the user to the Postfix virtual map file
echo $1 $domain/$username >> /etc/postfix/virtual
postmap /etc/postfix/virtual
postfix reload

************************************************************************
##for mkdovecotpasswd to work, mkpasswd has to be there (install it if it is not)

#touch /etc/dovecot/mkdovecotpasswd

#!/bin/bash

echo "$1:`mkpasswd --hash=md5 $2`" >> /etc/dovecot/passwd

************************************************************************

# chmod a+x /etc/dovecot/adddovecotusers
# chmod a+x /etc/dovecot/mkdovecotpasswd

************************************************************************

## add user
# /etc/dovecot/adddovecotusers info@partner.example

#add passwd
root@server:~# /etc/dovecot/mkdovecotpasswd info@partner.example heslo

# postfix reload
# /etc/init.d/dovecot restart

************************************************************************

## vytvorenie logovania /etc/logrotate.d/dovecot

#touch /etc/logrotate.d/dovecot
#nano /etc/logrotate.d/dovecot

/var/log/dovecot*log {
       weekly
       missingok
       rotate 52
       compress
       delaycompress
       notifempty
       # Note the odd permissions: this is needed because deliver doesn't know what user it runs under
       create 666 root adm
       sharedscripts
}

/var/log/dovecot*info {
       weekly
       missingok
       rotate 52
       compress
       delaycompress
       notifempty
       # Note the odd permissions: this is needed because deliver doesn't know what user it runs under
       create 666 root adm
       sharedscripts
}

************************************************************************
← howtoz(EN | SK)