#!/bin/bash

# disable all disturbing "new mail" announces...
biff n &>/dev/null
mesg n &>/dev/null

# make the connection
route del localnet &>/dev/null
until dip /etc/connect
do
  echo "Can't login."
  echo "Retrying in 3 minutes..."
  sleep 3m
done
sleep 1s
route add -net localnet dev sl0

# transfer sent mail
transfermail

# retrieve new mail
fetchmail -v

# kill the dip process
dip -k

# Kill the line (OK, dip should to that automatically... But I tend to be
# a bit paranoid when it comes down to paying the phone bill...)
echo -e "+++ATH0\n\n" >/dev/cua1
route del localnet
