home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / doc / HOWTO / mini / Offline-Mailing < prev    next >
Text File  |  1997-10-08  |  36KB  |  904 lines

  1.   Linux off-line mailing method (offline mailaddr with 1account)
  2.   Gunther Voet, gunther.voet@ibm.net - Belgium (CompuMed/TuCSRV)
  3.   v1.3.1, Mon 15 sept 1997 (CET)
  4.  
  5.   Use your linux mailing system offline, receive mail for multiple users
  6.   with only one email address, and without being 24-24 online on the
  7.   net.  If you are unable to pay a direct line to stay online for 24-24
  8.   and still want your users to receive mail on your linux box; as well
  9.   not pay for a multi-drop box at your isp, you can use this system
  10.   using only one email address to divide to your users email addresses.
  11.   It is as well 24-24 reachable since the server where your account
  12.   resists will receive the mail.  ``This howto is Copyright (c)1997 by
  13.   Gunther Voet.''
  14.  
  15.   1.  Notes by the author (preface).
  16.  
  17.   In this chapter i'm just going to put myself safe for any damages and
  18.   flames - since even *I* could be wrong ... If you got any questions or
  19.   suggestions to add to this faq, even if you find any faults - there is
  20.   a feedback section in it ...
  21.  
  22.   Some "need to know" point is, all filenames & files/types are
  23.   indicated with the line:
  24.  
  25.        (*** < file > *** text ***)     .procmailrc
  26.  
  27.   This means, this is a file, called ".procmailrc" containing text. The
  28.   text variable can also be code. It shows you what name of file to use.
  29.   Without a path means it can be variable/choosen by you (in the most
  30.   cases this files resists in the homedirectory of the mail"user" like
  31.   /home/mailer).
  32.  
  33.   1.1.  Legal stuff
  34.  
  35.   Neither the author nor the distributors of this HOWTO are in any way
  36.   responsible for physical, financial, moral damage incurred by
  37.   following the suggestions and examples of this text. The information
  38.   in this document contains the best of my knowledge and experience, but
  39.   i could still make any mistakes as well in the information as in the
  40.   examples. Any trademarks are property of their respective holders (i
  41.   ain't using any commercial thingy's here - but well - IF i'm going to
  42.   add some text, i don't need to change this disclaimer). If your cat
  43.   dies 'coz this document was too heavy - i am not responsible as well
  44.   ...
  45.  
  46.   1.2.  Copyrights
  47.  
  48.   This document and contents are Copyright (c)1997 by Gunther Voet.
  49.   Unauthorized (re)production in any form is explicitly allowed and even
  50.   strongly encouraged as long you don't change the contents of it
  51.   without contacting the author (Gunther Voet). If you quote the
  52.   document as whole or a part of it, there needs to be a Copyright
  53.   "hint" or link to the derived work. "The HOWTO documents are
  54.   copyrighted by their respective authors". The "HOWTO copyright" will
  55.   discuss what can be done and what cannot be done with this document.
  56.   If it is used in a commercial way, the author should been noticed for
  57.   such distributions. Exceptions on this copyright may be granted under
  58.   certain conditions with a written letter or e-mail to the author. For
  59.   more info about the standard HOWTO disclaimer, please contact
  60.   gregh@sunsite.unc.edu.
  61.  
  62.   *PLEASE* *IF* you are going to make a system based on this HOWTO, then
  63.   PLEASE give me the copyright :) heh ... - i am not that cruel :)). I
  64.   mean by a system "a package" - NOT the mailsystem itself - altough it
  65.   is some appreciative thingy i would be included :)) i can always use
  66.   one email address more for more flaming :)) (just kiddin').
  67.  
  68.   1.3.  Feedback
  69.  
  70.   Well, i expect from you and the users who read this HOWTO, they will
  71.   make this HOWTO useful. If you got any suggestions, corrections,
  72.   comments (except flame-mail :)) - please send them to me at
  73.   freaker@ibm.net or freaker@tuc.parkside.net.  and i will make the
  74.   corrections, comments or suggestions happen in the next revision. If
  75.   you publish this document on a commercial way, a complimentary copy
  76.   would be appreciated - you can mail me for my postal address. For
  77.   flames - you could send them to me, but they will end at /dev/null ...
  78.   so - don't even mind to waste bandwidth for it !.  Since i can exclude
  79.   some users to receive mail from (explained in this document) (evil
  80.   grin). My alias (name) is freaker btw :)). You can always try
  81.   "freaker@tucsrv.bi" altough, that server CAN be down ...
  82.  
  83.   1.4.  Distribution
  84.  
  85.   The latest revision of this document can been get from:
  86.  
  87.   http://sunsite.unc.edu/pub/Linux/docs/HOWTO/mini/Offline-Mailing
  88.  
  89.   -and-
  90.  
  91.   http://tuc.parkside.net/Offline-Mailing
  92.  
  93.   -and-
  94.  
  95.   (when the server gets back)   http://www.tucsrv.bi/Offline-Mailing
  96.  
  97.   (also checkout http://tuc.parkside.net)
  98.  
  99.   1.5.  Changes
  100.  
  101.    v1.0.0       - Preliminary release, internal testing, we tried it before
  102.                   we gave it out to you :) .. since - it GOT to be usefull
  103.                   and needs to work? rite ? :)
  104.    v1.1.0       - Fixed a lot of errors in the texts, put chapters in it,
  105.                 - fixed some small errors and typo's ...
  106.    v1.2.0       - fixed grammatical errors.
  107.                 - added a "what-are-we-using" chapter.
  108.                 - added Sunsite address.
  109.    v1.3.0       - Added "virtual mail support" for admins
  110.                 - New site and email addresses
  111.                 - Thanks go to ...
  112.    v1.3.1       - Converted to SGML and fixed some minor details.
  113.  
  114.   1.6.  What am i using ?
  115.  
  116.   I'm using Linux 2.0.30, Pentium-166, ATI pci-mach64 card, Accelerated-
  117.   X (Metro) and a connection to my isp (currently ibmnet) via ppp using
  118.   a ZyXEL 28k8 modem, and occasionally a Bausch 28k8.
  119.   1.7.  Thanks go out to ...
  120.  
  121.   ╖  Fred, durban.hebel.net (for allowing the pages & bot)
  122.  
  123.   ╖  Lifesaver, parkside.net (for allowing the new pages, helping with
  124.      this faq for mailing, since, it is all working overthere and here
  125.      ... make some visit to his cyber-cafe ... heard they got great
  126.      coffee :))
  127.  
  128.   2.  Preliminaries
  129.  
  130.   Well, how does this system works ? what can you do with it ? what is
  131.   it anyway ? and ... am i used to read it ? ... to all those questions
  132.   - there is an answer ...
  133.  
  134.   2.1.  Preface & Description
  135.  
  136.   This HOWTO is dedicated to all the off-line linux users/servers ...
  137.   You got a group, or organization, and you want all your members to
  138.   have a contact (email) address, without paying for the 24/24 direct
  139.   line or for the email accounts ... Or you got a internal network -
  140.   with a masq'd server and you want to give all the users using it a
  141.   email address, you could use this way to do it. I personally am using
  142.   it to give my users & members of a demogroup all a e-mail account
  143.   without being 24/24 online; since it is a non-commercial demogroup -
  144.   and we don't got THAT much money to pay a direct line with instant
  145.   email access - and different ip's. Everybody got a email address, even
  146.   when they don't got internet access. The ones with internet access can
  147.   receive their mail on their personal email address - viavia the system
  148.   described below. Your users can still send mail as they used to do,
  149.   since - your system will hold the mail queue from the users. The only
  150.   thing what should be changed for the users - is that they add their
  151.   "email address" wether (described below) it is the method with the
  152.   subject line, or with the header "to" ...
  153.  
  154.   2.2.  Points of interest ...
  155.  
  156.   ╖  A organization with members, for all a email address, so they can
  157.      be contacted when neccesary.
  158.  
  159.   ╖  A anonymous mailservice - they can't read your "mail setup file" -
  160.      so they don't know where the mail is forwarded/rerouted to.
  161.  
  162.   ╖  A group who doesn't got enuf money (don't laugh), or is free, and
  163.      don't WANT to spend money for it (eheh) - and still wants to
  164.      provide the members a email address.
  165.  
  166.   ╖  A masq'd network - with a server connected to the internet, where
  167.      the users using the masq'd network need to have a email account
  168.  
  169.   ╖  You want to put some documents "autoreplied" - like i do with my
  170.      HOWTO, statistics, or documents ... like "info@yourmail.dom" or
  171.      "document1@yourmail.dom".
  172.  
  173.   ╖  You only need one account at the "main" server to fetch from, for
  174.      the +200 email accounts you can create at your server ...
  175.  
  176.   ╖  I used the "B" method with +- 300 email accounts - with a public
  177.      server; 80486DX4-100 - and was processed in 1 minute.
  178.  
  179.   2.3.  Things you should know
  180.  
  181.   ╖  Not every (free) mailservice is happy when you are going to
  182.      distribute mail to other users, or putting up an anonymous mail
  183.      server, so, please try to contact your mailserver administrator
  184.      before "just doing it".
  185.  
  186.   ╖  It is slower than a direct 24/24 connection, since your server will
  187.      need to get online before it will process the mail.
  188.  
  189.   ╖  It needs a administrative force to administrate the "mailrouting"
  190.      and to add the user ... you will need work with it ! - it is not
  191.      that automatic.  (well - i made it "semi-automatic" with my server
  192.      :) you could try it as well).
  193.  
  194.   ╖  Bandwidth and space is needed when you got many users - on the
  195.      mailserver you are working on ... and sure - when they send files -
  196.      you need to have enough space on it !.
  197.  
  198.   ╖  All mail will be transferred into "one step" - so - the last mail
  199.      received on your server will be last sent to the recipient. "first
  200.      in - first out".
  201.  
  202.   ╖  In the first method (to:) there is no prob with the usernames - but
  203.      in the second "cheaper" method - users can't put in a subject line,
  204.      since that one will be used to send the mail to the recipient. Many
  205.      users forget to use the "subject" ... - or they will need to know
  206.      it clearly.
  207.  
  208.   ╖  If you poll enough for your mail, (for example 4 times a day) - the
  209.      mail will be sure be delivered to as from a recipient the least
  210.      every 6hrs. So the processing will go a little smoother.
  211.  
  212.   ╖  you CAN use it as a "online" mail server as well :) since it will
  213.      poll for it's mail for every XX minutes. but - when you are online
  214.      - why using another server ? and not asking your own domain for
  215.      your own server ?  (dough).
  216.  
  217.   2.4.  there are 2 different ways ...
  218.  
  219.   1. method 'A' - now called "(m(A))".
  220.  
  221.      The "mailsystem" will look to the header, and will see to the "to:"
  222.      line.  This is the best way, since it are "real email addresses".
  223.      You will need another account on some server *AND* you need a DNS
  224.      (MX) entry (your own domain for instance). If the system
  225.      administrator wants to help you with that, then there will be no
  226.      problem !. The system administrator will need to reroute ALL mail
  227.      sent to your (MX) maildomain -> to your account !.  This will take
  228.      some time for him to do it :) so be really nice to him :)) Thanks
  229.      to my system administrator (Fred) i got my maildomain and the user-
  230.      services of my "free" demogroup. It can be a DNS entry costs
  231.      something, what you will need to consider to take it or not.
  232.  
  233.   2. method 'B' - now called "(m(B))".
  234.  
  235.      The "mailsystem" looks to the subject line, and will forward to the
  236.      user indicated into the subject line. If the user is not found, it
  237.      will bounce a mail back. This will need a pop server with only one
  238.      useraccount, and don't need your own DNS or you don't need to be
  239.      nice to your system- administrator who arranges you the mail
  240.      address :). You can use a public mailserver, as well your own
  241.      mailserver or a private one. You can even sacrifice your own email
  242.      address for it :). I used this approach as first what worked for me
  243.      for over a year now ... I know this is sloppy, but, i ain't telling
  244.      you need to use this way, so don't shoot ME - since i'm only
  245.      offering you some solutions to your mail problems :) - you could
  246.      use method A what isn't that sloppy !
  247.  
  248.   3.  Requirements
  249.  
  250.   Well, you need (of'course) a Linux machine, what can be connected to
  251.   the internet - So! (i am smart - i am smart :)) - you probably got a
  252.   modem, right?  a phoneline - or any way to connect yourself with the
  253.   server you are running.  You will also need some software like
  254.   Fetchmail, Procmail, an extra account, and your email account or DNS
  255.   with email account.
  256.  
  257.   3.1.  A linux machine
  258.  
  259.   This can be ANYthing ... even a 8086 ... - but preferable - since
  260.   there will be some load on it - minimally a 80386 :). as faster the
  261.   machine - as faster the software will run (rite eh)? :).
  262.  
  263.   3.2.  A extra account at your linux machine
  264.  
  265.   You need to create a extra account on your Linux machine. I am using
  266.   as example (in this HOWTO) "mailservice". This can be as well
  267.   "mailserver" or "mailtousers" - as long it is some name what can be
  268.   recognized by you!.
  269.  
  270.   ! It doesn't need to have ANY root privileges !
  271.  
  272.   This mailaccount will forward all mail to the users on your system, or
  273.   to external users (not on your system :)). Just create it as an
  274.   ordinary user.  You will need to test things under this account, and,
  275.   the mail "administrator" can use this account to administrate the mail
  276.   account without being root even .. so - pretty safe !.
  277.  
  278.   3.3.  Fetchmail
  279.  
  280.   I am using v1.9 patch level 9 ... i found it at sunsite.unc.edu, and,
  281.   i am using only this mail-fetcher in my example - if you want to use
  282.   another one, you are on your own ! since i am happy with it :). For
  283.   extended features you should read the man of Fetchmail :). This can be
  284.   installed as root - as well for the user itself ... - best is to
  285.   install it as root :) since i know it will work for sure then :)))
  286.  
  287.   3.4.  Procmail
  288.  
  289.   I am using v3.10 - found it again at sunsite.unc.edu, and - i like
  290.   this as the best mda (mail delivery agent) around ... It delivers
  291.   nicely - and it is better than using it by the "original" system mda -
  292.   since it will deliver user-per-user ! ... The same as above - it can
  293.   be installed as root, or as user - and :) best is to install it as
  294.   root - since i know it will work for sure then (again!) :)... how
  295.   repetetive ...
  296.  
  297.   3.5.  A mail account
  298.  
  299.   You always need to have a mail account - where you can "poll" your
  300.   mail from.  The server needs to be a POP server - where you can poll
  301.   from when you want, and where users can send their mail 24/24 to. It
  302.   can be a free-mail service, as well commercial - even your mailaccount
  303.   is sufficient enough. In the "subject" method (m(B)) - you don't need
  304.   something more - in method A - with the "to" fields - you NEED more -
  305.   as written below !
  306.  
  307.   3.5.1.  A DNS record (MX)
  308.  
  309.   Needed to run your own "domain" - email domain ... it is needed since
  310.   the administrator of the server can't use it's own domain for your
  311.   users - since there are users who need to be contacted on his server
  312.   as well - what could interfere with your users. And your mailheader
  313.   must be filtered on that domain. So - an apart domain - pointing to
  314.   HIS server. This can be an additional cost - or you can ask your
  315.   system administrator to add a "non- authorative address" - pointing to
  316.   his server ... - however - it needs to be another domain than he is
  317.   using !
  318.  
  319.   3.5.2.  A "forward" to your account-account :)
  320.  
  321.   Well, the system administrator needs to forward *ALL* mail to your
  322.   domain to YOUR account ... - it is easy for him when he knows how to
  323.   do it :) ..  else he will need to read the sendmail manual :)) (or
  324.   qmail - whatever).  You will poll for your mail at your account and
  325.   voila ! filtering on YOUR own email domain.
  326.  
  327.   4.  I got it all, what now ?
  328.  
  329.   Now you created the extra account, you got the mail address - and/or
  330.   the DNS entry & forwarding to your account ... As well installed
  331.   Procmail & Fetchmail, we can rock the place ! :) .. here we go !
  332.  
  333.   1. You need to create a .fetchmailrc file, what will contain the
  334.      "delivery" info to your users.
  335.  
  336.   2. You need to create a "nosuchuserfile" - so the writer knows his
  337.      mail isn't delivered well.
  338.  
  339.   3. For best work :) you could use crontab to check for mail. This is a
  340.      easy way to check your mail every XX minutes when on the internet.
  341.  
  342.   4.1.  Creating a .fetchmailrc file
  343.  
  344.   You will need to create a .fetchmailrc file, what will contain the
  345.   information (username & password, as well the Mail Delivery Agent
  346.   (mda) to proces the mail to). Here is some example file ...
  347.  
  348.        (*** < file > *** text ***)     .fetchmailrc
  349.  
  350.   ______________________________________________________________________
  351.   server my.mail.server.com
  352.   proto pop3
  353.   user myaccountthere
  354.   pass deepestsecrets
  355.   flush
  356.   mda /usr/bin/procmail
  357.   ______________________________________________________________________
  358.  
  359.   This file will be used to fetch your mail. Please test it by using the
  360.   fetchmail program "fetchmail -vv" - and see your mail is being
  361.   transferred right ... There will be some errors - since the procmail
  362.   control file hasn't been created yet. You can wait by testing AFTER
  363.   making the procmailrc file, but - i'll warn ya - IF there is something
  364.   fault :) it CAN be this file :) It needs to be owned by the user
  365.   account itself - in my case "mailservice" and needs to be "user
  366.   readable" but NOT group/world readable - since it contains the "main
  367.   password" :)). (chmod 600 .fetchmailrc will do).
  368.  
  369.   4.2.  Creating a .procmailrc file
  370.  
  371.   This control file will forward all mail to the users in it. There are
  372.   2 ways as described before - the "to:" (header) way - and the
  373.   "subject" (sloppy) way.  The file will contain the usernames to
  374.   transport to. All the "#" are comments and are absolutely not needed
  375.   when not wanted - it's only so you know what i am doing ... - you can
  376.   as well best chmod it 600 - so the rest of the world or group doesn't
  377.   need those private addresses eh :) ... It needs also to be owned by
  378.   the user (like "mailservice") :)). The "nosuchuserfile" is a "bounce"
  379.   to the writer - if the user isn't found (so mail not delivered) in the
  380.   procmailrc file ... - so the writer knows the mail isn't delivered
  381.   well.
  382.  
  383.   4.2.1.  For "header (to:)" transportation
  384.  
  385.        (*** < file > *** text ***)     .procmailrc
  386.  
  387.   ______________________________________________________________________
  388.   # this line is for debugging purposes only ! it should be removed for
  389.   # ethical purposes - since you can read all mail passed trough your mail-
  390.   # server ... - all mail will be copied to the file "passtrough" before
  391.   # going to the users ... herein you can look what went wrong ...
  392.   :0 c
  393.           passtrough
  394.  
  395.   # the mail with header "to: freaker@mydom.com" will be forwarded directly
  396.   # to me, the other mail will pass this option ...
  397.   :0
  398.   * ^To:.*freaker@mydom.com
  399.   ! freaker
  400.  
  401.   # the mail to root@mydom.com will be forwarded to root ... as well postmaster!
  402.   :0
  403.   * ^To:.*root@mydom.com
  404.   ! root
  405.  
  406.   :0
  407.   * ^To:.*postmaster@mydom.com
  408.   ! postmaster
  409.  
  410.   # the mail to barbara@mydom.com will be forwarded to barbara AND will be
  411.   # forwarded to her private email address !
  412.  
  413.   :0 c
  414.   * ^To:.*barbara@mydom.com
  415.   ! barbara@her.private.one
  416.  
  417.   :0
  418.   * ^To:.*barbara@mydom.com
  419.   ! barbara
  420.  
  421.   # this lines will BOUNCE the mail to the sender - when it is not delivered to
  422.   # one of above users ... it will send the file "nosuchuser" into the mail
  423.   # body as reply ... be aware ! you need to make such file ! - mine contains
  424.   # "well, the user you wanted to reach does not exist on this server, please
  425.   # try again, it could be the user is not present anymore".
  426.   #
  427.   :0
  428.     |(/usr/bin/formail -r -k \
  429.        -A"X-loop: mailservice@mydomain.dom "| \
  430.          /usr/bin/gawk '{print }\
  431.          /^/ && !HEADER \
  432.            { system("/bin/cat nosuchuser"); \
  433.            print"--" ;\
  434.            HEADER=1 }' ) |\
  435.            /usr/bin/sendmail -t
  436.  
  437.   exit
  438.   ______________________________________________________________________
  439.  
  440.   4.2.2.  For "subject: touser" transportation
  441.  
  442.        (*** < file > *** text ***)     .procmailrc
  443.  
  444.        ______________________________________________________________________
  445.        # this line is for debugging purposes only ! it should be removed for
  446.        # ethical purposes - since you can read all mail passed trough your mail-
  447.        # server ... - all mail will be copied to the file "passtrough" before
  448.        # going to the users ... herein you can look what went wrong ...
  449.        :0 c
  450.                passtrough
  451.  
  452.        # the mail with header "to: freaker@ibm.net" will be forwarded directly
  453.        # to me, the other mail will pass this option ... When you got a "dedicated"
  454.        # email address to receive your "mailservice thingy's" on - you don't need
  455.        # to use this line :)
  456.        :0
  457.        * ^To:.*freaker@ibm.net
  458.        ! freaker
  459.  
  460.        # all mail with as subject "root" will be forwarded to root !
  461.        :0
  462.        * ^Subject:.root
  463.        ! root
  464.  
  465.        # all mail to "subject: barbara" will be forwarded to barbara ...
  466.        :0
  467.        * ^Subject:.barbara
  468.        ! barbara
  469.  
  470.        # all mail to "subject: paul" will be forwarded to his external email addr.
  471.        :0
  472.        * ^Subject:.paul
  473.        ! paul@his.personal.emailaddress
  474.  
  475.        # all mail to "subject: john" will be forwarded to his account at your server
  476.        # and a copy will go to his private email address ...
  477.        :0 c
  478.        * ^Subject:.john
  479.        ! john@his.personal.emailaddress
  480.  
  481.        :0
  482.        * ^Subject:.john
  483.        ! john
  484.  
  485.        # All the mail from ibm, with their updates and information, will go to
  486.        # freaker, as he is the one who will administrate the mailservice, and
  487.        # as ibm doesn't want to get the bounce putten below !! ... this is
  488.        # neccesary if your mail provider sends "newsletters" etc...
  489.        :0
  490.        * ^From:.*newsletter@ibm.net
  491.        ! freaker
  492.  
  493.        # All messages from the daemon should been thrown away, or in my case, will
  494.        # be saved to a file ... (use /dev/null to throw to endless pits of The Abyss)
  495.        :0
  496.        * ^FROM_DAEMON
  497.        throwaway
  498.  
  499.        # this lines will BOUNCE the mail to the sender - when it is not delivered to
  500.        # one of above users ... it will send the file "nosuchuser" into the mail
  501.        # body as reply ... be aware ! you need to make such file ! - mine contains
  502.        # some text like "user not found in subject line, please use "Subject: user"
  503.        # to write a mail to the user, like example "subject: freaker" would send a
  504.        # mail to freaker." The file can be long, but also small :) ... the
  505.        # "mailservice@mydomain.dom" will prevent to loop between your server and
  506.        # the other server - it needs to have the EXACT email address used !.
  507.        # Else you could create an endless loop with a server what sends mail
  508.        # to "your email address" with as subject something like "don't spend 500$
  509.        # at your ..." etc...
  510.   :0
  511.     |(/usr/bin/formail -r -k \
  512.        -A"X-loop: mailservice@mydomain.dom "| \
  513.          /usr/bin/gawk '{print }\
  514.          /^/ && !HEADER \
  515.            { system("/bin/cat nosuchuser"); \
  516.            print"--" ;\
  517.            HEADER=1 }' ) |\
  518.            /usr/bin/sendmail -t
  519.  
  520.   exit
  521.   ______________________________________________________________________
  522.  
  523.   4.3.  nosuchuserfile"
  524.  
  525.        (*** < file > *** text ***)     nosuchuser
  526.  
  527.        ______________________________________________________________________
  528.  
  529.        The user you wanted to contact is not present at this system.
  530.  
  531.        Please use the subject line as recipient - example "subject: freaker" would
  532.        send mail to freaker on this system.
  533.        ______________________________________________________________________
  534.  
  535.   4.4.  crontab files".
  536.  
  537.   If you don't know how crontab works :) better read the manual :) ...
  538.   You need to create a "checkmail" file - what will see if the link is
  539.   up, as well the cronfile itself ... - i am using a ppp link :) so -
  540.   this is an example how to look when the ppp link is up - and to poll
  541.   every 10 minutes using cron. Looks sloppy - but isn't !.
  542.  
  543.   4.4.1.  checkformail
  544.  
  545.   the .checkformail file will be called (needs to be executable as well)
  546.   - and will look if the ppp link is up. If it is up - then it will
  547.   fetch for mail.  Crontab will use this file when you are using the
  548.   below cronentry ...
  549.  
  550.        (*** < file > *** code ***)     .checkformail
  551.  
  552.   ______________________________________________________________________
  553.   #!/bin/sh
  554.   #
  555.  
  556.           cd /home/mailservice
  557.  
  558.           if [ -f /var/run/ppp0.pid ]; then
  559.           /usr/local/bin/fetchmail -s > /dev/null 2>&1
  560.   fi
  561.   ______________________________________________________________________
  562.  
  563.   4.4.2.  crontab
  564.  
  565.   This cronentry file needs to been loaded into crontab, and will call
  566.   the .checkformail - every 10 minutes. It won't write any mail or give
  567.   any info to the console - since i'm redirecting everything to null.
  568.  
  569.        (*** < file > *** text ***)     cronentry
  570.  
  571.        ______________________________________________________________________
  572.        0,10,20,30,40,50 * * * *  /home/mailservice/.checkformail 1> /dev/null 2> /dev/null
  573.        ______________________________________________________________________
  574.  
  575.   4.5.  At the admins site".
  576.  
  577.   Well, this should be done when using the "A method" ... at the admin's
  578.   site, so the email goes all from a complete domain, to one username.
  579.   It is pretty simple, and once you've done it - it works like hell.
  580.   this is NOT neccesary if your system administrator (the uplink) got
  581.   another method, and is NOT neccesary at YOUR side !!!!
  582.  
  583.   4.5.1.  add some lines to sendmail.cf
  584.  
  585.   add the following lines to your /etc/sendmail.cf file, so the domains
  586.   file will be read.  please be noted that the "ruleset 98" is added as
  587.   underhere, since - once you got errors :) it's a hell to find 'm out !
  588.   (and i can know it :) DuH).
  589.  
  590.        (*** < file > *** add ***)    /etc/sendmail.cf
  591.  
  592.   ______________________________________________________________________
  593.   # Database of handled domains
  594.  
  595.   Kmaildomains btree /etc/maildomains.db
  596.  
  597.   # Add these lines *IN* Ruleset 98 ! (under Ruleset 98).
  598.  
  599.   R$+ < @ $+  . >         $: $1 < @ $2 > .
  600.   R$+ < @ $+ > $*         $: $(maildomains $1@$2 $: $1 < @ $2 > $3 $)
  601.   R$+ < @ $+ > $*         $: $(maildomains $2 $: $1 < # $2 > $3 $)
  602.   R$+ < @ $* > .          $: $1 < @ $2 . >
  603.   ______________________________________________________________________
  604.  
  605.   4.5.2.  creating a /etc/maildomains file ...
  606.  
  607.   First create a /etc/maildomains file, what will be used to "send" a
  608.   domain to a specific user ... here is an example ... (as you already
  609.   knew, the name "mailservice" can be anything you want - it can even be
  610.   your loginname (like mine is freaker).
  611.  
  612.        (*** < file > *** text ***)     /etc/maildomains
  613.  
  614.        ______________________________________________________________________
  615.        mydomain.dom            mailservice
  616.        ______________________________________________________________________
  617.  
  618.   4.5.3.  let it work !
  619.  
  620.   now you'll need to generate the btree (database) files. do the
  621.   following:
  622.  
  623.   cd /etc
  624.   makemap btree maildomains < maildomains
  625.  
  626.   after that, kill the sendmail daemon, and restart it. it should now
  627.   WORK!  good luck :)
  628.  
  629.   5.  Automation
  630.  
  631.   Well, now, everything above works ... (if it doesn't work - don't even
  632.   think about automation before it WILL work ... - now - we need some
  633.   script so it isn't a pain in the ass for the "mailadministrator" or
  634.   the root user to add users to the procmailrc file ... The below
  635.   example will be for "more experienced users" - since some things NEED
  636.   to be changed as well ... - it is an example with the "B method -
  637.   Subject lines". It can be easily adapted to the "A method". Since the
  638.   "B method" will be more used (cheaper) than the "A" method - i decided
  639.   to use the "B method" ... Am i sounding repetitive or not ? .. well -
  640.   i meant to write it in this way :)) to bug you :)))..
  641.  
  642.   5.1.  The "skeletion".
  643.  
  644.   Since the footer needs to be as footer (everything below won't be
  645.   processed since we are bouncing there); there needs to be a header and
  646.   a footer file.
  647.  
  648.   5.1.1.  the ".procmailrc-header" file
  649.  
  650.   This file will now be the "header & user" file .. since here will
  651.   users been added and removed - it will be a important file ... - best
  652.   take a backup from it each time you add a user ... - there COULD be
  653.   something wrong sometime ..  A system can fail ...
  654.  
  655.        (*** < file > *** text ***)    .fetchmailrc-header
  656.  
  657.        ______________________________________________________________________
  658.        :0 c
  659.                passtrough
  660.  
  661.        :0
  662.        * ^To:.*freaker@ibm.net
  663.        ! freaker
  664.  
  665.        :0
  666.        * ^Subject:.root
  667.        ! root
  668.  
  669.        :0
  670.        * ^Subject:.barbara
  671.        ! barbara
  672.  
  673.        :0
  674.        * ^Subject:.paul
  675.        ! paul@his.personal.emailaddress
  676.  
  677.        :0 c
  678.        * ^Subject:.john
  679.        ! john@his.personal.emailaddress
  680.  
  681.        :0
  682.        * ^Subject:.john
  683.        ! john
  684.  
  685.        :0
  686.        * ^From:.*newsletter@ibm.net
  687.        ! freaker
  688.  
  689.        :0
  690.        * ^FROM_DAEMON
  691.        throwaway
  692.        ______________________________________________________________________
  693.  
  694.   5.1.2.  the .procmailrc-footer file ..
  695.  
  696.   As mentioned above, this file needs to be as footer - since all data
  697.   BELOW it won't be used to deliver - this footer contains the "bounce"
  698.   code to bounce the users not found *ABOVE* the footer !. it is the
  699.   ABSOLUTE end of the file !
  700.  
  701.        (*** < file > *** text ***)     .fetchmailrc-footer
  702.  
  703.        ______________________________________________________________________
  704.  
  705.        :0
  706.          |(/usr/bin/formail -r -k \
  707.             -A"X-loop: mailservice@mydomain.dom "| \
  708.               /usr/bin/gawk '{print }\
  709.               /^/ && !HEADER \
  710.                 { system("/bin/cat nosuchuser"); \
  711.                 print"--" ;\
  712.                 HEADER=1 }' ) |\
  713.                 /usr/bin/sendmail -t
  714.  
  715.        exit
  716.        ______________________________________________________________________
  717.  
  718.   5.2.  addmail script
  719.  
  720.   This script will add a user to the header file, attach the header &
  721.   footer to eachother - so it will be a complete .procmailrc file. the
  722.   "#" (comments) are not really needed - and are for your info :).
  723.  
  724.        (*** < file > *** code ***)     addmail   (* chmod 500 *)
  725.  
  726.   ______________________________________________________________________
  727.   #/bin/sh
  728.   #
  729.   # Copyright (c)1997 by Gunther Voet. rev 1.0
  730.   # please leave the Copyright in it when it is distributed with any
  731.   # system using this thingy ...
  732.  
  733.   echo ""
  734.   echo "Addmail v1.0 by Gunther Voet, Freaker / TuC'97 (21/04/97)"
  735.   echo ""
  736.  
  737.   if [ $1 ]; then
  738.  
  739.           if [ $2 ]; then
  740.  
  741.   # make a backup file !
  742.  
  743.           cp /home/mailserv/.procmailrc-header /home/mailserv/.procmailrc-backup
  744.  
  745.   # APPEND (>>) the information to the header file ...
  746.  
  747.           echo ":0" >> /home/mailserv/.procmailrc-header
  748.           echo "* ^Subject:.$1" >> /home/mailserv/.procmailrc-header
  749.           echo "! $2" >> /home/mailserv/.procmailrc-header
  750.           echo "" >> /home/mailserv/.procmailrc-header
  751.  
  752.   # copy the header file to .procmailrc - and append the footer file to it !
  753.  
  754.           cat /home/mailserv/.procmailrc-header > /home/mailserv/.procmailrc
  755.           cat /home/mailserv/.procmailrc-footer >> /home/mailserv/.procmailrc
  756.  
  757.   # make sure it is owned by "mailserv" and the read/write priveleges are ONLY
  758.   # for the user "mailserv" itself ...
  759.  
  760.           chown mailserv /home/mailserv/.procmailrc
  761.           chgrp users /home/mailserv/.procmailrc
  762.           chmod 600 /home/mailserv/.procmailrc
  763.   else
  764.           echo "No DESTINATION mail address has been given ..."
  765.   fi
  766.  
  767.   else
  768.           echo "usage:"
  769.           echo ""
  770.           echo "syntax:  addmail from_user to_user(domain)"
  771.           echo ""
  772.           echo "example: addmail freaker freaker@myemail.dom"
  773.           echo ""
  774.   fi
  775.   ______________________________________________________________________
  776.  
  777.   Now, this script will append the information of the user, as well the
  778.   email address to the header file, it will copy it to the .procmailrc
  779.   file, and will add the footer to it, so you got a complete .procmailrc
  780.   to process the mail.  If you want to delete a user- just edit the
  781.   .procmailrc-header file, and at the next user added it will be deleted
  782.   at the .procmailrc. To do a instant delete, just delete the user from
  783.   both the files .procmailrc & .procmailrc- header.
  784.  
  785.   6.  Help! (sigh)
  786.  
  787.   Well, you need help - isn't :) ... hmm .. i could be sarcastic and
  788.   just say "you could better do it again, 'coz it looks a messy enuf" -
  789.   or .. i could help ... - I wrote down some common problems - IF you
  790.   got any problem NOT listed in this HOWTO (section) - then mail me -
  791.   and i'll put it in this howto even with your name/email addr in it :).
  792.   **BEFORE** mailing to me - please look if you didn't forgot anything -
  793.   and IF you want some help from me - send me the MOST DETAILED
  794.   information - included the scripts & things you needed.  i DON'T need
  795.   any binaries - since i won't run them.
  796.  
  797.   6.1.  The automation script just doesn't work:
  798.  
  799.   ╖  is it executable ?
  800.  
  801.   ╖  is your (default shell) located at /bin/sh ?
  802.  
  803.   6.2.  What do you mean by "anonymous mailserver"?
  804.  
  805.   ╖  Well, you could make accounts like "anon0001@yourdom.dom" - and
  806.      forward it to another email address ... nobody needs to read the
  807.      .procmailrc file, so YOU ONLY know the address !.
  808.  
  809.   6.3.  My cat died
  810.  
  811.   ╖  Well, next time don't print this HOWTO out on 200 gram papers,
  812.      since it are 10 pages it would be 2KG for the cat - it is JUST TOO
  813.      HEAVY !
  814.  
  815.   6.4.  My dog died
  816.  
  817.   ╖  hmm - can't do anything about that one - why askin' me ? ...  Just
  818.      bury it ....
  819.  
  820.   6.5.  Linux?
  821.  
  822.   ╖  A free-unix - posix compatible - made by Linus Torvalds ... Why are
  823.      you reading this if you even don't know what Linux is ?
  824.  
  825.   6.6.  Can you help me with finding a mail account?
  826.  
  827.   ╖  No! - this is a howto for YOUR side, i don't care about the side of
  828.      your isp, nor how to get your email address.
  829.  
  830.   6.7.  Why is the "maybe later i'll make some addition ..." removed ?
  831.  
  832.   ╖  Read point 5.5 very carefully :) and you'll see why .. it's 'coz i
  833.      needed to add it on general request :)
  834.  
  835.   6.8.  How do i get a "domain" ?
  836.  
  837.   ╖  Ask your local ISP/provider - he will help you with it. It could
  838.      take days/ even weeks when asking to the Internic - your provider
  839.      can help.
  840.  
  841.   6.9.  Why are you so f*cking lame using this?
  842.  
  843.   ╖  ┤coz i don't want to spend money - and - 'coz i feel like being
  844.      f*cking lame USING it - i *AM* using it - so why bother?
  845.  
  846.   6.10.  Nosuchuserfile?
  847.  
  848.   ╖  You can put in it what you want - as long you put some "needed"
  849.      info so the original writer knows what happened with his "never
  850.      delivered" mail.
  851.  
  852.   6.11.  Can my users write/send mail too?
  853.  
  854.   ╖  This has nothing to do with the system i explained to you, read the
  855.      sendmail manual ... - this is to RECEIVE mail - to be "always
  856.      available at an email address".
  857.  
  858.   6.12.  Does every user need a shell account at my server?
  859.  
  860.   ╖  Nope .. - but - it will be really hard for users not having
  861.      internet access :) ... You could have a masq'd network - and use a
  862.      computer connected to it - so the users can get their mail that
  863.      way, or you can generate a link between a bulletin board and his
  864.      mail, you could even forward it to a fidonet gate :) ... reasons
  865.      enough not to give a shell!.
  866.  
  867.   6.13.  skeletion?
  868.  
  869.   ╖  i know it is a typo - but - i like this word better.
  870.  
  871.   6.14.  Addmail?
  872.  
  873.   ╖  No questions - for automation - you better be sure about what you
  874.      are going to do ... since - it COULD be a trojan ya know :))) (it
  875.      isn't but what means you need to know what scripting is before
  876.      asking questions) It IS easy enough to interprete - that's even why
  877.      i put the comments with it. *IF* you are going to distribute this
  878.      script - leave my Copyright in it please ! thanks :).
  879.  
  880.   6.15.  Why are you so cruel?
  881.  
  882.   ╖  I am not cruel :) i am nice :) i am the nicest guy of the world, of
  883.      the universe ! NOW SCRAM! (i just want to be complete in my HOWTO,
  884.      and not TOO much "drifting away" from my original point in the doc
  885.      - so :) that's all).
  886.  
  887.   6.16.  Didn't you get a complaint of excessive language ?
  888.  
  889.   ╖  Not yet, but, could be i'm filtering everything containing
  890.      'excessive' and language :) i don't know :))
  891.  
  892.   6.17.  Why is this howto different than most others?
  893.  
  894.   ╖  ┤coz sometimes reading plain howto's CAN be boring ... i wanted to
  895.      add something next to it ...
  896.  
  897.   7.  The End
  898.  
  899.   This sounds like the end ... If you find any unwanted bugs (or
  900.   features :)), then leave some feedback ... any comments & suggestions
  901.   -> mail them :).  if you are still bored after reading this, please go
  902.   to: http://tuc.parkside.net/  hehehe
  903.  
  904.