User avatar
habilis
Posts: 17
Joined: Mon May 15, 2017 2:31 pm
Location: Montreal, Canada
Contact: Website

Raspberry Pi Email Server complete solution

Wed Apr 04, 2018 7:39 pm

Hello,
I'm back and it is time for another Complete tutorial.

Image

Many good folks have requested that I do something about hosting your own Email server on your Raspberry Pi.
Especially in this topic
viewtopic.php?f=36&t=183824

I wasn't entirely sure about this. Since ISPs on residential lines tend to block email ports and all email traffic.

You will be using :

Postfix, open-source mail transfer agent that routes and delivers electronic mail.
Dovecot, open-source IMAP and POP3 server.
MardiaDB (MySQL), to store Email account details.
RoundCube, web-based IMAP email client to read and send your Emails.
You will be using sophisticated though, free web services to audit your configuration, to obtain high security and credibility results.




Server setup
https://habilisbest.com/raspberry-pi-as ... ail-server

How to setup a Webmail client
Image
https://habilisbest.com/round-cube-web- ... spberry-pi

There is another article coming soon
featuring the configuration of
SPF, DKIM, ADSP, DMARC

Those will make sure your email server obtains the best results
Image

Image

Keep this in mind

If you are setting up an Email server using your residential Internet connection:

WARNING : It might just happen that the Email server you've just configured, doesn't work!

There is, probably, nothing wrong with your setup. Just, Be aware that MOST of the ISP (Internet Service Providers) Block Email related ports and traffic on their residential networks.

This is the explanation, they usually provide:
It is being done to limit fraud and other malicious activity from virus-infected computers on our networks.
Just a thing to consider, before panicking, if your server doesn't send nor receive any Emails...
https://habilisbest.com/ My blog where I'm doing cool stuff with Raspberry Pi

Skyway
Posts: 19
Joined: Sun Dec 27, 2015 8:26 pm

Re: Raspberry Pi Email Server complete solution

Tue Nov 27, 2018 6:11 pm

Could you update this? From very first lines, it doesn't work.. That iptables restore gives errors..

gloover
Posts: 2
Joined: Thu Oct 11, 2018 9:42 am

Re: Raspberry Pi Email Server complete solution

Wed Nov 28, 2018 10:42 am

is it possible to integrate a fetchmail or getmail to gather mails from ISP mailboxes such like gmail, yahoo, etc?
Thx in advance!

pfletch101
Posts: 629
Joined: Sat Feb 24, 2018 4:09 am
Location: Buffalo, NY, USA

Re: Raspberry Pi Email Server complete solution

Wed Nov 28, 2018 4:37 pm

habilis wrote:
Wed Apr 04, 2018 7:39 pm
Keep this in mind

If you are setting up an Email server using your residential Internet connection:

WARNING : It might just happen that the Email server you've just configured, doesn't work!

There is, probably, nothing wrong with your setup. Just, Be aware that MOST of the ISP (Internet Service Providers) Block Email related ports and traffic on their residential networks.

This is the explanation, they usually provide:
It is being done to limit fraud and other malicious activity from virus-infected computers on our networks.
Just a thing to consider, before panicking, if your server doesn't send nor receive any Emails...
Your warning doesn't entirely make sense. If email traffic and/or traffic to/from the standard SMTP and POP-3 ports were blocked on a network, you could not send or receive email at all, let alone run a mail server. I have run my own local mail server for more than a decade under a number of ISPs, in England and in the US, and I have never had a problem with using POP-3-related ports to download email from outside servers. I have occasionally run into restrictions on the use of the ISP's servers, of which the most common is a prohibition on forwarding through their SMTP servers either from outside their network (e.g. when away from home) or, more rarely, when using a 'foreign' "From" email address. As long as you have your own domains with email service (as I do), the 'away from home' problem can usually be handled by forwarding through the ISP which hosts the domain, and the home ISP usually provides a workaround for genuine 'foreign' "From" addresses.

User avatar
habilis
Posts: 17
Joined: Mon May 15, 2017 2:31 pm
Location: Montreal, Canada
Contact: Website

Re: Raspberry Pi Email Server complete solution

Fri Feb 15, 2019 8:51 pm

