6 # Fetchsetup is a shell script for creating a .fetchmailrc file, that will be
7 # used by the program "fetchmail" to connect to your mail domain and retrieve
9 # This script is linux specific, so it may not work on another system.
10 # Kent Robotti <krobot@erols.com> (3-31-99)
15 if [ "$(id -ur)" != "0" ]; then
16 echo >&2 "$0: You need to be root [found $(id -un)] to run this script."
17 echo >&2 "You could login as root"
18 echo >&2 "You could also try one of these: # sudo fetchsetup"
19 echo >&2 " # su root -c fetchsetup"
24 echo -n "Continue? (Y/n) : "
26 if [ "$ans" = "n" -o "$ans" = "N" ]; then
31 stty erase "^?" 2>/dev/null
34 echo "Remote mail site?: pop.boo.com <Your service providers mail domain name>"
35 echo -n "Remote mail site?: "
38 echo "Protocol?: pop3 <My service provider uses the 'pop3' mail protocol>"
39 echo "Protocol?: auto <If not sure put: auto>"
40 echo "Choices: apop auto etrn imap imap-gss imap-k4 kpop pop2 pop3 rpop sdps"
44 echo "Remote username?: jerry <My username or login is jerry>"
45 echo -n "Remote username?: "
48 echo "Remote password?: ? <What's the password for?: $USR>"
49 echo -n "Remote password?: "
53 echo -n "Create $HOME/.fetchmailrc file? (Y/n) : "
55 if [ "$ans" = "n" -o "$ans" = "N" ]; then
57 echo "Fetchsetup cancelled."
62 echo 'poll "'$SITE'"' > $HOME/.fetchmailrc
63 echo "protocol $PROTO" >> $HOME/.fetchmailrc
64 echo 'username "'$USR'"' >> $HOME/.fetchmailrc
65 echo 'password "'$PASS'"' >> $HOME/.fetchmailrc
67 PROCMAIL=`type -all procmail | sed -n "1 p" | cut -d' ' -f3`
68 SENDMAIL=`type -all sendmail | sed -n "1 p" | cut -d' ' -f3`
70 if [ ! "$PROCMAIL" = "" ]; then
71 echo 'mda "'$PROCMAIL -d %s'"' >> $HOME/.fetchmailrc
73 elif [ ! "$SENDMAIL" = "" ]; then
74 echo 'mda "'$SENDMAIL %s'"' >> $HOME/.fetchmailrc
80 echo >> $HOME/.fetchmailrc
82 echo "This is your $HOME/.fetchmailrc file."
84 chmod 600 $HOME/.fetchmailrc
87 cat $HOME/.fetchmailrc
89 if [ ! "$MAIL" = "" ]; then
90 echo "Fetchmail will retrieve your mail and put it in:"
92 if [ ! -f "$MAIL" ]; then
93 touch $MAIL 2>/dev/null
94 chmod 600 $MAIL 2>/dev/null
99 if [ "$MDA" = "1" ]; then
100 echo "I put that (m)ail (d)elivery (a)gent in .fetchmailrc"
101 echo "because i found it on your system, this doesn't mean"
102 echo "it's correct or the one you want to use."
104 echo "The first time you run fetchmail, you should run it"
105 echo "this way: # fetchmail -k"
107 elif [ "$MDA" = "2" ]; then
108 echo "You seem to have sendmail, sendmail will be used"
109 echo "as the (m)ail (d)elivery (a)gent for fetchmail."
111 echo "WARNING! There's no way to know if sendmail is set up"
112 echo "properly for local mail delivery, so the first time you"
113 echo "run fetchmail run it this way: # fetchmail -k"
115 echo "If the mail that fetchmail retrieves is not put in your mailbox,"
116 echo "you'll know that sendmail is not set up properly for the delivery"
117 echo "of local mail."
119 elif [ "$MDA" = "3" ]; then
120 echo "I Don't know what (m)ail (d)elivery (a)gent you're going to use."
121 echo "You need a <mda> to deliver the mail to you, after <fetchmail> retrieves it."
123 echo "Put the <mda> in your .fetchmailrc file, like below."
124 echo "password $PASS"
125 echo mda '"/usr/bin/procmail -d %s"'
126 echo mda '"/usr/sbin/sendmail %s"'
128 echo "The first time you run fetchmail, you should run it"
129 echo "this way: # fetchmail -k"