Hi!
If you are happy to use your ISPs email service, please stop reading now....
If you plan to use your own registered domain for your email server, you should be aware that DNS(es) does not work the same for emails as for simple host lookups. The DNS databases has several types of entries. 'A' for normal lookups for a web or ftp server for example. They only return one (or several) IP address, so it is up to the application/protocol to decide what port number to use. The entry type for email is called 'MX'. It often contains one or several host names in a prioritized list.
When you send an email, the SMTP protocol is used. It looks up the MX entry in the DNS, and it is only possible to use port 25. You cannot specify a port number in an email address.
Here is an example of google's DNS 'A' record of dn.se (a popular Swedish newspaper):
Code: Select all
$ dig @8.8.8.8 dn.se A
; <<>> DiG 9.7.3 <<>> @8.8.8.8 dn.se A
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 49083
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;dn.se. IN A
;; ANSWER SECTION:
dn.se. 17503 IN A 212.28.194.152
;; Query time: 27 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Thu Dec 20 19:22:47 2012
;; MSG SIZE rcvd: 39
It can contain several IP addresses, but it is pretty simple with just the one.
Here is the same same for the MX record:
Code: Select all
$ dig @8.8.8.8 dn.se MX
; <<>> DiG 9.7.3 <<>> @8.8.8.8 dn.se MX
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55449
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;dn.se. IN MX
;; ANSWER SECTION:
dn.se. 600 IN MX 10 dn-mf03.dn.se.
dn.se. 600 IN MX 10 dn-mf02.dn.se.
;; Query time: 61 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Thu Dec 20 19:22:34 2012
;; MSG SIZE rcvd: 71
This is for email sent to ...@dn.se. As you see they list actual host names rather than IP addresses.
They can list several options, and even given them priority.
Here is your first problem:
You must make sure that your domain registrar allows you to control ALL your entries in the DNS database.
I had to change mine as they didn't even know what a MX record was... They are not happy to give up control over "their" domains, even though it belongs to you.
As all SMTP uses port 25, and almost ALL ISPs block that port to avoid spam, you have to do some trickery to set up your own proper postfix and dovecot solution.
When you send email, postfix will try to send it on port 25, as all other email servers uses that port. This won't work as the ISP blocks it. You can use relay email services who accepts incoming SMTP messages on other ports.
The problem is that even if you set up postfix to use a relayhost with another port, the relayhost will most likely not accept messages in clear text. Postfix can be configured to use another port, but it will still use plain text SMTP.
The solution is stunnel4 (available in the repositories, and easy to configure). It opens a listener port on your B3 where postfix can connect to and send it's stuff. Stunnel4 is configured to encrypt the traffic with SSL, making it acceptable to the relayhost. This is called SMTPS and it is somewhat of an afterthought (or hack). The port used is traditionally 465.
Now for reading your email through dovecot, it must first be delivered to postfix.
There are several ways of doing this. I opted for a company that receives my email and then send it to my server on port 52525. I have to pay for this service. I also have to point my DNS MX records to the service provider's email servers. I'm sure there are better solutions than this, but I've been using for ever, and I can't be arsed to shop around for better solutions. Perhaps SASL could be worth looking into.
Once your email is on your server, the communications between dovecot and your preferred email client already has the means to encrypt your data.
Hope this might be of some help,
(and please feel free to correct me if I'm talking out of my arse again

)
Cheeseboy
PS:
Google for postfix stunnel4 SASL