pfletch101 wrote:
Wed Nov 28, 2018 4:37 pm
Your warning doesn't entirely make sense. If email traffic and/or traffic to/from the standard SMTP and POP-3 ports were blocked on a network, you could not send or receive email at all, let alone run a mail server. I have run my own local mail server for more than a decade under a number of ISPs, in England and in the US, and I have never had a problem with using POP-3-related ports to download email from outside servers. I have occasionally run into restrictions on the use of the ISP's servers, of which the most common is a prohibition on forwarding through their SMTP servers either from outside their network (e.g. when away from home) or, more rarely, when using a 'foreign' "From" email address. As long as you have your own domains with email service (as I do), the 'away from home' problem can usually be handled by forwarding through the ISP which hosts the domain, and the home ISP usually provides a workaround for genuine 'foreign' "From" addresses.
True, It doesn't make sense, but it does. :D

My ISP is blocking ports for the reason mentioned above. (The reason mentioned above is the official answer from the ISP to my question why my mail server is not able to send any mail).
Installed a MAIL server on a VPS following the same exact guidelines, I am able to receive and send mail flawlessly on my VPS.


Well, there is no need to not trust me, when there are tools, that can speak on my behalf :P :

Code: Select all

sudo apt-get install nmap
nmap -p 0-65535 portquiz.net > /tmp/nmaptest
grep filtered /tmp/nmaptest
Image

Code: Select all

25/tcp    filtered smtp
135/tcp   filtered msrpc
136/tcp   filtered profile
137/tcp   filtered netbios-ns
138/tcp   filtered netbios-dgm
139/tcp   filtered netbios-ssn
445/tcp   filtered microsoft-ds
I think, this should answer most of your questions.
https://habilisbest.com/ My blog where I'm doing cool stuff with Raspberry Pi

pfletch101
Posts: 629
Joined: Sat Feb 24, 2018 4:09 am
Location: Buffalo, NY, USA

Re: Raspberry Pi Email Server complete solution

Fri Feb 15, 2019 11:57 pm

habilis wrote:
Fri Feb 15, 2019 8:51 pm
pfletch101 wrote:
Wed Nov 28, 2018 4:37 pm
Your warning doesn't entirely make sense. If email traffic and/or traffic to/from the standard SMTP and POP-3 ports were blocked on a network, you could not send or receive email at all, let alone run a mail server. I have run my own local mail server for more than a decade under a number of ISPs, in England and in the US, and I have never had a problem with using POP-3-related ports to download email from outside servers. I have occasionally run into restrictions on the use of the ISP's servers, of which the most common is a prohibition on forwarding through their SMTP servers either from outside their network (e.g. when away from home) or, more rarely, when using a 'foreign' "From" email address. As long as you have your own domains with email service (as I do), the 'away from home' problem can usually be handled by forwarding through the ISP which hosts the domain, and the home ISP usually provides a workaround for genuine 'foreign' "From" addresses.
My ISP is blocking ports for the reason mentioned above. (The reason mentioned above is the official answer from the ISP to my question why my mail server is not able to send any mail).
Installed a MAIL server on a VPS following the same exact guidelines, I am able to receive and send mail flawlessly on my VPS.


I think, this should answer most of your questions.
On reflection, the second sentence in my original post, isn't quite true, since, nowadays, one should in any event be (and I now am) employing secure email protocols that typically use ports 995 (POP-3) and 587 (SMTP). I would be interested to know if your ISP blocks these, and strongly suspect that they don't. My original third sentence, recording my experience over probably at least 15 year, remains true, however, and for much of that time I was using the standard non-secured ports.

Your ISP may well be doing as you say, but I would challenge your claim that "MOST of the ISP (Internet Service Providers) Block Email related ports and traffic on their residential networks." {your emphasis). That certainly does not coincide with my, fairly extensive, experience.

kucingsunken
Posts: 1
Joined: Thu May 21, 2020 12:47 am

Re: Raspberry Pi Email Server complete solution

Thu May 21, 2020 12:56 am

thank you for the thourough guide. i just followed it and it all works, well one thing does not work, turns out my isp also blocks incoming traffic to port 25 like you said earlier :lol:

however it took me sometime to realize this, since i originally run the nmap test from my own home network, it says the port is open. but once i run it over my vps, then it shows that it actually filtered. interestingly enough though they dont block port 587, i wonder if we can swtich to that port for incoming emails.

bls
Posts: 713
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA
Contact: Twitter

Re: Raspberry Pi Email Server complete solution

Thu May 21, 2020 2:56 pm

If your ISP is blocking incoming port 25 traffic, you might be able to use fetchmail on the Pi. fetchmail acts like a mail client to read email on a remote mail server, and then delivers it as you prescribe in the config file. I use it to pull email from my Outlook.com account and send it to a local email account.
Pi tools:
Easily and quickly build customized-just-for-you SD Cards: https://github.com/gitbls/sdm
Free your network from your router's DHCP/DNS:https://github.com/gitbls/ndm
Easy strongSwan VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

Return to “Networking and servers”