Using Putmail.py with Mutt
If you are a regular reader of this journal, you know that I usea variety of software to be productive, organized, and to keep in touch with people. (okay, if you know me, all of these things are debateable, but I am going to pretend that I am all those things). I have been making a concerted effort to move the majority of my tools and computer usage to text and command-line based programs and tools. What follows is my work from this past weekend, getting putmail.py to work with mutt, a termainal-based e-mail package. From now on, I am going to make a better effort to document my setup in the hopes that it helps you out somewhat.
One of the deals you have to make with the devil when you decide to run Mutt as your mail program is that it does not have a way to talk to your mail server or you. See, the developers of mutt believe that each and every program should perform a task and perform it well. Well, the downside of this philosophy is that sometimes you need some helper applications to perform all the tasks you need accomplished. Customizability comes at a price.
One of those tasks is the actual sending of mail from whatever computer on which mutt is running to the receiving server.
Putmail or Putmail.py? I am not even sure the developer knows what the proper name is. Well, it may not be a Christmas Ham, but putmail is a workhorse for sending mail. The advantages are straightforward:
1. Simple
2. Multi-platform
3. Only requirement: Python.
4. Flexible
Since the only requirement is not a problem, as we should already have python installed on any computer upon which we want to run Putmail, this will be one o the easiest things you have ever done on your computer.
As long as python is installed, pretty much, you need only download putmail.py from the putmail site: http://putmail.sourceforge.net and save it somewhere. Notice that the program's only requirement is python. Python can be found on almost any computer. If you are running Linux it is likely alreay there. If you are running Windows, then you should be able to grab a working install from the python download site at http://www.python.org/download/.
And that is pretty much it. With a working python installation, you should be able to run Putmail without too much trouble. A quick run of install.sh from the package should do everything you want and like Emily Post, it will place the appropriate files in the appropriate places with the appropriate accoutrements.
Sinple, really, and all we have left is the configuration files. In your home directory, a couple of simple commands will get you through. Ready to head to the command line? I know you're used to it by now!
cd ~
mkdir .putmail
cd .putmail
emacs putmailrc
And one of the beauties of putmail.py is that its configuration file is so, so simple. Just enter the following into the file:
[config]
server = smtp.gmail.com
email = username@gmail.com
port = 587
tls = 1
username = gmail-loginName
password = Pa$$w0rD
Of course, replacing the appropriate fields with your own pertinent and very personal information. My setup, as always, relies upon the Google Apps for Your Domain services as a backend, so my username entry is just my e-mail address copied. If you are using plain old Gmail, the above should work for you. If you are using some other service, just use your own info. If your server does not support TLS encryption, you can use a '0' or just remove that line entirely. No encryption is the default. Also, if you are not using Gmail, your port is likely the default of '25' and you can eliminate that line, as well. so, a simple non-Gmail config would look something like this:
[confg]
server = mailserver.domain.com
email = user@domain.com
Making Putmail.py work with Mutt
Okay, now you should have Putmail configured, all you have to do is make it work with mutt. As you no doubt still have emacs opened with the putmailrc file, we will move on from there.
1. First, save your configuration file with a C-x C-s command.
2. Next, open your mutt configuration file, C-x C-f and type ~/.muttrc at the 'Find file' prompt at the bottom of your screen.
3. In the .muttrc file, find or create the 'set sendmail' line and change it to set sendmail="/usr/local/bin/putmail.py"
4. Save and exit: C-x C-s, C-x C-c
5. At the command line: chmod 600 ~/.putmail/*
The last one is important because you have just placed your password in cleartext on your computer. Restricting the permissions will help protect that file and keep your password secret.
Fire up mutt and try sending some mail. You can send it to me, if you like, with the subject "Testing mutt with Putmail.py" and I'll respond with a "Congratulations and welcome to the dark side of computing" message or some other similar witticism.
Putmail-queue.py
One of the things I really like about putmail.py is the author's creation of a queuing script. This can be handy in a couple scenarios:
1. You use a laptop not always connected to the internet.
2. You regularly send very large messages and do not want to wait for them to send before you regain control of mutt.
3. You have a slow or sporadic connection to the internet, such as dialup.
Download putmail-queue.py from the same place you got the original putmail package: http://sourceforge.net/project/showfiles.php?group_id=122444
The great thing about using or moving to putmail-queue is that it is practically identical to putmail.py in configuration. After you have followed the above steps, then perform the following at our friend the command line
1. cd ~
2. mkdir .putmail/queue
If you get an error in step #2, then go back and do the configuration for putmail.py. And now, replace the 'set sendmail' command in your .muttrc to point to putmail_enqueue.py instead of just putmail.py. Now when you 'send' mail with mutt, it should just queue it up in the queue directory.
To send the mail queued up in your directory, just run putmail_dequeue.py. You can set this up as a cron job to handle the task for you, and the mail will go out when you have a solid connection to the internet.

0 Comments:
Post a Comment
Links to this post:
Create a Link
<< Home