Set up Mail Server Documentation 1.0
Total Page:16
File Type:pdf, Size:1020Kb
Set Up Mail Server Documentation 1.0 Nosy 2014 01 23 Contents 1 1 1.1......................................................1 1.2......................................................2 2 11 3 13 3.1...................................................... 13 3.2...................................................... 13 3.3...................................................... 13 4 15 5 17 5.1...................................................... 17 5.2...................................................... 17 5.3...................................................... 17 5.4...................................................... 18 6 19 6.1...................................................... 19 6.2...................................................... 28 6.3...................................................... 32 6.4 Webmail................................................. 36 6.5...................................................... 37 6.6...................................................... 38 7 39 7.1...................................................... 39 7.2 SQL.................................................... 41 8 43 8.1...................................................... 43 8.2 strategy.................................................. 43 8.3...................................................... 44 8.4...................................................... 45 8.5...................................................... 45 8.6 Telnet................................................... 46 8.7 Can postfix receive?........................................... 46 i 8.8 Can postfix send?............................................. 47 8.9 Can courier read emails......................................... 47 9 49 9.1...................................................... 49 9.2...................................................... 49 9.3...................................................... 50 9.4 MySQL................................................. 50 9.5...................................................... 51 9.6...................................................... 51 9.7...................................................... 52 9.8...................................................... 52 9.9...................................................... 52 9.10...................................................... 52 10 53 10.1 MX................................................... 53 10.2...................................................... 55 10.3 IDSPF.................................................. 56 10.4...................................................... 57 10.5 /...................................................... 57 10.6 PGP & S/MIME............................................. 58 10.7...................................................... 58 10.8 Pop-before-SMTP............................................ 59 10.9...................................................... 59 10.10...................................................... 59 10.11...................................................... 59 10.12...................................................... 59 10.13...................................................... 59 10.14 Google Apps / GMail.......................................... 60 10.15 Squirrel Mail............................................... 62 10.16...................................................... 63 10.17...................................................... 63 10.18...................................................... 64 10.19 ?..................................................... 64 11 Elastic Compute Cloud 65 12 67 12.1...................................................... 67 12.2...................................................... 67 12.3...................................................... 67 12.4...................................................... 67 12.5...................................................... 68 12.6...................................................... 69 12.7...................................................... 69 12.8...................................................... 70 12.9 Difference between Ubuntu versions................................... 70 12.10...................................................... 70 12.11...................................................... 70 12.12 Todo................................................... 71 12.13 FAQ.................................................... 71 13 73 13.1 mailman................................................. 73 ii 13.2 phplist.................................................. 116 14 VERP 117 14.1...................................................... 117 14.2 VERP................................................... 117 14.3...................................................... 118 14.4...................................................... 118 14.5 Without VERP.............................................. 118 14.6 With VERP................................................ 118 14.7 VERP................................................... 119 14.8...................................................... 119 14.9...................................................... 120 15 Indices and tables 121 iii iv CHAPTER 1 1.1 : http://www.pixelinx.com/2010/10/creating-a-mail-server-on-ubuntu-using-postfix-courier-ssltls-spamassassin- clamav-and-amavis/ : This guide has been updated to work with Ubuntu 12.04 LTS. : this has been tested to work on the following versions of Ubuntu: • Ubuntu 12.04 • Ubuntu 11.04 • Ubuntu 10.04 • Ubuntu 9.04 One of the most fragile and fragmented services I’ve had to configure on Ubuntu is a mail server. No matter which of the many guides I follow, each time I do it there’s always something not working. This one is mostly for my benefit, but hopefully it’ll be useful to others, too. I’ve tried to make the guide easy to follow and as short as possible. Please comment if something isn’t clear. Before we start, I have to give a huge amount of credit to Ivar Abrahamsen for his guide which is, by far, one of the best ones out there. So let’s kick off. : • Postfix is the mail transfer agent (MTA) responsible for accepting new messages and storing them on your server as well as allowing authorised users to send e-mail. • Courier sits in front of Postfix and provides an IMAP and POP3 interface for clients to connect to. • SASL with SSL and TLS allows you to authenticate and communicate with the mail server securely. • SpamAssassin will analyse your e-mails as they arrive and will filter out what it thinks is spam. • ClamAV will scan e-mails for viruses before delivering it to your inbox. • Amavis ties SpamAssasin and ClamAV together, and is itself hooked into Postfix. • MySQL will be used to manage user accounts and e-mail forwarding. 1 Set Up Mail Server Documentation, 1.0 1.2 ,. sudo su - apt-get update apt-get install -y mysql-server postfix postfix-mysql libsasl2-modules libsasl2-modules-sql libgsasl7 libauthen-sasl-cyrus-perl sasl2-bin libpam-mysql clamav-base libclamav6 clamav-daemon clamav-freshclam amavisd-new spamassassin spamc courier-base courier-authdaemon courier-authlib-mysql courier-imap courier-imap-ssl courier-pop courier-pop-ssl courier-ssl During the installation of MySQL you will be prompted for the root user password, as shown: Enter a secure password, and don’t forget it! Similarly, during the installation of Courier you will be presented with the following configuration prompts: Choose No Choose OK Choose Internet Site Enter your mail server name (e.g. replace example.com with your own domain). Make sure you have this subdomain configured in your DNS records. Choose OK I won’t walk you through the parameters we’re using when configuring Postfix as I want to keep this guide light. If you’re interested, you can find more information from the man pages. 2 Chapter 1. Set Up Mail Server Documentation, 1.0 mv /etc/postfix/main.cf{,.default} vi /etc/postfix/main.cf Copy/paste the following (change all instances of mail.example.com): myorigin= /etc/mailname smtpd_banner = $myhostname ESMTP $mail_name biff = no append_dot_mydomain = no readme_directory = no mydestination = relayhost = mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mynetworks_style = host mail- box_size_limit = 0 virtual_mailbox_limit = 0 recipient_delimiter = + inet_interfaces = all message_size_limit = 0 # SMTP Authentication (SASL) smtpd_sasl_auth_enable = yes broken_sasl_auth_clients = yes smtpd_sasl_security_options = noanonymous smtpd_sasl_local_domain = # Encrypted transfer (SSL/TLS) smtp_use_tls = yes smtpd_use_tls = yes smtpd_tls_cert_file = /etc/ssl/private/mail.example.com.crt smtpd_tls_key_file = /etc/ssl/private/mail.example.com.key smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache # Basic SPAM prevention smtpd_helo_required = yes smtpd_delay_reject = yes disable_vrfy_command = yes smtpd_sender_restrictions = permit_sasl_authenticated, permit_mynetworks, reject smtpd_recipient_restrictions = permit_sasl_authenticated, per- mit_mynetworks, reject # Force incoming mail to go through Amavis content_filter = amavis:[127.0.0.1]:10024 receive_override_options = no_address_mappings # Virtual user mappings alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases virtual_mailbox_base = /var/spool/mail/virtual vir- tual_mailbox_maps = mysql:/etc/postfix/maps/user.cf virtual_uid_maps = static:5000 virtual_gid_maps = static:5000 virtual_alias_maps = mysql:/etc/postfix/maps/alias.cf virtual_mailbox_domains = mysql:/etc/postfix/maps/domain.cf