Finding Your Mail Server

This list of common mail servers might be helpful. If that doesn’t clear things up, then you can guess at your mail server.

First, find your real IP address as the outside world knows it. I’m using the website here on the command line but you can just put it in a normal browser if that’s convenient:

$ lynx -dump | grep "My ip address"

Find out who your ISP is with reverse lookup:

:-> [prince][~]$ nslookup | grep name name =

Guess what the mail server might be:

:-> [prince][~]$ nc 25

If that works and you get a mail server greeting message, you are ready to interact with it to test it.

Explicit Mail Server Test

The first thing you need to do is verify you have a cooperating mail server. This process allows you to check on the functionality of a putative mail server from the command line with no ambiguity.

220 comcast ESMTP server ready
HELO just setting up my mail and testing the server
250 hello [],
pleased to meet you
250 2.1.0 <> sender ok
250 2.1.5 <> recipient ok
354 enter mail, end with "." on a line by itself
This is a test message from a comcast server.


Sending Mail


I believe that the concept of nullmailer is that instead of your server talking to all the wild mail servers around the world, you only talk to one which you have some control over. The huge advantage of this is that you can hire a good mail handling company to do a good job of it and avoid the predations of your ISP or a Silicon Valley tech giant.

The reason you do not want to really run a mail server yourself (unless you’re a professional and that’s your job) is that mail server minutia is so baroque and a such a slippery moving target — because of spam — that to stay on top of it really is a full time job. When running your own mail server, it seems like every month a major provider starts bouncing your messages because you’ve not adopted some kind of new header or registered yourself with some list or god-knows-what.

I tend not to trust Google or my ISP who would probably let you send mail without too much fuss. But a third party professional who is working for you to provide email services seems better to me.

When I do apt install nullmailer I get this message which is helpful in understanding how all this works:

The following packages will be REMOVED:
  exim4-base exim4-config exim4-daemon-light
The following NEW packages will be installed:

I made a "mailbox" account (using the main account for my hosting provider which handles my email) for the purpose of configuring a constant SMTP server that is independent of any particular predatory ISP. In other words, I pay these people money and they do a good job at receiving and sending my mail without selling me out to criminals. They have a concept of "mailboxes" which I don’t really understand completely; I used a "mailbox" to make a dedicated account just to send things so that credential set was not terribly important to me. If this credential set gets compromised some spammers can send a bit of mail using my outbound pipeline. That’s it.

In the Debian installation, it stops and asks you to enter a "Smarthost" which is just a way to say "flexibly interpreted way to send mail".

Add this line: smtp --port=465 --pass=StupidPlainText --ssl

Or if you’re doing things manually, add that line to this file.


The password as shown for illustration is StupidPlainText which is lame, but the whole point of this account is that it doesn’t really do anything but let me send mail. It deals with the problem that the password must be insecure in plain text in the nullmailer/remotes file anyway. Search for "smtp" in my secure notes for the real thing.

If you’re using apt, it’s probably ready to go. If not, you might need to restart the mailer.

sudo service nullmailer restart
sudo service nullmailer status

Test it out.

cal 2021 | mail -a "From: REMINDER <>" -s "TESTING ra21"


One easy solution to send things is sendEmail:

$ sudo apt-get install sendemail
$ sendEmail -f -t -u "Test message of sendEmail on pr" -s <<<"This is a test message."
Reading message body from STDIN because the '-m' option was not used.
If you are manually typing in a message:
    - First line must be received within 60 seconds.
    - End manual input with a CTRL-D on its own line.
May 15 13:39:36 prince sendEmail[21947]: Message input complete.
May 15 13:39:37 prince sendEmail[21947]: Email was sent successfully!

This can be a good way to test the server.

msmtp and mailx and exim4

Presumably exim4 is already installed because it usually is I think.

$ sudo apt-get install msmtp mailx
$ sudo dpkg-reconfigure exim4-config
 internet site; mail is sent and received directly using SMTP
 mail name=
 listen on= (unless you really want outside mail traffic)
 recipient domains= <empty>
 recipient relay= <empty>
 uncond relay= <empty>
 DNS minimal= No
 delivery format= mbox
 split config= No
 aliases for postmaster and root= "xed"

Then create this file /etc/msmtprc containing:

account cox

account default : cox


account comcast

account default : comcast

Now test:

$ mail -s "test of pr exim cli mail" <<<"This is a test `date`"

And troubleshoot:

$ cat /var/log/exim4/mainlog

Email With Gentoo

Packages Relevant For Email


Widely-used Mail Transport Agent (MTA).


A fast and secure drop-in replacement for sendmail.


The /bin/mail program, which is used to send mail via shell scripts.


Extremely simple MTA to get mail off the system to a Mailhub


An SMTP client and SMTP plugin for mail user agents such as Mutt.


Command line based, SMTP email agent.


Advanced CLI tool for sending email.

mail-client/mailx is important for command line /bin/mail to work with the MTA that is installed (sendmail, postfix, etc).

A Simple Homemade Mail Client
# Here is a quick and dirty mail client designed to just see mail.
# This was written when the route between my house and mail server was
# blocked for some weird reason. I was able to use this on an ssh
# account to look at some critical mail.
import getpass, imaplib

theuser= 'xed'
thepass= getpass.getpass()
mail_server= ''

#M= imaplib.IMAP4()
M= imaplib.IMAP4_SSL(mail_server)

M.login(theuser, thepass)

typ, data=, 'ALL')

for num in data [0].split():
    typ, data = M.fetch(num, '(RFC822)')
    print 'Message %s\n%s\n' % (num, data[0][1])