Advertisement
Guest User

Untitled

a guest
Sep 1st, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.55 KB | None | 0 0
  1. dovecot unix - n n - - pipe
  2. flags=DRhu user=email:email argv=/usr/lib/dovecot/deliver -f ${sender} -d ${recipient}
  3.  
  4.  
  5. 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:
  6. [
  7. pwcheck_method: saslauthd
  8. mech_list: plain login cram-md5 digest-md5
  9. ]
  10.  
  11.  
  12. Step 4: configuring Dovecot
  13. 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.
  14. [
  15. # Basic configuration
  16. protocols = imap imaps pop3 pop3s
  17. log_timestamp = "%Y-%m-%d %H:%M:%S "
  18. disable_plaintext_auth=yes
  19.  
  20. # User and group permissions
  21. first_valid_uid=7788
  22. last_valid_uid=7788
  23. first_valid_gid=7788
  24. last_valid_gid=7788
  25. mail_location = maildir:/var/email/%d/%n/Maildir
  26. mail_privileged_group = email
  27. auth_executable = /usr/lib/dovecot/dovecot-auth
  28. auth_verbose = yes
  29.  
  30. # SSL config
  31. ssl_cert_file = /etc/ssl/private/example.com.cert
  32. ssl_key_file = /etc/ssl/private/example.com.key
  33.  
  34. # LDA config
  35. protocol lda {
  36. auth_socket_path = /var/run/dovecot/auth-master
  37. postmaster_address = postmaster@example.com
  38. mail_plugins = sieve
  39. log_path =
  40. }
  41.  
  42. # Authentication configuration
  43. auth default {
  44. mechanisms = plain login
  45. passdb passwd-file {
  46. args = scheme=SHA1 /etc/dovecot/users.conf
  47. }
  48. userdb static {
  49. #args = /etc/dovecot/users.conf
  50. args = uid=7788 gid=7788 home=/var/email/%d/%n allow_all_users=yes
  51. }
  52. socket listen {
  53. master {
  54. path = /var/run/dovecot/auth-master
  55. mode = 0600
  56. user = email
  57. group = email
  58. }
  59. client {
  60. path = /var/spool/postfix/private/auth
  61. mode = 0660
  62. user = postfix
  63. group = postfix
  64. }
  65. }
  66. }
  67. ]
  68.  
  69. 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:
  70.  
  71. [
  72. chgrp email /etc/dovecot/dovecot.conf
  73. chmod g+r /etc/dovecot/dovecot.conf
  74. chown root:root /etc/dovecot/users.conf
  75. chmod 600 /etc/dovecot/users.conf
  76. ]
  77.  
  78. Step 5: managing domains and mailboxes
  79. 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:
  80. example.com OK
  81. example2.com OK
  82.  
  83. 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:
  84. /etc/postfix/vmail_mailbox: contains the list of mailboxes along with their storage path
  85. /etc/postfix/vmail_aliases: the list of email aliases
  86. /etc/dovecot/users.conf: stores your encrypted mailbox passwords
  87. 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:
  88. webmaster@example.com example.com/webmaster
  89. contact@example.com example.com/contact
  90. webmaster@example2.com example2.com/webmaster
  91.  
  92. 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:
  93. webmaster@example.com webmaster@example.com
  94. contact@example.com contact@example.com
  95. webmaster@example2.com webmaster@example.com
  96.  
  97. 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:
  98. 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}).
  99. 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)
  100. My users.conf file now looks like this:
  101. webmaster@example.com:qUqP5cyxm6YcTAhz05Hph5gvu9M=
  102. contact@example.com:EJ9LPFDXsN9ynSmbxvjp75Bmlx8=
  103. webmaster@example2.com:RTzySG+IxBH5rWCLVjrvllztsV0=
  104.  
  105. 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:
  106. [
  107. postmap /etc/postfix/vmail_domains
  108. postmap /etc/postfix/vmail_mailbox
  109. postmap /etc/postfix/vmail_aliases
  110.  
  111. And now, it's time to start the Postfix and Dovecot services, making sure they're stopped first:
  112. service postfix stop
  113. service dovecot stop
  114. service postfix start
  115. service dovecot start
  116. ]
  117. 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:
  118. Server: example.com
  119. User account: webmaster@example.com (full email address)
  120. Password: the password you chose earlier when you ran the dovecotpw -s SHA1 command
  121. Protocol: SMTP for sending (authentication required!), POP3 or IMAP for receiving
  122. Ports: SMTP 25, SMTP secure 587, POP3 110, POP3 secure 995, IMAP 143, IMAP secure 993
  123. 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