An Off-Line Email System
Even if you can read emails online, it is a very good way to waste your money. What can you do to save money?
There are two programs which allow an off-line work at home. The first is sendmail, the second is popclient.
But before we explore sendmail and popclient we have to edit the file /etc/hosts and to insert one entry for the mail server. If you have created i4l.config and called "makeleaf" this is done already. If you did not do it, you must add:
/etc/hosts (cutting) <IP address> <name_of_mail_server> getmail
/usr/src/sendmail/cf/cf/linux.asyoulike.mc # Bernhard's sendmail.cf include(`../m4/cf.m4')dnl # must be!!! VERSIONID(`asyoulike')dnl # name it as you like OSTYPE(linux)dnl # We're doing Linux! FEATURE(nodns)dnl # No own name server FEATURE(nocanonify)dnl # Don't lookup DNS while sending FEATURE(nouucp)dnl # We don't use UUCP define(SMART_HOST, relay:<provider.name>)dnl # mail to ... define(confCON_EXPENSIVE, True)dnl # distributing mail is expensive MASQUERADE_AS(lrz.uni-muenchen.de)dnl # we act as "provider" define(confUSERDB_SPEC, /etc/userdb.db)dnl # Address correction FEATURE(notsticky)dnl # don't change From: line MAILER(local)dnl # use mailer: MAILER(smtp)dnl # local, Simple Mail Transfer Prot.You just must tell sendmail this now:
root:# m4 linux.asyoulike.mc > /etc/sendmail.cf root:# _Writing emails you have to tell your address so that a "reply" works properly. This means, the From: line in the email header must contain your account name at your provider. This happens because of the line "MASQUERADE_AS ..." in the m4 script, and because of a user database built in there. This database (/etc/userdb.db) also must be prepared, therefore you must create a file containing two lines per user:
/etc/userdb.db <login_at_your_pc>:mailname <provider_login_name> <provider_login_name>:maildrop <login_at_your_pc>It must be changed to a format sendmail can read:
root:# makemap btree /etc/userdb.db < /etc/userdb root:# _(sendmail-FAQ tells that this only works, if you have the Berkeley db package - the S.u.S.E. 4.2 installs it.)
Now you have after a reboot (or after killing sendmail and restarting it with the option "-bd") a working mail slave.
Sendmail is running as daemon in the background. You can tell him to collect all the email you wrote (it will be stored in /var/spool/mqueue or /var/mqueue), and to send it on demand only.
Therefore you must start sendmail while booting as daemon without the "-q ..." option. In simpleinit environment this happens in the last part of the startup script /etc/rc.d/rc.M; if you have sysvinit it is in an extra file (SuSE 4.2: /sbin/init.d/sendmail. Here you must remove this option; "-bd" must remain, because it is the command for sendmail to go into background as daemon.
But there are some mail programs which are something obstinate. Programs like pine or Netscape overwrite the header with some entries, which are not correct.
Jan Berkel <email@example.com> wrote me this hint: You need to edit .muttrc in your home directory and to add the following line:
my_hdr From: firstname.lastname@example.org (Foo Name)With this the header rewriting works.
For Netscape you can edit the file ~/.netscape/preferences. In it you find the line
~/.netscape/preferences (cutting) [...] EMAIL_ADDRESS: <Email@Address> [...]Type in your correct email address.
Tilo Winkler <email@example.com> found out how to manage it that pine does not write garbage into the From: line. You must get the pine source code and edit pine/makefile.lnx: add -DALLOW_CHANGING_FROM at the CFLAGS and recompile. Now you can add the following to .pinerc in your home directory:
customized-hdrs=From: My Name <My@email.address>, Reply-To: My Name <My@email.address>XEmacs
(Thanks, Markus Dickebohm <firstname.lastname@example.org> for sending me these hints!)
You can fake the From: address within XEmacs, if you edit the file ~/.emacs and add the following entries:
(setq user-mail-address "email@example.com") (setq mail-host-address "mail.rrz.uni-koeln.de")This is not ideal, like the mailer programs above: this mailer changes the mailer header.
If you have information about other MUAs (Mail User Agents), please send them to me. Thank you!
~:# popclient -3 -u<host-login> -p<host-password> -o/var/spool/mail/<user> getmail ~:# _getmail is the mailhost defined in /etc/hosts. If you give an additional "-k" as option, the emails at the provider will not be erased.
Hint: In the meantime a powerful child of popclient was born: fetchmail. Sorry, but I'm not familiar with fetchmail until now.
/sbin/transmail #!/bin/sh # transmail.sh: exchanges email with the provider. # Author: Bernhard Hailer <firstname.lastname@example.org> # Version: 4.0 (27-Jan-97) PATH=/sbin:/usr/sbin:/bin:/usr/bin . /etc/i4l.provider . /etc/i4l.secrets cd / # against PATH=. effect echo ----------------------------------------------------------------------- echo -e "Starting mail transfer: \c"; date . /sbin/connect on echo "Checking mail server..." set `ping -qc5 -i1 getmail | grep transmitted` if [ $4 -gt 0 ] then echo ":-) Mail server online - starting mail exchange" echo "Sending mail..." sendmail -q echo "Again sleeping 1 sec for PPP handshaking" sleep 1 echo "Fetching mail..." popclient -3 -u $MAIL_LOGIN -p $MAIL_PASSWD -o $MAIL_PATH getmail echo "Again sleeping 1 sec for PPP handshaking" sleep 1 else echo ":-[ Sorry - mail server is down. Try later..." fi . /sbin/isdn off # allow dl4mhk access to mail: chown dl4mhk.users /var/spool/mail/dl4mhk echo -e "Finished mail transfer: \c"; dateThe sleep commands are important: the connection may hang without them.
1.) modify cron table.
root:# cd ~ root:# cp /var/spool/cron/crontabs/root .crontab root:# _Append the following lines to the file .crontab:
# Transfer mail 30 04 * * * /sbin/transmail.sh 1>> /var/log/transmail-log 2>> /var/log/transmail-log2.) Tell crond these modifications.
crontab .crontabNow the clock in the computer automatically handles all the emails. Each night at 4:30 a.m. the mails are fetched and sent. Remark: Of course the system time must be set properly - man date; man clock.
You need to calculate what's more expensive: telephone or electricity. Electricity is expensive. But I use this system because it is so comfortable...