apt-get install postfix mailutils alpine
Choose "internet site" when asked.
You will require fully qualified domain name (FQDN) and with properly configured MX record.
You can use the "dig" command to verify your MX record. The output will include the following lines;
dig mydomain.com mx
;; ANSWER SECTION:
mydomain.com. 2857 IN MX 10 mail.mydomain.com.
;; ADDITIONAL SECTION:
mail.mydomain.com. 2862 IN A 184.108.40.206
Your MX record should point to the A record for your mail server as it does in the above example.
The mail server must of course be contactable from the Internet.
Now, we need to configure a few things in postfix. Edit mail.cf
sudo vi /etc/postfix/main.cf
Modify the following lines with the details shown as bold
myhostname = mydomain.com mydestination = mydomain.com, localhost.localdomain, localhost
If you are running behind NAT/proxy you will need to ensure that port 25 is forwarded from your router and advise postfix it is operating behind a NAT/firewall.
Add this line to the main.cf file;
The address must be the same as the mail server IP that is shown in the ADDITIONAL SECTION from our dig command from before.
sudo service postfix restart
Try sending an email to an external address;
mail -s Test firstname.lastname@example.org
Assuming you get the mail you should reply to it.
You can check whether it arrives using alpine;
Select "Folder List" ("L" key) to see any messages.