Home|Cudeso|Linux|*NIX / BSD|Misc|
 

Gotmail

Contents

1. Introduction

2. Useful resources

3. Getting the package

4. Usage

5. Configuration

6. CronJob

7. Security

8. Hotwayd





1. Introduction

GotMail is a very nice Perl-script written by Peter Hawkins (peter AT hawkins.emu.id.au) that provides you with an easy way to retrieve all your hotmail-accounts and delivers them to a local account or another e-mailaccount.

As of may 2002 the project is maintainted by Paul Cannon (check it out at http://ssl.usu.edu/paul/gotmail/). Paul has been the maintainer for Debian packages for a while and has released a new version that can cope with the recent Hotmail changes.

First of all, what is GotMail?

I quote Freshmeat.net
GotMail is a Perl script which downloads mail messages from a HotMail account and either saves them to disk or forwards them to another email address. It can either be used to transfer all the mail out of an account for backups, or on a regular basis to use a HotMail address as a forwarding account.

2. Useful resources

GotMail has its own home-page at http://ssl.usu.edu/paul/gotmail/)
http://www.hawkins.emu.id.au/gotmail/ (outdated)

Another useful place for information is at http://www.preikschat.com/gotmail.html.

3. Getting the packages

There are some packages that need to be installed before you can get GotMail up and running. First of all, you need to make sure you've got a recent perl-compiler (minimum Perl 5). You can check this with
perl -v
Next, you need to install Curl-SSL version 7.9.8 or later. If there's no current version available for your distribution, you can try by building one from the src-rpm and installing it afterwards.
rpm -ba /usr/src/redhat/SPECS/curl.spec
rpm -ivh /usr/src/redhat/RPMS/i386/curl-* --nodeps
The last thing you need is the URI-CSPAN-module (an extra perl-module). This can be downloaded from http://www.cpan.org/authors/id/G/GA/GAAS/

Untar this package and move it to the newly created directory
tar zxvf URI-1.12.tar.gz
cd URI-1.2
Now, install this module.
perl Makefile.PL
make
make test
make install

4. Install

First step is to download the latest version. http://ssl.usu.edu/paul/gotmail/gotmail_0.7.0.tar.gz. I prefer downloading and install this into /usr/local/src/. Untar this package and move to the newly created directory
zxvf gotmail_0.6.5-1.tar.gz
cd gotmail
That's all for the installation. There's no other configure or make involved.

If you don't want to install the source, you can always download either the RPM of the Debian package.

If you use Gentoo then a simple 'emerge gotmail' will do the trick. This will install two packages, dev-perl/libnet and net-mail/gotmail.

5. Configuration

The easiest way, in my humble opinion, is to place all directives in one script and start everything from a cron-job.

I'll give you an example of my script.
 /usr/local/src/gotmail/gotmail.pl
   -u myhotmail
   -p pasword
   --proxy proxy.myisp.com:8080
   --folders "Inbox"
   -f johndoe
   --only-new-messages
   --mark-messages-as-read
The first line speaks for itself, it just starts the Perl-script.
The - u directive tells GotMail which Hotmail-account it should use and according to this, with - p you can send your password.
Beware! When you're running this from a script make sure the script file that contains your settings (and your hotmail-password) is NOT world-readable!
For better perfomance, you could use a proxy-server with --proxy. This is done with
--proxy hostname:port
With --folders you can specify which folders need to be accessed. Seperate the different folders with a colon , for example like
--folders "Inbox, Special_Stuff, Spam_Mail
When you want to forward the mail to another mail-account you can do this with -f. Either you specify a full mail-address (johndoe@bigcompany.com) or just a local account (make sure your mail-configuration is accepting messages and the provided e-mailaddress is correct, otherwise there could arise some bumping around).
-f johndoe (localaccount)
-f johndoe@company.com (external account)
If instead of delivering them to a local account you'd like them to be saved in a directory, you can do this with --folder-directory as in
--folder-directory /home/johndoe/GotMail/tmp/
With the directive --only-new-messages you tell GotMail to collect only the new messages (this makes sense doesn't it?).
After reading the message GotMail can mark the message as read with --mark-messages-as-read
You can delete the downloaded (and ONLY the downloaded) messages with --delete-messages.


A last word that concerns the configuration is a possible error-output with some versions of Perl. When you receive output like this :
main::getPage() called too early to check prototype at /usr/local/src/gotmail/gotmail.pl line 432.
main::getFolder() called too early to check prototype at /usr/local/src/gotmail/gotmail.pl line 643.
To avoid these messages, open the Perl-script itself, gotmail.pl and remove the - w from the first line.

One final note, take a look further down the page for some security issues if you're on a multi-user system (even if you're not it's not a bad practice).

6. CronJob

I first ran this script from /etc/crontab but for some reason this gave back some errors from the curl-library. When I tried it from the command-line (logged in as root) everything worked fine. I suspected the PATH had something to do with this. Either you can change the PATH-variable in your /etc/crontab, you supply the right PATH in your gotmail-script or you just make a seperate file in /etc/cron.hourly. I prefer the seperate-file-way because when you change the PATH variable in /etc/crontab this counts for every job and you'll never know what comes out then (hmmm...as a good sysadmin you should know). Best way to get the correct PATH-variable is to login as root and then issue
echo $PATH
Now in the script that starts GotMail in /etc/cron.hourly you just need to supply the variable
PATH=/usr/bin:/usr/sbin.....................rest of your path
That would be all. Some remarks however:
  • Mail in the Sent Messages or Drafts folders cannot be saved at the moment
  • Mail in the Trash Can will not be downloaded
  • If the page structure of HotMail is changed, this script may stop working. If that happens, annoy the author for a new version

7. Security

The way I've outlined the use of Gotmail, allows other users to view the username and password (either in the process-list or in the script-source). A better way would be to use a file .gotmailrc with read-only permissions (0600, -rw-------) and put all your configuration stuff (username/password) in there.

8. Hotwayd

In stead of using Gotmail for retrieving mail, you can access your Hotmail or Yahoo mailbox 'directly' through the use of Hotwayd. This package is available for download from http://sourceforge.net/projects/hotwayd/.

Hotwayd is in fact an emulation of a POP-server that acts as a gateway between your account and the services of Hotmail or Yahoo.

Extract the package, compile and install it.

Usage is very easy, just create a hotwayd file in /etc/xinetd. and restart xinetd. This is how my hotwayd file looks like :
service hotwayd
{
 disable = no
 type = unlisted
 socket_type = stream
 protocol = tcp
 wait = no
 user = nobody
 groups = yes
 server = /usr/local/sbin/hotwayd
 #server_args = -p http://proxy:8080 -u proxy_user -q proxy_password
 port = 110
}
Copyleft 2002-2007 - cudeso.bewebmaster@cudeso.betop