Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dovecot unix - n n - - pipe
- flags=DRhu user=email:email argv=/usr/lib/dovecot/deliver -f ${sender} -d ${recipient}
- Finally, there is one last file that you need to edit out: /etc/postfix/sasl/smtpd.conf. If it doesn't exist, create it. Anyhow insert the follow values into the file:
- [
- pwcheck_method: saslauthd
- mech_list: plain login cram-md5 digest-md5
- ]
- Step 4: configuring Dovecot
- It is now time to configure Dovecot, the program that will serve as POP3 and IMAP server. Open the dovecot main configuration file [/etc/dovecot/dovecot.conf] using your favorite text editor. As you can see this file is pretty big due to the massive amount of comments all over the place. I'm going to post the appropriate configuration below with my own comments pertaining to the architecture we're setting up. Feel free to copy paste it but make sure to modify the relevant sections.
- [
- # Basic configuration
- protocols = imap imaps pop3 pop3s
- log_timestamp = "%Y-%m-%d %H:%M:%S "
- disable_plaintext_auth=yes
- # User and group permissions
- first_valid_uid=7788
- last_valid_uid=7788
- first_valid_gid=7788
- last_valid_gid=7788
- mail_location = maildir:/var/email/%d/%n/Maildir
- mail_privileged_group = email
- auth_executable = /usr/lib/dovecot/dovecot-auth
- auth_verbose = yes
- # SSL config
- ssl_cert_file = /etc/ssl/private/example.com.cert
- ssl_key_file = /etc/ssl/private/example.com.key
- # LDA config
- protocol lda {
- auth_socket_path = /var/run/dovecot/auth-master
- postmaster_address = postmaster@example.com
- mail_plugins = sieve
- log_path =
- }
- # Authentication configuration
- auth default {
- mechanisms = plain login
- passdb passwd-file {
- args = scheme=SHA1 /etc/dovecot/users.conf
- }
- userdb static {
- #args = /etc/dovecot/users.conf
- args = uid=7788 gid=7788 home=/var/email/%d/%n allow_all_users=yes
- }
- socket listen {
- master {
- path = /var/run/dovecot/auth-master
- mode = 0600
- user = email
- group = email
- }
- client {
- path = /var/spool/postfix/private/auth
- mode = 0660
- user = postfix
- group = postfix
- }
- }
- }
- ]
- Next we need to create an empty users file, so create a blank file [/etc/dovecot/users.conf]. We will update it during the next step. To finish with this step, ensure that your configuration files have the proper permissions, by running the following commands:
- [
- chgrp email /etc/dovecot/dovecot.conf
- chmod g+r /etc/dovecot/dovecot.conf
- chown root:root /etc/dovecot/users.conf
- chmod 600 /etc/dovecot/users.conf
- ]
- Step 5: managing domains and mailboxes
- At this point, our SMTP and IMAP/POP3 servers are properly configured. Now all we have to do is create mailboxes and user accounts for the domains of our choice. To begin with, we need to define the list of domains that are being handled by our server. Open up (by this I mean create or edit out) [/etc/postfix/vmail_domains] and insert 1 domain per line, followed by a tabulation character, and the word OK. In our case:
- example.com OK
- example2.com OK
- Now we're going to set up our mailboxes and accounts. There are three files involved, you'll need to edit them out every time you need to make changes to your mail accounts:
- /etc/postfix/vmail_mailbox: contains the list of mailboxes along with their storage path
- /etc/postfix/vmail_aliases: the list of email aliases
- /etc/dovecot/users.conf: stores your encrypted mailbox passwords
- Let's begin by vmail_mailbox. On each line you're supposed to enter the full e-mail address of the mailbox, a tabulation character, then the path of the mailbox files - relative to /var/email as we have indicated in the Dovecot and Postfix configurations. The directories you indicate here do not need to exist, they will be created automatically when needed; however they have to respect the syntax: domain.tld/user. My file contains:
- webmaster@example.com example.com/webmaster
- contact@example.com example.com/contact
- webmaster@example2.com example2.com/webmaster
- Now, on to vmail_aliases. This is the alias list which can be used for email address forwarding or mailing lists. Each line must contain: the source address, a tabulation character, the destination address(es). Here's mine:
- webmaster@example.com webmaster@example.com
- contact@example.com contact@example.com
- webmaster@example2.com webmaster@example.com
- And finally, [/etc/dovecot/users.conf]. This file contains the user accounts and encrypted passwords. Now how do we build that file knowing that passwords will be encrypted? Here's how: repeat the following process for each user/password combination you want to add:
- Generate a password by running this command: [dovecotpw -s SHA1]. It will ask you to enter a password, and output the hashed result like this: {SHA1}qUqP5cyxm6YcTAhz05Hph5gvu9M=. Copy the part highlighted in yellow (the whole line except {SHA1}).
- Open up users.conf and at the bottom of the file, add a new line respecting the following format: mailbox@example.com:password (copied from step 1)
- My users.conf file now looks like this:
- webmaster@example.com:qUqP5cyxm6YcTAhz05Hph5gvu9M=
- contact@example.com:EJ9LPFDXsN9ynSmbxvjp75Bmlx8=
- webmaster@example2.com:RTzySG+IxBH5rWCLVjrvllztsV0=
- Now that you have updated your user database, it's time to apply the changes. Run the following commands for Postfix to acknowledge your newly created mailboxes:
- [
- postmap /etc/postfix/vmail_domains
- postmap /etc/postfix/vmail_mailbox
- postmap /etc/postfix/vmail_aliases
- And now, it's time to start the Postfix and Dovecot services, making sure they're stopped first:
- service postfix stop
- service dovecot stop
- service postfix start
- service dovecot start
- ]
- You can now try your new mailboxes with your favorite email client software. Here are the configuration settings that you may be requested to provide:
- Server: example.com
- User account: webmaster@example.com (full email address)
- Password: the password you chose earlier when you ran the dovecotpw -s SHA1 command
- Protocol: SMTP for sending (authentication required!), POP3 or IMAP for receiving
- Ports: SMTP 25, SMTP secure 587, POP3 110, POP3 secure 995, IMAP 143, IMAP secure 993
- You may need to properly configure the above ports in your server's firewall if you use one. If you have correctly performed all the steps and done as I said, there's no way this can go wrong. I have personally configured a good number of servers following these exact instructions, and it always worked great. Don't hesitate to post comments if you run into problems.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement