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 my-i-p.com here on the command line but you can just put it in a normal browser if that’s convenient:
$ lynx -dump my-i-p.com | grep "My ip address"
Find out who your ISP is with reverse lookup:
:-> [prince][~]$ nslookup 184.108.40.206 | grep name 220.127.116.11.in-addr.arpa name = c-76-124-159-147.hsd1.nj.comcast.net.
Guess what the mail server might be:
:-> [prince][~]$ nc smtp.comcast.net 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 OMTA11.westchester.pa.mail.comcast.net comcast ESMTP server ready HELO just setting up my mail and testing the server 250 OMTA11.westchester.pa.mail.comcast.net hello [18.104.22.168], pleased to meet you MAIL FROM: firstname.lastname@example.org 250 2.1.0 <email@example.com> sender ok RCPT TO: firstname.lastname@example.org 250 2.1.5 <email@example.com> recipient ok DATA 354 enter mail, end with "." on a line by itself This is a test message from a comcast server. . QUIT
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 firstname.lastname@example.org -t email@example.com -u "Test message of sendEmail on pr" -s smtp.comcast.net <<<"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: Message input complete. May 15 13:39:37 prince sendEmail: 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= example.xed.ch listen on= 127.0.0.1 (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 firstname.lastname@example.org"
Then create this file /etc/msmtprc containing:
account cox host smtp-server.san.rr.com account default : cox
account comcast host smtp.comcast.net account default : comcast
$ mail -s "test of pr exim cli mail" email@example.com <<<"This is a test `date`"
$ 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.
A Simple Homemade Mail Client
#!/usr/bin/python # 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= 'mail66.theisp.com' #M= imaplib.IMAP4() M= imaplib.IMAP4_SSL(mail_server) M.login(theuser, thepass) M.select() typ, data= M.search(None, 'ALL') for num in data .split(): typ, data = M.fetch(num, '(RFC822)') print 'Message %s\n%s\n' % (num, data) M.close() M.logout()