ubuntu:email:install_postfix_mail_server_with_dovecot
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
ubuntu:email:install_postfix_mail_server_with_dovecot [2020/12/06 12:19] – peter | ubuntu:email:install_postfix_mail_server_with_dovecot [2020/12/06 13:07] (current) – removed peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Ubuntu - Email - Install Postfix Mail Server with Dovecot ====== | ||
- | |||
- | **Postfix** is responsible for interacting with the other email servers in the world. | ||
- | |||
- | Postfix is used to either send mail to, or receive mail from, other servers. | ||
- | |||
- | **Dovecot** interacts with your email client (Thunderbird, | ||
- | |||
- | ---- | ||
- | |||
- | ====== Install Postfix ====== | ||
- | |||
- | <code bash> | ||
- | sudo apt install postfix | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | ===== Virtual Mailboxes ===== | ||
- | |||
- | Create a user that will actually own all the virtual mailboxes. | ||
- | |||
- | <code bash> | ||
- | useradd -m -r -s / | ||
- | </ | ||
- | |||
- | <WRAP info> | ||
- | **NOTE: | ||
- | |||
- | The virtual mailboxes will be placed in this directory. | ||
- | |||
- | Virtual mailboxes allow us to unlink the users of the email system from the users on the underlying operating system. | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | ===== Configuring Postfix ===== | ||
- | |||
- | The configuration files for Postfix are usually found in **/ | ||
- | |||
- | The two most important files are **main.cf** and **master.cf**. | ||
- | |||
- | ---- | ||
- | |||
- | ==== Basic Configuration ==== | ||
- | |||
- | The file **main.cf** will be completely replaced. | ||
- | |||
- | It should start with the basic configuration: | ||
- | |||
- | <file bash / | ||
- | mydomain = sharewiz.net | ||
- | myhostname = mail2.$mydomain | ||
- | myorigin = $mydomain | ||
- | mydestination = $myhostname, | ||
- | mynetworks = 127.0.0.0/8 [:: | ||
- | inet_interfaces = all | ||
- | mailbox_size_limit = 0 | ||
- | home_mailbox = mail/ | ||
- | |||
- | # Prevent bad guys from querying for valid email addresses. | ||
- | disable_vrfy_command = yes | ||
- | </ | ||
- | |||
- | **NOTE: | ||
- | |||
- | * **myorigin** defines the domain used for outgoing messages. | ||
- | * **mydestination** gives the non-virtual domains for which mail will be accepted. | ||
- | * $mydomain is not contained in mydestination. That is intentional. | ||
- | |||
- | Postfix will reject any mail that it receives that is not destined for a domain or machine that is not listed in mydestination (or in the virtual mail domains defined later) unless it comes from a machine on the local network. | ||
- | |||
- | * **mynetworks** defines the local network. | ||
- | * **mailbox_size_limit = 0** is used to disable limits on the size of the mail that can be received into a mailbox. | ||
- | * **home_mailbox** define the name of the mailbox used for local users. | ||
- | |||
- | ---- | ||
- | |||
- | ==== Local Aliases ==== | ||
- | |||
- | <file bash / | ||
- | alias_maps = hash:/ | ||
- | alias_database = hash:/ | ||
- | |||
- | # Configure list of users/ | ||
- | local_recipient_maps = proxy: | ||
- | </ | ||
- | |||
- | <WRAP info> | ||
- | **NOTE: | ||
- | |||
- | You should not have to create this file nor change it, but if you do change it, you will need to run the following before the changes will take effect: | ||
- | |||
- | <code bash> | ||
- | postalias / | ||
- | </ | ||
- | |||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | ===== Virtual Mailboxes ===== | ||
- | |||
- | How should local delivery be performed? | ||
- | |||
- | Local delivery is that act of moving a piece of email from Postfix to the users mailbox. | ||
- | |||
- | For Local Delivery, we could use: | ||
- | |||
- | * **Postfix**: | ||
- | * **Dovecot**: | ||
- | |||
- | ---- | ||
- | |||
- | ==== Using the Postfix LDA ==== | ||
- | |||
- | To configure the Postfix local delivery agent for virtual mailboxes, add the following to main.cf: | ||
- | |||
- | <file bash / | ||
- | virtual_mailbox_domains = sharewiz.net abcd.com | ||
- | virtual_mailbox_maps = hash:/ | ||
- | virtual_alias_maps = hash:/ | ||
- | virtual_mailbox_base=/ | ||
- | virtual_uid_maps = static:997 | ||
- | virtual_gid_maps = static:997 | ||
- | virtual_minimum_uid = 997 | ||
- | </ | ||
- | |||
- | <WRAP info> | ||
- | **NOTE:** There are two virtual mail domains: sharewiz.net and abcd.com defined. | ||
- | |||
- | These two domains will be added to the list of domains for which Postfix will accept mail. | ||
- | |||
- | The actual virtual mailboxes are defined in **/ | ||
- | |||
- | <file bash / | ||
- | peter@sharewiz.net | ||
- | peter@abcd.net | ||
- | admin@sharewiz.net | ||
- | </ | ||
- | |||
- | Each line defines a virtual mailbox and consists of two items. | ||
- | |||
- | * The first item is the email address of the virtual mailbox (should be lowercase). | ||
- | * The second item is the physical address on disk. | ||
- | * **NOTE:** Each of the second entries ends with a slash. | ||
- | * The physical address of the mailbox specified must be consistent with what Dovecot expects, which is set in the userdb section of the Dovecot configuration file. The correspondence is a bit complicated. | ||
- | |||
- | The mail directory for **peter@sharewiz.net** would be **/ | ||
- | |||
- | Whenever you modify this file you must run **postmap** in order to Postfix to be aware of the changes: | ||
- | |||
- | <code bash> | ||
- | postmap / | ||
- | </ | ||
- | |||
- | |||
- | </ | ||
ubuntu/email/install_postfix_mail_server_with_dovecot.1607257149.txt.gz · Last modified: 2020/12/06 12:19 by peter