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.


By default Ubuntu seems to not support non local email.

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 is a good way to test the server for the next level of curing this problem described below.

Here’s how to fix it properly:

$ 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])