Stephen Philbin
09-02-2007, 06:20 AM
Hi folks, I was wondering if anyone could help me out of mail-server setup hell.
I'd been putting off setting up my mail server for quite some time now. I had a try years ago and just got completely bamboozled my all this strange talk of using "M4" to create configuration files. I'd only really delt with configuration via the "./configure --opts=args" command-line style and the configuration file style like that of my.cnf of mysql and httpd.conf of the Apache http server and so on. So I couldn't really make head nor tail of writing a .mc configuration file and then "using the M4 preprocessor to generate a .cf configuration file" and so on. It all had me rather confused.
However, now that I'm finally getting somewhere with building my site, I want to set up email on it properly so I can use addresses from my domain. As much as I want to use email from my domain in the normal way, I also want it available for automated mail too. It's rather annoying that every mail my system sends out gets thrown straight in the bin simply because I can't get incoming mail to be accepted.
At first, I asked my hosting provider to set it up for me. I asked them to install and configure the necessary software for my domain to be able to send and recieve email and then leave me the information I need to be able to add, edit and delete accounts as and when I desire. I also told them to keep sendmail installed because I know that's the program PHP uses to send mail out. So they went ahead and uninstalled sendmail, installed something else in its place and then gave up trying to figure it out and just gave me a link to the "manual" for configuring the now-uninstalled sendmail via one of those awful web-based host account administration panels (y'know, like cPanel and all that crap).
So, with my mail software thoroughly decimated, I saw no other option but for me to try and fix everything myself. Luckily I got sendmail reinstalled pretty quickly. The OS on my VPS is Debian, so it was just a case of a quick "apt-get install sendmail" and it chucked out the MTA the support staff put on and put Sendmail back in its place. Unfortunately for me, however, it seems that the installation apt-get found and installed is broken by default. It wasn't anything too major, though. Just enough to force me to have to figure out what all this "M4" talk was about and re-order a few things in the config files. So, I now have a reasonable enough understanding of the basics of how configuring Sendmail using M4 works and I once again have a working local MTA. So things like echo "Body text of a mail message." | mail -s "Subject text of a mail message" user and echo "Body text of a mail message." | mail -s "Subject text of a mail message" user@domain.com work fine (although like I said, the one to a user on another domain like gmail.com or hotmail.com gets thrown straight into the trash/spam bucket).
After much reading of documentation and various other sources of information, I then found that having Sendmail installed is only half of the job. I also needed a POP3 server to recieve mail from a remote client and then pass it on to Sendmail as if it was from a local user because Sendmail has no authentication mechanism and so can be either an open relay for mail from the entire internet (not good), a relay for specified domains and static addresses (better, but still entirely useless) or closed and relaying mail from local users only. So after a bit of looking around and reading, I decided to Go with Dovecot (http://www.dovecot.org/) as my POP3 server. I've installed and configured it in so far as I can now connect to my domain via Dovecot and retrieve mail from the /var/mail/$USERNAME files, but I still can't send outgoing mail and recieve incoming mail from another domain.
I think everything would work if I could just get one last thing done, but I can't find out how. I think all I need to do now is enable Dovecot to listen on ports 25 and 465 so that it can relay incoming mail to Sendmail locally.
telnet stephenphilbin.com 25 begins connecting, but then does nothing until the connection times out and telnet stephenphilbin.com 465 gets the connection refused immediately, so I'm guessing there's nothing listening on 465 and netstat -nlp | grep 25 confirmed my suspicion that Sendmail is listening on 25. Sendmail doesn't trust any external domains for relaying mail, though, so I'm guessing that's why nothing happens until the connection times out. It also means that it's listening on a port it has no need to listen on and is blocking Dovecot from listening on 25 too.
So I guess my question is, does anyone know how to get Sendmail to stop listening on port 25? The only thing I've seen which I think might be a likely candidate is the line MAILER(`smtp') at the end of my main Sendmail configuration file. I suspect that removing this might stop Sendmail listening on 25, but I suspect it might also stop Sendmail relaying mail on to other domains too. I've been reading the Sendmail documentation (yet again) but I can't make a lot of sense of most of what I've read so far.
I'll also still need to find how to get Dovecot to listen on 25 and 465, but my primary concern, for now, is just getting Sendmail to stop listening on 25 without stopping it from relaying via SMTP to other domains.
I'd been putting off setting up my mail server for quite some time now. I had a try years ago and just got completely bamboozled my all this strange talk of using "M4" to create configuration files. I'd only really delt with configuration via the "./configure --opts=args" command-line style and the configuration file style like that of my.cnf of mysql and httpd.conf of the Apache http server and so on. So I couldn't really make head nor tail of writing a .mc configuration file and then "using the M4 preprocessor to generate a .cf configuration file" and so on. It all had me rather confused.
However, now that I'm finally getting somewhere with building my site, I want to set up email on it properly so I can use addresses from my domain. As much as I want to use email from my domain in the normal way, I also want it available for automated mail too. It's rather annoying that every mail my system sends out gets thrown straight in the bin simply because I can't get incoming mail to be accepted.
At first, I asked my hosting provider to set it up for me. I asked them to install and configure the necessary software for my domain to be able to send and recieve email and then leave me the information I need to be able to add, edit and delete accounts as and when I desire. I also told them to keep sendmail installed because I know that's the program PHP uses to send mail out. So they went ahead and uninstalled sendmail, installed something else in its place and then gave up trying to figure it out and just gave me a link to the "manual" for configuring the now-uninstalled sendmail via one of those awful web-based host account administration panels (y'know, like cPanel and all that crap).
So, with my mail software thoroughly decimated, I saw no other option but for me to try and fix everything myself. Luckily I got sendmail reinstalled pretty quickly. The OS on my VPS is Debian, so it was just a case of a quick "apt-get install sendmail" and it chucked out the MTA the support staff put on and put Sendmail back in its place. Unfortunately for me, however, it seems that the installation apt-get found and installed is broken by default. It wasn't anything too major, though. Just enough to force me to have to figure out what all this "M4" talk was about and re-order a few things in the config files. So, I now have a reasonable enough understanding of the basics of how configuring Sendmail using M4 works and I once again have a working local MTA. So things like echo "Body text of a mail message." | mail -s "Subject text of a mail message" user and echo "Body text of a mail message." | mail -s "Subject text of a mail message" user@domain.com work fine (although like I said, the one to a user on another domain like gmail.com or hotmail.com gets thrown straight into the trash/spam bucket).
After much reading of documentation and various other sources of information, I then found that having Sendmail installed is only half of the job. I also needed a POP3 server to recieve mail from a remote client and then pass it on to Sendmail as if it was from a local user because Sendmail has no authentication mechanism and so can be either an open relay for mail from the entire internet (not good), a relay for specified domains and static addresses (better, but still entirely useless) or closed and relaying mail from local users only. So after a bit of looking around and reading, I decided to Go with Dovecot (http://www.dovecot.org/) as my POP3 server. I've installed and configured it in so far as I can now connect to my domain via Dovecot and retrieve mail from the /var/mail/$USERNAME files, but I still can't send outgoing mail and recieve incoming mail from another domain.
I think everything would work if I could just get one last thing done, but I can't find out how. I think all I need to do now is enable Dovecot to listen on ports 25 and 465 so that it can relay incoming mail to Sendmail locally.
telnet stephenphilbin.com 25 begins connecting, but then does nothing until the connection times out and telnet stephenphilbin.com 465 gets the connection refused immediately, so I'm guessing there's nothing listening on 465 and netstat -nlp | grep 25 confirmed my suspicion that Sendmail is listening on 25. Sendmail doesn't trust any external domains for relaying mail, though, so I'm guessing that's why nothing happens until the connection times out. It also means that it's listening on a port it has no need to listen on and is blocking Dovecot from listening on 25 too.
So I guess my question is, does anyone know how to get Sendmail to stop listening on port 25? The only thing I've seen which I think might be a likely candidate is the line MAILER(`smtp') at the end of my main Sendmail configuration file. I suspect that removing this might stop Sendmail listening on 25, but I suspect it might also stop Sendmail relaying mail on to other domains too. I've been reading the Sendmail documentation (yet again) but I can't make a lot of sense of most of what I've read so far.
I'll also still need to find how to get Dovecot to listen on 25 and 465, but my primary concern, for now, is just getting Sendmail to stop listening on 25 without stopping it from relaying via SMTP to other domains.