Wednesday, February 11, 2009

the pleasure of command line email

I don't think there is anything as satisfying as the simplicity of sending an email at the command line. Like so:
[sodo@ogre ~]$ mail -s "short and sweet" cacasododom@gmail.com
This is my email.
.
EOT
[sodo@ogre ~]$


Simplicity Itself
I mean, really, how sweet is that? No opening a big fat email client, no clicking "Compose Email", no clicking into an address textbox field, no surfing through lists of adressees, you get the point. Command line email is simplicity itself. Of course, its simplicity is its drawback..you can't do the fancy stuff. But for simple communications or piping the input of text files into an email and sending it off, command line email can't be beat.
[sodo@ogre ~]$ mail -s "Fedora 10 random lockups" cacasododom@gmail.com
[sodo@ogre ~]$

Sending Mail Via Comcast
Fedora 10's base install comes with "mail". However, you need to tweak your .mailrc file for it to work with your mail provider. In my case, I am on Comcast. Comcast's mail requires your username and password. And of course you need to specify the outbound SMTP server. Finally, I want to set the "From:" address, so replies go to the right place. So my .mailrc file looks like this:
[sodo@ogre ~]$ cat .mailrc
set smtp-auth-user=myaccount
set smtp-auth-password=password
set smtp=smtp.comcast.net
set from=myaccount@comcast.net

Just put this .mailrc file in your home directory and you should be good to go. Test it by sending a mail from the command line:
[sodo@ogre ~]$ mail -s "test email #1" yourtestemail@mailhost.com < /dev/null
[sodo@ogre ~]$

Test That This Works
After sending your email, you may get a bounce back if something is incorrectly configured. So you may receive a message at the command line:
[sodo@ogre ~]$
You have new mail in /var/spool/mail/root
[sodo@ogre ~]$

Just type "mail" and hit enter. The interactive version of "mail" will start and you'll see a list of mail headers:
[sodo@ogre ~]$ mail
Heirloom Mail version 12.4 7/29/08. Type ? for help.
"/var/spool/mail/sodo": 2 messages
> 1 Mail Delivery Subsys Fri Feb 6 11:07 253/20968 "Returned mail: see transcript for details"
2 Mail Delivery Subsys Fri Feb 6 11:07 249/20491 "Returned mail: see transcript for details"

Type the number of the email header (1, 2, 3, etc) to see its contents.
Message
1:From MAILER-DAEMON@localhost.localdomain Fri Feb 6 11:07:40 2009
Return-Path: <MAILER-DAEMON@localhost.localdomain>
Date: Fri, 6 Feb 2009 11:07:40 -0500
From: Mail Delivery Subsystem <MAILER-DAEMON@localhost.localdomain>
To: <sodo@localhost.localdomain>
Content-Type: multipart/report; report-type=delivery-status; boundary="n16G7eTG018842.1233936460/localhost.localdomain"
Subject: Returned mail: see transcript for details
Auto-Submitted: auto-generated (failure)
Status: RO

Part 1:

The original message was received at Fri, 6 Feb 2009 11:07:39 -0500
from localhost.localdomain [127.0.0.1]

----- The following addresses had permanent fatal errors -----<
cacasododom@gmail.com> (reason: 554 Blocked by SPAM RBL check senderbase.org orwikipedia.org/wiki/DNSBL)

Debug
Usually, there will be a very clear indication in the email as to what is going on. Such as in the above email:
reason: 554 Blocked by SPAM RBL check senderbase.org orwikipedia.org/wiki/DNSBL

Type "quit" to exit.

So that's it. Enjoy your command line email!
TAG


PS - As shown in the example above, I have been experiencing some random lockups in Fedora 10: http://forums.fedoraforum.org/showthread.php?t=205950
My current workaround is to use the "noapic" command line option. But I will need to further investigate why these lockups just started happening with Fedora 10. They didn't happen with Fedora 9 or 7!

No comments:

Feel free to drop me a line or ask me a question.