Difference between revisions of "Installing A Mail Server"
m |
|||
(One intermediate revision by the same user not shown) | |||
Line 1,079: | Line 1,079: | ||
# Be sure to add your public ip address block if needed. | # Be sure to add your public ip address block if needed. | ||
# | # | ||
+ | [::1]/128 | ||
127.0.0.0/8 | 127.0.0.0/8 | ||
51.79.81.233/32 | 51.79.81.233/32 | ||
Line 1,537: | Line 1,538: | ||
$ sudo systemctl restart httpd | $ sudo systemctl restart httpd | ||
</pre> | </pre> | ||
+ | |||
+ | == Adding DKIM Support == | ||
+ | |||
+ | I followed the directions on this page -> https://easydmarc.com/blog/how-to-configure-dkim-opendkim-with-postfix/ | ||
+ | |||
+ | DKIM adds digital signing of emails sent between mail servers to reduce spam and spoofing. | ||
[[Category:Linux]] | [[Category:Linux]] |
Latest revision as of 17:49, 30 October 2023
I started with this cookbook written by Shrinivas Gundu on the SystemPandit web site and updated it as I went along.
Contents
- 1 Introduction
- 2 Installing The Software
- 3 Configuring The Server
- 3.1 Obtain An SSL Certificate
- 3.2 Setup the Virtual Mail User
- 3.3 Configuring Postfix Admin
- 3.4 Configuring Postfix
- 3.5 Configure Vacation Email Functionallity
- 3.6 Configuring Dovecot
- 3.7 Configuring Roundcube mail
- 3.8 Configuring the Little Things That Drive You MAD
- 3.9 Preparing and Testing the Postoffice
- 3.10 Setting up Spam and Virus Filtering
- 3.11 Configuring Amavisd
- 3.12 Allow Users To Change Their Own eMail Passwords Via The Roundcube Password Plugin
- 3.13 Adding DKIM Support
Introduction
First things first. If you are a novice at linux I recommend that you should get help with setting this up. This is an advanced email server configuration. This configuration will allow you to serve multiple domains on one server. This howto will allow you to setup a server that is one of four mail server types:
- Mail server with spam and virus checking (Most people. Do everything in the howto)
- Mail server w/o spam and virus checking (Someone else is doing email filtering for you)
- Backup MX / spam and virus filtering server (you want to divide things up)
- Backup MX (You want to receive and hold mail while your main server is down)
You will get the following features:
- Postfix: the workhorse behind the mail receiving and sending
- SMTP authentication
- secure smtp using TLS
- Dovecot: imap and pop3 mailbox service
- secure imap and pop3
- server side filtering of flagged spam to a spam folder
- mysql: handle all the virtual domains and users
- PostfixAdmin: GUI for domain administration
- Roundcube: web mail access
- spam/virus filtering using amavisd-new, spamassassin and clamav
Installing The Software
We’ll start with distribution packages:
$ sudo dnf install roundcubemail dovecot dovecot-mysql dovecot-pigeonhole cyrus-sasl-devel cyrus-sasl-sql subversion perl-MailTools perl-MIME-EncWords perl-MIME-Charset perl-Email-Valid perl-Test-Pod perl-TimeDate perl-Mail-Sender perl-Log-Log4perl imapsync offlineimap amavisd clamav clamd clamav-update perl-Convert-BinHex php-imap postfix postfix-mysql postfix-pcre unrar lz4
Postfix.Admin isn't part of the distribution. Download and install the RPM from https://sourceforge.net/projects/postfixadmin/files/postfixadmin/postfixadmin-3.2/ The RPM tries to use the user and group http2 for the httpd server user. This is incorrect on Fedora. Make sure you change all file ownership to apache:apache in the /user/share/postfixadmin and /etc/postfixadmin directories.
Configuring The Server
Obtain An SSL Certificate
If you have no other source then use LetsEncrypt.com's certbot tool to obtain a free SSL certificate for your server.
Setup the Virtual Mail User
Next we’ll configure the mail store directory. We put it in the /home directory to make backups and other item easy. So type the following.
$ sudo mkdir /home/vmail $ sudo chmod 770 /home/vmail $ sudo useradd -r -u 101 -g mail -d /home/vmail -s /sbin/nologin vmail $ sudo chown vmail:mail /home/vmail
Configuring Postfix Admin
Create the apache config file for postfixadmin, /etc/httpd/conf.d/postfixadmin.conf:
Alias /postfixadmin /usr/share/postfixadmin/public <Directory /usr/share/postfixadmin> Options FollowSymLinks </Directory> <Directory /usr/share/postfixadmin/public> require all granted </Directory>
Restart apache:
$ service httpd restart
Now we need to setup the mysql database for postfixadmin. We only need to create the database and user. The setup file will create the rest. I used phpMyAdmin to create an empty database called "postfix" with a user called "postfix" that had full rights to the database. I set a password for that userid.
Create the config file /usr/share/postfixadmin/config.local.php. Be sure to set the database password. (The setup password gets set in the next step of the process, you can leave it alone for now.)
?php /** * Contains configuration options that override the default config file */ /***************************************************************** * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! * You have to set $CONF['configured'] = true; before the * application will run! * Doing this implies you have changed this file as required. * i.e. configuring database etc; specifying setup.php password etc. */ $CONF['configured'] = true; // In order to setup Postfixadmin, you MUST specify a hashed password here. // To create the hash, visit setup.php in a browser and type a password into the field, // on submission it will be echoed out to you as a hashed value. $CONF['setup_password'] = <your-setup-password-goes_here>; $CONF['postfix_admin_url'] = '/mailadmin'; $CONF['database_type'] = 'mysqli'; $CONF['database_host'] = 'localhost'; $CONF['database_user'] = 'postfix'; $CONF['database_password'] = 'your_database_password_goes-here>'; $CONF['database_name'] = 'postfix'; $CONF['admin_email'] = 'postmaster@daveking.com'; $CONF['encrypt'] = 'md5crypt'; $CONF['dovecotpw'] = "/usr/sbin/dovecotpw"; $CONF['min_password_length'] = 6; $CONF['page_size'] = '20'; $CONF['domain_path'] = 'YES'; $CONF['domain_in_mailbox'] = 'NO'; $CONF['aliases'] = '50'; $CONF['mailboxes'] = '50'; $CONF['maxquota'] = '100'; $CONF['quota'] = 'YES'; $CONF['quota_multiplier'] = '1024000'; $CONF['transport'] = 'YES'; $CONF['transport_options'] = array ( 'virtual', // for virtual accounts 'local', // for system accounts 'relay' // for backup mx ); $CONF['transport_default'] = 'virtual'; $CONF['vacation'] = 'YES'; $CONF['vacation_domain'] = 'autoreply.daveking.com'; $CONF['vacation_control'] ='YES'; $CONF['vacation_control_admin'] = 'YES'; $CONF['special_alias_control'] = 'YES'; $CONF['user_footer_link'] = "http://www.daveking.com"; $CONF['show_footer_text'] = 'YES'; $CONF['footer_text'] = 'Return to www.daveking.com'; $CONF['footer_link'] = 'http://www.daveking.com'; $CONF['create_mailbox_subdirs']=array('Drafts','Spam','Sent','Trash'); $CONF['create_mailbox_subdirs_host']='localhost'; $CONF['create_mailbox_subdirs_prefix']=''; $CONF['used_quotas'] = 'YES'; $CONF['new_quota_table'] = 'YES'; // $CONF['create_mailbox_subdirs_hostoptions']=array('notls'); $CONF['create_mailbox_subdirs_hostoptions']=array('novalidate-cert','norsh'); // Password validation // New/changed passwords will be validated using all regular expressions in the array. // If a password doesn't match one of the regular expressions, the corresponding // error message from $PALANG (see languages/*) will be displayed. // See http://de3.php.net/manual/en/reference.pcre.pattern.syntax.php for details // about the regular expression syntax. // If you need custom error messages, you can add them using $CONF['language_hook']. // If a $PALANG text contains a %s, you can add its value after the $PALANG key // (separated with a space). $CONF['password_validation'] = array( # '/regular expression/' => '$PALANG key (optional: + parameter)', '/.{5}/' => 'password_too_short 5', # minimum length 5 characters '/([a-zA-Z].*){3}/' => 'password_no_characters 3', # must contain at least 3 characters ); // // END OF CONFIG FILE //
Next we need to run the setup.php script in a web browser. Enter the url in your browser. Ex. http://yourdomain.tld/postfixadmin/setup.php
If everything shows OK then create the admin user using the form displayed. Follow the instructions for generating a setup password and inserting it back into /usr/share/postfixadmin/config.local.php. Then re-run the setup.php script.
The URL for the postfixadmin tool is http://yourdomain.tld/postfixadmin/ You will use it to create the virtual mail domains that your mail server supports and the users who are defined within each of those domains.
Configuring Postfix
These are my configuration files. They completely replace the files that are provided as part of the distribution:
/etc/postfix/main.cf:
# Global Postfix configuration file. This file lists only a subset # of all parameters. For the syntax, and for a complete parameter # list, see the postconf(5) manual page (command: "man 5 postconf"). # # For common configuration examples, see BASIC_CONFIGURATION_README # and STANDARD_CONFIGURATION_README. To find these documents, use # the command "postconf html_directory readme_directory", or go to # http://www.postfix.org/BASIC_CONFIGURATION_README.html etc. # # For best results, change no more than 2-3 parameters at a time, # and test if Postfix still works after every change. # COMPATIBILITY # # The compatibility_level determines what default settings Postfix # will use for main.cf and master.cf settings. These defaults will # change over time. # # To avoid breaking things, Postfix will use backwards-compatible # default settings and log where it uses those old backwards-compatible # default settings, until the system administrator has determined # if any backwards-compatible default settings need to be made # permanent in main.cf or master.cf. # # When this review is complete, update the compatibility_level setting # below as recommended in the RELEASE_NOTES file. # # The level below is what should be used with new (not upgrade) installs. # compatibility_level = 2 # SOFT BOUNCE # # The soft_bounce parameter provides a limited safety net for # testing. When soft_bounce is enabled, mail will remain queued that # would otherwise bounce. This parameter disables locally-generated # bounces, and prevents the SMTP server from rejecting mail permanently # (by changing 5xx replies into 4xx replies). However, soft_bounce # is no cure for address rewriting mistakes or mail routing mistakes. # #soft_bounce = no # LOCAL PATHNAME INFORMATION # # The queue_directory specifies the location of the Postfix queue. # This is also the root directory of Postfix daemons that run chrooted. # See the files in examples/chroot-setup for setting up Postfix chroot # environments on different UNIX systems. # queue_directory = /var/spool/postfix # The command_directory parameter specifies the location of all # postXXX commands. # command_directory = /usr/sbin # The daemon_directory parameter specifies the location of all Postfix # daemon programs (i.e. programs listed in the master.cf file). This # directory must be owned by root. # daemon_directory = /usr/libexec/postfix # The data_directory parameter specifies the location of Postfix-writable # data files (caches, random numbers). This directory must be owned # by the mail_owner account (see below). # data_directory = /var/lib/postfix # QUEUE AND PROCESS OWNERSHIP # # The mail_owner parameter specifies the owner of the Postfix queue # and of most Postfix daemon processes. Specify the name of a user # account THAT DOES NOT SHARE ITS USER OR GROUP ID WITH OTHER ACCOUNTS # AND THAT OWNS NO OTHER FILES OR PROCESSES ON THE SYSTEM. In # particular, don't specify nobody or daemon. PLEASE USE A DEDICATED # USER. # mail_owner = postfix # The default_privs parameter specifies the default rights used by # the local delivery agent for delivery to external file or command. # These rights are used in the absence of a recipient user context. # DO NOT SPECIFY A PRIVILEGED USER OR THE POSTFIX OWNER. # #default_privs = nobody # INTERNET HOST AND DOMAIN NAMES # # The myhostname parameter specifies the internet hostname of this # mail system. The default is to use the fully-qualified domain name # from gethostname(). $myhostname is used as a default value for many # other configuration parameters. # #myhostname = host.domain.tld #myhostname = virtual.domain.tld myhostname = mail.daveking.com # The mydomain parameter specifies the local internet domain name. # The default is to use $myhostname minus the first component. # $mydomain is used as a default value for many other configuration # parameters. # #mydomain = domain.tld mydomain = daveking.com # SENDING MAIL # # The myorigin parameter specifies the domain that locally-posted # mail appears to come from. The default is to append $myhostname, # which is fine for small sites. If you run a domain with multiple # machines, you should (1) change this to $mydomain and (2) set up # a domain-wide alias database that aliases each user to # user@that.users.mailhost. # # For the sake of consistency between sender and recipient addresses, # myorigin also specifies the default domain name that is appended # to recipient addresses that have no @domain part. # #myorigin = $myhostname myorigin = $mydomain # RECEIVING MAIL # The inet_interfaces parameter specifies the network interface # addresses that this mail system receives mail on. By default, # the software claims all active interfaces on the machine. The # parameter also controls delivery of mail to user@[ip.address]. # # See also the proxy_interfaces parameter, for network addresses that # are forwarded to us via a proxy or network address translator. # # Note: you need to stop/start Postfix when this parameter changes. # inet_interfaces = all #inet_interfaces = $myhostname #inet_interfaces = $myhostname, localhost #inet_interfaces = localhost # Enable IPv4, and IPv6 if supported inet_protocols = all # The proxy_interfaces parameter specifies the network interface # addresses that this mail system receives mail on by way of a # proxy or network address translation unit. This setting extends # the address list specified with the inet_interfaces parameter. # # You must specify your proxy/NAT addresses when your system is a # backup MX host for other domains, otherwise mail delivery loops # will happen when the primary MX host is down. # #proxy_interfaces = #proxy_interfaces = 1.2.3.4 # The mydestination parameter specifies the list of domains that this # machine considers itself the final destination for. # # These domains are routed to the delivery agent specified with the # local_transport parameter setting. By default, that is the UNIX # compatible delivery agent that lookups all recipients in /etc/passwd # and /etc/aliases or their equivalent. # # The default is $myhostname + localhost.$mydomain + localhost. On # a mail domain gateway, you should also include $mydomain. # # Do not specify the names of virtual domains - those domains are # specified elsewhere (see VIRTUAL_README). # # Do not specify the names of domains that this machine is backup MX # host for. Specify those names via the relay_domains settings for # the SMTP server, or use permit_mx_backup if you are lazy (see # STANDARD_CONFIGURATION_README). # # The local machine is always the final destination for mail addressed # to user@[the.net.work.address] of an interface that the mail system # receives mail on (see the inet_interfaces parameter). # # Specify a list of host or domain names, /file/name or type:table # patterns, separated by commas and/or whitespace. A /file/name # pattern is replaced by its contents; a type:table is matched when # a name matches a lookup key (the right-hand side is ignored). # Continue long lines by starting the next line with whitespace. # # See also below, section "REJECTING MAIL FOR UNKNOWN LOCAL USERS". # mydestination = $myhostname, localhost.$mydomain, localhost #mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain #mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, # mail.$mydomain, www.$mydomain, ftp.$mydomain # REJECTING MAIL FOR UNKNOWN LOCAL USERS # # The local_recipient_maps parameter specifies optional lookup tables # with all names or addresses of users that are local with respect # to $mydestination, $inet_interfaces or $proxy_interfaces. # # If this parameter is defined, then the SMTP server will reject # mail for unknown local users. This parameter is defined by default. # # To turn off local recipient checking in the SMTP server, specify # local_recipient_maps = (i.e. empty). # # The default setting assumes that you use the default Postfix local # delivery agent for local delivery. You need to update the # local_recipient_maps setting if: # # - You define $mydestination domain recipients in files other than # /etc/passwd, /etc/aliases, or the $virtual_alias_maps files. # For example, you define $mydestination domain recipients in # the $virtual_mailbox_maps files. # # - You redefine the local delivery agent in master.cf. # # - You redefine the "local_transport" setting in main.cf. # # - You use the "luser_relay", "mailbox_transport", or "fallback_transport" # feature of the Postfix local delivery agent (see local(8)). # # Details are described in the LOCAL_RECIPIENT_README file. # # Beware: if the Postfix SMTP server runs chrooted, you probably have # to access the passwd file via the proxymap service, in order to # overcome chroot restrictions. The alternative, having a copy of # the system passwd file in the chroot jail is just not practical. # # The right-hand side of the lookup tables is conveniently ignored. # In the left-hand side, specify a bare username, an @domain.tld # wild-card, or specify a user@domain.tld address. # #local_recipient_maps = unix:passwd.byname $alias_maps #local_recipient_maps = proxy:unix:passwd.byname $alias_maps #local_recipient_maps = # The unknown_local_recipient_reject_code specifies the SMTP server # response code when a recipient domain matches $mydestination or # ${proxy,inet}_interfaces, while $local_recipient_maps is non-empty # and the recipient address or address local-part is not found. # # The default setting is 550 (reject mail) but it is safer to start # with 450 (try again later) until you are certain that your # local_recipient_maps settings are OK. # unknown_local_recipient_reject_code = 550 # TRUST AND RELAY CONTROL # The mynetworks parameter specifies the list of "trusted" SMTP # clients that have more privileges than "strangers". # # In particular, "trusted" SMTP clients are allowed to relay mail # through Postfix. See the smtpd_recipient_restrictions parameter # in postconf(5). # # You can specify the list of "trusted" network addresses by hand # or you can let Postfix do it for you (which is the default). # # By default (mynetworks_style = subnet), Postfix "trusts" SMTP # clients in the same IP subnetworks as the local machine. # On Linux, this works correctly only with interfaces specified # with the "ifconfig" command. # # Specify "mynetworks_style = class" when Postfix should "trust" SMTP # clients in the same IP class A/B/C networks as the local machine. # Don't do this with a dialup site - it would cause Postfix to "trust" # your entire provider's network. Instead, specify an explicit # mynetworks list by hand, as described below. # # Specify "mynetworks_style = host" when Postfix should "trust" # only the local machine. # #mynetworks_style = class #mynetworks_style = subnet #mynetworks_style = host # Alternatively, you can specify the mynetworks list by hand, in # which case Postfix ignores the mynetworks_style setting. # # Specify an explicit list of network/netmask patterns, where the # mask specifies the number of bits in the network part of a host # address. # # You can also specify the absolute pathname of a pattern file instead # of listing the patterns here. Specify type:table for table-based lookups # (the value on the table right-hand side is not used). # #mynetworks = 168.100.189.0/28, 127.0.0.0/8 mynetworks = $config_directory/mynetworks #mynetworks = hash:/etc/postfix/network_table # The relay_domains parameter restricts what destinations this system will # relay mail to. See the smtpd_recipient_restrictions description in # postconf(5) for detailed information. # # By default, Postfix relays mail # - from "trusted" clients (IP address matches $mynetworks) to any destination, # - from "untrusted" clients to destinations that match $relay_domains or # subdomains thereof, except addresses with sender-specified routing. # The default relay_domains value is $mydestination. # # In addition to the above, the Postfix SMTP server by default accepts mail # that Postfix is final destination for: # - destinations that match $inet_interfaces or $proxy_interfaces, # - destinations that match $mydestination # - destinations that match $virtual_alias_domains, # - destinations that match $virtual_mailbox_domains. # These destinations do not need to be listed in $relay_domains. # # Specify a list of hosts or domains, /file/name patterns or type:name # lookup tables, separated by commas and/or whitespace. Continue # long lines by starting the next line with whitespace. A file name # is replaced by its contents; a type:name table is matched when a # (parent) domain appears as lookup key. # # NOTE: Postfix will not automatically forward mail for domains that # list this system as their primary or backup MX host. See the # permit_mx_backup restriction description in postconf(5). # #relay_domains = $mydestination relay_domains = proxy:mysql:/etc/postfix/mysql-relay_domains_maps.cf # INTERNET OR INTRANET # The relayhost parameter specifies the default host to send mail to # when no entry is matched in the optional transport(5) table. When # no relayhost is given, mail is routed directly to the destination. # # On an intranet, specify the organizational domain name. If your # internal DNS uses no MX records, specify the name of the intranet # gateway host instead. # # In the case of SMTP, specify a domain, host, host:port, [host]:port, # [address] or [address]:port; the form [host] turns off MX lookups. # # If you're connected via UUCP, see also the default_transport parameter. # #relayhost = $mydomain #relayhost = [gateway.my.domain] #relayhost = [mailserver.isp.tld] #relayhost = uucphost #relayhost = [an.ip.add.ress] # REJECTING UNKNOWN RELAY USERS # # The relay_recipient_maps parameter specifies optional lookup tables # with all addresses in the domains that match $relay_domains. # # If this parameter is defined, then the SMTP server will reject # mail for unknown relay users. This feature is off by default. # # The right-hand side of the lookup tables is conveniently ignored. # In the left-hand side, specify an @domain.tld wild-card, or specify # a user@domain.tld address. # #relay_recipient_maps = hash:/etc/postfix/relay_recipients # INPUT RATE CONTROL # # The in_flow_delay configuration parameter implements mail input # flow control. This feature is turned on by default, although it # still needs further development (it's disabled on SCO UNIX due # to an SCO bug). # # A Postfix process will pause for $in_flow_delay seconds before # accepting a new message, when the message arrival rate exceeds the # message delivery rate. With the default 100 SMTP server process # limit, this limits the mail inflow to 100 messages a second more # than the number of messages delivered per second. # # Specify 0 to disable the feature. Valid delays are 0..10. # #in_flow_delay = 1s # ADDRESS REWRITING # # The ADDRESS_REWRITING_README document gives information about # address masquerading or other forms of address rewriting including # username->Firstname.Lastname mapping. # ADDRESS REDIRECTION (VIRTUAL DOMAIN) # # The VIRTUAL_README document gives information about the many forms # of domain hosting that Postfix supports. # "USER HAS MOVED" BOUNCE MESSAGES # # See the discussion in the ADDRESS_REWRITING_README document. # TRANSPORT MAP # # See the discussion in the ADDRESS_REWRITING_README document. transport_maps = hash:/etc/postfix/transport # ALIAS DATABASE # # The alias_maps parameter specifies the list of alias databases used # by the local delivery agent. The default list is system dependent. # # On systems with NIS, the default is to search the local alias # database, then the NIS alias database. See aliases(5) for syntax # details. # # If you change the alias database, run "postalias /etc/aliases" (or # wherever your system stores the mail alias file), or simply run # "newaliases" to build the necessary DBM or DB file. # # It will take a minute or so before changes become visible. Use # "postfix reload" to eliminate the delay. # #alias_maps = dbm:/etc/aliases alias_maps = hash:/etc/aliases #alias_maps = hash:/etc/aliases, nis:mail.aliases #alias_maps = netinfo:/aliases # The alias_database parameter specifies the alias database(s) that # are built with "newaliases" or "sendmail -bi". This is a separate # configuration parameter, because alias_maps (see above) may specify # tables that are not necessarily all under control by Postfix. # #alias_database = dbm:/etc/aliases #alias_database = dbm:/etc/mail/aliases alias_database = hash:/etc/aliases #alias_database = hash:/etc/aliases, hash:/opt/majordomo/aliases # ADDRESS EXTENSIONS (e.g., user+foo) # # The recipient_delimiter parameter specifies the separator between # user names and address extensions (user+foo). See canonical(5), # local(8), relocated(5) and virtual(5) for the effects this has on # aliases, canonical, virtual, relocated and .forward file lookups. # Basically, the software tries user+foo and .forward+foo before # trying user and .forward. # recipient_delimiter = + # DELIVERY TO MAILBOX # # The home_mailbox parameter specifies the optional pathname of a # mailbox file relative to a user's home directory. The default # mailbox file is /var/spool/mail/user or /var/mail/user. Specify # "Maildir/" for qmail-style delivery (the / is required). # #home_mailbox = Mailbox #home_mailbox = Maildir/ # The mail_spool_directory parameter specifies the directory where # UNIX-style mailboxes are kept. The default setting depends on the # system type. # #mail_spool_directory = /var/mail #mail_spool_directory = /var/spool/mail # The mailbox_command parameter specifies the optional external # command to use instead of mailbox delivery. The command is run as # the recipient with proper HOME, SHELL and LOGNAME environment settings. # Exception: delivery for root is done as $default_user. # # Other environment variables of interest: USER (recipient username), # EXTENSION (address extension), DOMAIN (domain part of address), # and LOCAL (the address localpart). # # Unlike other Postfix configuration parameters, the mailbox_command # parameter is not subjected to $parameter substitutions. This is to # make it easier to specify shell syntax (see example below). # # Avoid shell meta characters because they will force Postfix to run # an expensive shell process. Procmail alone is expensive enough. # # IF YOU USE THIS TO DELIVER MAIL SYSTEM-WIDE, YOU MUST SET UP AN # ALIAS THAT FORWARDS MAIL FOR ROOT TO A REAL USER. # #mailbox_command = /some/where/procmail #mailbox_command = /some/where/procmail -a "$EXTENSION" # The mailbox_transport specifies the optional transport in master.cf # to use after processing aliases and .forward files. This parameter # has precedence over the mailbox_command, fallback_transport and # luser_relay parameters. # # Specify a string of the form transport:nexthop, where transport is # the name of a mail delivery transport defined in master.cf. The # :nexthop part is optional. For more details see the sample transport # configuration file. # # NOTE: if you use this feature for accounts not in the UNIX password # file, then you must update the "local_recipient_maps" setting in # the main.cf file, otherwise the SMTP server will reject mail for # non-UNIX accounts with "User unknown in local recipient table". # # Cyrus IMAP over LMTP. Specify ``lmtpunix cmd="lmtpd" # listen="/var/imap/socket/lmtp" prefork=0'' in cyrus.conf. #mailbox_transport = lmtp:unix:/var/lib/imap/socket/lmtp # If using the cyrus-imapd IMAP server deliver local mail to the IMAP # server using LMTP (Local Mail Transport Protocol), this is prefered # over the older cyrus deliver program by setting the # mailbox_transport as below: # # mailbox_transport = lmtp:unix:/var/lib/imap/socket/lmtp # # The efficiency of LMTP delivery for cyrus-imapd can be enhanced via # these settings. # # local_destination_recipient_limit = 300 # local_destination_concurrency_limit = 5 # # Of course you should adjust these settings as appropriate for the # capacity of the hardware you are using. The recipient limit setting # can be used to take advantage of the single instance message store # capability of Cyrus. The concurrency limit can be used to control # how many simultaneous LMTP sessions will be permitted to the Cyrus # message store. # # Cyrus IMAP via command line. Uncomment the "cyrus...pipe" and # subsequent line in master.cf. #mailbox_transport = cyrus # The fallback_transport specifies the optional transport in master.cf # to use for recipients that are not found in the UNIX passwd database. # This parameter has precedence over the luser_relay parameter. # # Specify a string of the form transport:nexthop, where transport is # the name of a mail delivery transport defined in master.cf. The # :nexthop part is optional. For more details see the sample transport # configuration file. # # NOTE: if you use this feature for accounts not in the UNIX password # file, then you must update the "local_recipient_maps" setting in # the main.cf file, otherwise the SMTP server will reject mail for # non-UNIX accounts with "User unknown in local recipient table". # fallback_transport = lmtp:unix:/var/lib/imap/socket/lmtp #fallback_transport = # The luser_relay parameter specifies an optional destination address # for unknown recipients. By default, mail for unknown@$mydestination, # unknown@[$inet_interfaces] or unknown@[$proxy_interfaces] is returned # as undeliverable. # # The following expansions are done on luser_relay: $user (recipient # username), $shell (recipient shell), $home (recipient home directory), # $recipient (full recipient address), $extension (recipient address # extension), $domain (recipient domain), $local (entire recipient # localpart), $recipient_delimiter. Specify ${name?value} or # ${name:value} to expand value only when $name does (does not) exist. # # luser_relay works only for the default Postfix local delivery agent. # # NOTE: if you use this feature for accounts not in the UNIX password # file, then you must specify "local_recipient_maps =" (i.e. empty) in # the main.cf file, otherwise the SMTP server will reject mail for # non-UNIX accounts with "User unknown in local recipient table". # #luser_relay = $user@other.host #luser_relay = $local@other.host #luser_relay = admin+$local # JUNK MAIL CONTROLS # # The controls listed here are only a very small subset. The file # SMTPD_ACCESS_README provides an overview. # The header_checks parameter specifies an optional table with patterns # that each logical message header is matched against, including # headers that span multiple physical lines. # # By default, these patterns also apply to MIME headers and to the # headers of attached messages. With older Postfix versions, MIME and # attached message headers were treated as body text. # # For details, see "man header_checks". # #header_checks = regexp:/etc/postfix/header_checks # FAST ETRN SERVICE # # Postfix maintains per-destination logfiles with information about # deferred mail, so that mail can be flushed quickly with the SMTP # "ETRN domain.tld" command, or by executing "sendmail -qRdomain.tld". # See the ETRN_README document for a detailed description. # # The fast_flush_domains parameter controls what destinations are # eligible for this service. By default, they are all domains that # this server is willing to relay mail to. # #fast_flush_domains = $relay_domains # SHOW SOFTWARE VERSION OR NOT # # The smtpd_banner parameter specifies the text that follows the 220 # code in the SMTP server's greeting banner. Some people like to see # the mail version advertised. By default, Postfix shows no version. # # You MUST specify $myhostname at the start of the text. That is an # RFC requirement. Postfix itself does not care. # #smtpd_banner = $myhostname ESMTP $mail_name #smtpd_banner = $myhostname ESMTP $mail_name ($mail_version) # PARALLEL DELIVERY TO THE SAME DESTINATION # # How many parallel deliveries to the same user or domain? With local # delivery, it does not make sense to do massively parallel delivery # to the same user, because mailbox updates must happen sequentially, # and expensive pipelines in .forward files can cause disasters when # too many are run at the same time. With SMTP deliveries, 10 # simultaneous connections to the same domain could be sufficient to # raise eyebrows. # # Each message delivery transport has its XXX_destination_concurrency_limit # parameter. The default is $default_destination_concurrency_limit for # most delivery transports. For the local delivery agent the default is 2. #local_destination_concurrency_limit = 2 #default_destination_concurrency_limit = 20 # DEBUGGING CONTROL # # The debug_peer_level parameter specifies the increment in verbose # logging level when an SMTP client or server host name or address # matches a pattern in the debug_peer_list parameter. # debug_peer_level = 2 # The debug_peer_list parameter specifies an optional list of domain # or network patterns, /file/name patterns or type:name tables. When # an SMTP client or server host name or address matches a pattern, # increase the verbose logging level by the amount specified in the # debug_peer_level parameter. # #debug_peer_list = 127.0.0.1 #debug_peer_list = some.domain # The debugger_command specifies the external command that is executed # when a Postfix daemon program is run with the -D option. # # Use "command .. & sleep 5" so that the debugger can attach before # the process marches on. If you use an X-based debugger, be sure to # set up your XAUTHORITY environment variable before starting Postfix. # debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5 # If you can't use X, use this to capture the call stack when a # daemon crashes. The result is in a file in the configuration # directory, and is named after the process name and the process ID. # # debugger_command = # PATH=/bin:/usr/bin:/usr/local/bin; export PATH; (echo cont; # echo where) | gdb $daemon_directory/$process_name $process_id 2>&1 # >$config_directory/$process_name.$process_id.log & sleep 5 # # Another possibility is to run gdb under a detached screen session. # To attach to the screen session, su root and run "screen -r # <id_string>" where <id_string> uniquely matches one of the detached # sessions (from "screen -list"). # # debugger_command = # PATH=/bin:/usr/bin:/sbin:/usr/sbin; export PATH; screen # -dmS $process_name gdb $daemon_directory/$process_name # $process_id & sleep 1 # INSTALL-TIME CONFIGURATION INFORMATION # # The following parameters are used when installing a new Postfix version. # # sendmail_path: The full pathname of the Postfix sendmail command. # This is the Sendmail-compatible mail posting interface. # sendmail_path = /usr/sbin/sendmail.postfix # newaliases_path: The full pathname of the Postfix newaliases command. # This is the Sendmail-compatible command to build alias databases. # newaliases_path = /usr/bin/newaliases.postfix # mailq_path: The full pathname of the Postfix mailq command. This # is the Sendmail-compatible mail queue listing command. # mailq_path = /usr/bin/mailq.postfix # setgid_group: The group for mail submission and queue management # commands. This must be a group name with a numerical group ID that # is not shared with other accounts, not even with the Postfix account. # setgid_group = postdrop # html_directory: The location of the Postfix HTML documentation. # html_directory = no # manpage_directory: The location of the Postfix on-line manual pages. # manpage_directory = /usr/share/man # sample_directory: The location of the Postfix sample configuration files. # This parameter is obsolete as of Postfix 2.1. # sample_directory = /usr/share/doc/postfix/samples # readme_directory: The location of the Postfix README files. # readme_directory = /usr/share/doc/postfix/README_FILES # TLS CONFIGURATION # # Basic Postfix TLS configuration by default with self-signed certificate # for inbound SMTP and also opportunistic TLS for outbound SMTP. # The full pathname of a file with the Postfix SMTP server RSA certificate # in PEM format. Intermediate certificates should be included in general, # the server certificate first, then the issuing CA(s) (bottom-up order). # smtpd_tls_cert_file = /etc/letsencrypt/live/www.daveking.com/fullchain.pem # The full pathname of a file with the Postfix SMTP server RSA private key # in PEM format. The private key must be accessible without a pass-phrase, # i.e. it must not be encrypted. # smtpd_tls_key_file = /etc/letsencrypt/live/www.daveking.com/privkey.pem # Announce STARTTLS support to remote SMTP clients, but do not require that # clients use TLS encryption (opportunistic TLS inbound). # smtpd_tls_security_level = may # Directory with PEM format Certification Authority certificates that the # Postfix SMTP client uses to verify a remote SMTP server certificate. # smtp_tls_CApath = /etc/pki/tls/certs # The full pathname of a file containing CA certificates of root CAs # trusted to sign either remote SMTP server certificates or intermediate CA # certificates. # #smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt # Use TLS if this is supported by the remote SMTP server, otherwise use # plaintext (opportunistic TLS outbound). # smtp_tls_security_level = may meta_directory = /etc/postfix shlib_directory = /usr/lib64/postfix # dlk additions ################################################################ delay_warning_time = 4 # virtual setup virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-virtual_alias_maps.cf, regexp:/etc/postfix/virtual_regexp virtual_mailbox_base = /home/vmail virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual_domains_maps.cf virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailbox_maps.cf #virtual_mailbox_limit_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailbox_limit_maps.cf virtual_minimum_uid = 101 virtual_uid_maps = static:101 virtual_gid_maps = static:12 virtual_transport = dovecot dovecot_destination_recipient_limit = 1 # authentication smtpd_sasl_auth_enable = yes smtpd_sasl_security_options = noanonymous smtpd_sasl_local_domain = $myhostname broken_sasl_auth_clients = yes smtpd_sasl_type = dovecot smtpd_sasl_path = private/auth # tls config smtp_use_tls = yes smtpd_use_tls = yes smtpd_tls_loglevel = 1 smtpd_tls_received_header = yes smtpd_tls_session_cache_timeout = 3600s tls_random_source = dev:/dev/urandom smtp_tls_session_cache_database = btree:$data_directory/smtp_tls_session_cache # restrictions smtpd_client_restrictions = smtpd_helo_restrictions = smtpd_sender_restrictions = smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination, reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unknown_recipient_domain # uncomment for realtime black list checks # ,reject_rbl_client zen.spamhaus.org # ,reject_rbl_client bl.spamcop.net # ,reject_rbl_client dnsbl.sorbs.net smtpd_helo_required = yes unknown_local_recipient_reject_code = 550 disable_vrfy_command = yes smtpd_data_restrictions = reject_unauth_pipelining # Other options # email size limit ~20Meg message_size_limit = 204800000
/etc/postfix/master.cf
# # Postfix master process configuration file. For details on the format # of the file, see the master(5) manual page (command: "man 5 master" or # on-line: http://www.postfix.org/master.5.html). # # Do not forget to execute "postfix reload" after editing this file. # # ========================================================================== # service type private unpriv chroot wakeup maxproc command + args # (yes) (yes) (no) (never) (100) # ========================================================================== smtp inet n - n - - smtpd -o content_filter=smtp-amavis:127.0.0.1:10024 -o receive_override_options=no_address_mappings submission inet n - n - - smtpd -o syslog_name=postfix/submission -o smtpd_tls_security_level=encrypt -o smtpd_sasl_auth_enable=yes -o smtpd_sasl_type=dovecot -o smtpd_sasl_path=private/auth -o smtpd_sasl_security_options=noanonymous -o smtpd_sasl_local_domain=$myhostname -o smtpd_sasl_authenticated_header=no -o smtpd_client_restrictions=permit_sasl_authenticated,reject -o smtpd_relay_restrictions=reject_non_fqdn_recipient,reject_unknown_recipient_domain,permit_sasl_authenticated,reject smtps inet n - n - - smtpd -o syslog_name=postfix/smtps -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes -o smtpd_reject_unlisted_recipient=no -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject pickup fifo n - n 60 1 pickup -o content_filter= -o receive_override_options=no_header_body_checks cleanup unix n - n - 0 cleanup qmgr fifo n - n 300 1 qmgr #qmgr fifo n - n 300 1 oqmgr tlsmgr unix - - n 1000? 1 tlsmgr rewrite unix - - n - - trivial-rewrite bounce unix - - n - 0 bounce defer unix - - n - 0 bounce trace unix - - n - 0 bounce verify unix - - n - 1 verify flush unix n - n 1000? 0 flush proxymap unix - - n - - proxymap smtp unix - - n - - smtp # When relaying mail as backup MX, disable fallback_relay to avoid MX loops relay unix - - n - - smtp -o fallback_relay= # -o smtp_helo_timeout=5 -o smtp_connect_timeout=5 showq unix n - n - - showq error unix - - n - - error discard unix - - n - - discard local unix - n n - - local virtual unix - n n - - virtual lmtp unix - - n - - lmtp anvil unix - - n - 1 anvil scache unix - - n - 1 scache # # ==================================================================== # Interfaces to non-Postfix software. Be sure to examine the manual # pages of the non-Postfix software to find out what options it wants. # ==================================================================== maildrop unix - n n - - pipe flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient} uucp unix - n n - - pipe flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient) ifmail unix - n n - - pipe flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient) bsmtp unix - n n - - pipe flags=Fq. user=foo argv=/usr/local/sbin/bsmtp -f $sender $nexthop $recipient # # spam/virus section # smtp-amavis unix - - y - 2 smtp -o smtp_data_done_timeout=1200 -o disable_dns_lookups=yes -o smtp_send_xforward_command=yes 127.0.0.1:10025 inet n - y - - smtpd -o content_filter= -o smtpd_helo_restrictions= -o smtpd_sender_restrictions= -o smtpd_recipient_restrictions=permit_mynetworks,reject -o mynetworks=127.0.0.0/8 -o smtpd_error_sleep_time=0 -o smtpd_soft_error_limit=1001 -o smtpd_hard_error_limit=1000 -o receive_override_options=no_header_body_checks # -o smtpd_bind_address=127.0.0.1 -o smtpd_helo_required=no -o smtpd_client_restrictions= -o smtpd_restriction_classes= -o disable_vrfy_command=no -o strict_rfc821_envelopes=yes # # Dovecot LDA dovecot unix - n n - - pipe flags=DRhu user=vmail:mail argv=/usr/libexec/dovecot/deliver -d ${recipient} # # Vacation mail vacation unix - n n - - pipe flags=Rq user=vacation argv=/var/spool/vacation/vacation.pl -f ${sender} -- ${recipient}
/etc/postfix/mynetworks
This specifies the list of subnets that Postfix considers as # "trusted" SMTP clients that have more privileges than "strangers". # # In particular, "trusted" SMTP clients are allowed to relay mail # through Postfix. # # Be sure to add your public ip address block if needed. # [::1]/128 127.0.0.0/8 51.79.81.233/32
The postfix / mysql mapping files:
/etc/postfix/mysql-virtual_alias_maps.cf
hosts = localhost user = postfix password = <your_database_password_goes_here> dbname = postfix query = SELECT goto FROM alias WHERE address='%s' AND active = '1'
/etc/postfix/mysql-virtual_domains_maps.cf
hosts = localhost user = postfix password = <your_database_password_goes_here> dbname = postfix query = SELECT domain FROM domain WHERE domain='%s' AND backupmx = '0' AND active = '1'
/etc/postfix/mysql-relay_domains_maps.cf
hosts = localhost user = postfix password = <your_database_password_goes_here> dbname = postfix query = SELECT domain FROM domain WHERE domain='%s' and backupmx = '1'
/etc/postfix/mysql-virtual_mailbox_maps.cf
hosts = localhost user = postfix password = <your_database_password_goes_here> dbname = postfix query = SELECT maildir FROM mailbox WHERE username='%s' AND active = '1'
/etc/postfix/mysql-virtual_mailbox_limit_maps.cf
hosts = localhost user = postfix password = <your_database_password_goes_here> dbname = postfix query = SELECT quota FROM mailbox WHERE username='%s' AND active = '1'
Finally, we need to create an empty file: touch /etc/postfix/virtual_regexp
Configure Vacation Email Functionallity
Lets finish the postfix configuration with vacation mail. Don’t forget to fill in your domain name where needed. Execute the following commands:
$ echo “autoreply.yourdomain.com vacation:” > /etc/postfix/transport $ postmap /etc/postfix/transport $ echo “127.0.0.1 autoreply.yourdomain.com” >> /etc/hosts
Create /etc/postfixadmin/vacation.conf with the following:
$db_type = 'mysql'; $db_username = 'postfix'; $db_password = '<your_database_password_goes_here>'; $db_name = 'postfix'; $vacation_domain = 'autoreply.daveking.com';
Configuring Dovecot
Now for the dovecot config file. Dovecot now uses multiple config files to break things up. We’re going to only use a couple config files. So cut and paste the following files.
/etc/dovecot/dovecot.conf
## Dovecot configuration file protocols = imap pop3 lmtp sieve auth_mechanisms = plain login passdb { driver = sql args = /etc/dovecot/dovecot-mysql.conf } userdb { driver = prefetch } userdb { driver = sql args = /etc/dovecot/dovecot-mysql.conf } mail_location = maildir:/home/vmail/%d/%n first_valid_uid = 101 #last_valid_uid = 0 first_valid_gid = 12 #last_valid_gid = 0 #mail_plugins = mailbox_idle_check_interval = 30 secs maildir_copy_with_hardlinks = yes service imap-login { inet_listener imap { port = 143 } inet_listener imaps { port = 993 ssl = yes } } service pop3-login { inet_listener pop3 { port = 110 } inet_listener pop3s { port = 995 ssl = yes } } service lmtp { unix_listener lmtp { #mode = 0666 } } service imap { vsz_limit = 256M } service pop3 { } service auth { unix_listener auth-userdb { mode = 0666 user = vmail group = mail } # Postfix smtp-auth unix_listener /var/spool/postfix/private/auth { mode = 0666 user = postfix group = postfix } } service auth-worker { } service dict { unix_listener dict { mode = 0666 user = vmail group = mail } } service managesieve-login { inet_listener sieve { port = 4190 } service_count = 1 process_min_avail = 0 vsz_limit = 64M } service managesieve { } service stats { unix_listener stats-writer { group = mail mode = 0660 user = vmail } } ssl = yes ssl_cert = </etc/letsencrypt/live/www.daveking.com/fullchain.pem ssl_key = </etc/letsencrypt/live/www.daveking.com/privkey.pem ssl_verify_client_cert = no #ssl_ca = lda_mailbox_autocreate = yes lda_mailbox_autosubscribe = yes protocol lda { mail_plugins = quota sieve postmaster_address = postmaster@your-domain.tld } protocol imap { mail_plugins = quota imap_quota trash imap_client_workarounds = delay-newmail } lmtp_save_to_detail_mailbox = yes protocol lmtp { mail_plugins = sieve } protocol pop3 { mail_plugins = quota pop3_client_workarounds = outlook-no-nuls oe-ns-eoh } protocol sieve { managesieve_max_line_length = 65536 managesieve_implementation_string = Dovecot Pigeonhole managesieve_max_compile_errors = 5 } dict { quotadict = mysql:/etc/dovecot/dovecot-dict-quota.conf } plugin { quota = dict:user::proxy::quotadict acl = vfile:/etc/dovecot/acls trash = /etc/dovecot/trash.conf sieve_global_path = /home/sieve/globalfilter.sieve sieve = ~/dovecot.sieve sieve_dir = ~/sieve sieve_global_dir = /home/sieve/ #sieve_extensions = +notify +imapflags sieve_max_script_size = 1M #sieve_max_actions = 32 #sieve_max_redirects = 4 }
/etc/dovecot/trash.conf
1 Spam # Uncomment if you want trash as well # 2 Trash
Next we configure Dovecot to access mysql. Create the following file.
/etc/dovecot/dovecot-mysql.conf
driver = mysql connect = host=localhost dbname=postfix user=postfix password=5Gv7e4ZE81nbiBcOh7cgc6m19WvJgNYw default_pass_scheme = MD5-CRYPT password_query = SELECT username as user, password, concat('/home/vmail/', maildir) as userdb_home, concat('maildir:/home/vmail/', maildir) as userdb_mail, 101 as userdb_uid, 12 as userdb_gid FROM mailbox WHERE username = '%u' AND active = '1' user_query = SELECT concat('/home/vmail/', maildir) as home, concat('maildir:/home/vmail/', maildir) as mail, 101 AS uid, 12 AS gid, CONCAT('*:bytes=', quota) as quota_rule FROM mailbox WHERE username = '%u' AND active = '1'
/etc/dovecot/dovecot-dict-quota.conf
connect = host=localhost dbname=postfix user=postfix password=5Gv7e4ZE81nbiBcOh7cgc6m19WvJgNYw map { pattern = priv/quota/storage table = quota2 username_field = username value_field = bytes } map { pattern = priv/quota/messages table = quota2 username_field = username value_field = messages }
Finally set Dovecot to boot at startup.
$ sudo systemctl enable dovecot
Now Create the sieve filter for SPAM filtering:
$ mkdir /home/sieve
/home/sieve/globalfilter.sieve
require "fileinto"; if exists "X-Spam-Flag" { if header :contains "X-Spam-Flag" "NO" { } else { fileinto "Spam"; stop; } } if header :contains "subject" ["***SPAM***"] { fileinto "Spam"; stop; }
$ sudo chown -R vmail:mail /home/sieve
Configuring Roundcube mail
Edit the roundcube apache config file to look like the following:
/etc/httpd/conf.d/roundcubemail.conf
# # Round Cube Webmail is a browser-based multilingual IMAP client # # This URL is globally defined, all vhosts should be able to use # this mail client Alias /roundcubemail /usr/share/roundcubemail Alias /webmail /usr/share/roundcubemail <Directory /usr/share/roundcubemail/> Require all granted </Directory> # Define who can access the installer <Directory /usr/share/roundcubemail/installer/> #Require all granted Require all denied </Directory> # These directories should never be viewed by Web clients. <Directory /usr/share/roundcubemail/bin/> Require all denied </Directory> <Directory /usr/share/roundcubemail/plugins/enigma/home/> Require all denied </Directory>
Create the database for roundcube:
$ mysql -u root -p -e “CREATE DATABASE roundcubemail;” $ mysql -u root -p -e “GRANT ALL PRIVILEGES ON roundcubemail.* TO roundcube@localhost IDENTIFIED BY ‘password’;” $ mysql -u root -p roundcubemail </usr/share/roundcubemail/SQL/mysql.initial.sql
Edit /etc/roundcubemail/db.inc.php and find the line:
$rcmail_config['db_dsnw'] = 'mysql://roundcube:pass@localhost/roundcubemail';
Change ‘pass’ to your passowrd.
Edit /etc/roundcubemail/main.inc.php and find the lines and make the changes below:
find: $rcmail_config['default_host'] = ;
change to: $rcmail_config['default_host'] = 'localhost';
find: $rcmail_config['smtp_server'] = ;
change to: $rcmail_config['smtp_server'] = 'localhost';
find: $rcmail_config['force_https'] = false;
change to: $rcmail_config['force_https'] = true;
find: $rcmail_config['plugins'] = array();
change to: $rcmail_config['plugins'] = array('managesieve');
find: $rcmail_config['quota_zero_as_unlimited'] = false;
change to: $rcmail_config['quota_zero_as_unlimited'] = true;
Restart apache:
$ sudo systemctl restart httpd
Configuring the Little Things That Drive You MAD
Add a line to /etc/hosts with your host's public ip and hostname
Preparing and Testing the Postoffice
Reboot the system. Use PostfixAdmin to set up a test account and domain. Send some test mails to it. Fix any problems you encounter.
Setting up Spam and Virus Filtering
Update clamav:
$ sudo freshclam
Amavisd will start clamd so we don't need to worry about that.
Configuring Amavisd
Edit /etc/amavisd/amavisd.conf and change the following items:
$mydomain = ‘example.com’; # set to your domain name
$log_level = 1; # set the log leve to one
$sa_tag_level_deflt = -99; # i want to see the headers so change to -99
$sa_tag2_level_deflt = 5.0; # start with 5
$sa_kill_level_deflt = 9; # change to 9
$sa_dsn_cutoff_level = 9; # change to 9
$sa_quarantine_cutoff_level = 50; # remove the starting # and change to 50
$myhostname = ‘lightning.campworld.net’; # remove the starting # and enter your host name
$notify_method = ‘smtp:[127.0.0.1]:10025’; # uncomment the line
$forward_method = ‘smtp:[127.0.0.1]:10025’; # uncomment the line
$final_banned_destiny = D_DISCARD; # change to D_DISCARD
Find the following lines and uncomment them to enable clamav:
# ### http://www.clamav.net/ # ['ClamAV-clamd', # \&ask_daemon, ["CONTSCAN {}\n", "/var/run/clamav/clamd"], # qr/\bOK$/m, qr/\bFOUND$/m, # qr/^.*?: (?!Infected Archive)(.*) FOUND$/m ],
Now update spamassassin and start amavisd-new.
$ sa-update $ sudo systemctl enable amavisd $ sudo systemctl start amavisd
Telling Postfix to Start Filtering SPAM
To turn on spam filtering in postfix we need to uncomment a couple lines in /etc/postfix/master.cf. Uncomment the following two lines:
smtp inet n - n - - smtpd # -o content_filter=smtp-amavis:127.0.0.1:10024 # -o receive_override_options=no_address_mappings
Restart postfix:
$ sudo systemctl restart postfix
Allow Users To Change Their Own eMail Passwords Via The Roundcube Password Plugin
Edit /etc/roundcubemail/main.inc.php and find the lines and make the changes below:
find: $rcmail_config['plugins'] = array('managesieve');
change to: $rcmail_config['plugins'] = array('managesieve','password');
Now let's configure the password plugin.
$ cd /usr/share/roundcubemail/plugins/password/ $ sudo cp config.inc.php.dist config.inc.php
Edit config.inc.php"
find: $rcmail_config['password_db_dsn'] = ;
change to: $rcmail_config['password_db_dsn'] = 'mysql://postfix:your-postfixadmin-password@localhost/postfix';
find: $rcmail_config['password_query'] = 'SELECT update_passwd(%c, %u)';
change to: $rcmail_config['password_query'] = 'UPDATE mailbox SET password=%c WHERE username=%u limit 1;';
Restart apache:
$ sudo systemctl restart httpd
Adding DKIM Support
I followed the directions on this page -> https://easydmarc.com/blog/how-to-configure-dkim-opendkim-with-postfix/
DKIM adds digital signing of emails sent between mail servers to reduce spam and spoofing.