home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1997 December / Internet_Info_CD-ROM_Walnut_Creek_December_1997.iso / faqs / comp / answers / mail / addressing < prev    next >
Encoding:
Internet Message Format  |  1997-10-24  |  49.4 KB

  1. Path: senator-bedfellow.mit.edu!bloom-beacon.mit.edu!eecs-usenet-02.mit.edu!news.kei.com!nntprelay.mathworks.com!howland.erols.net!feed1.news.erols.com!News.NetUSA.Net!eli!not-for-mail
  2. From: pogo@qz.little-neck.ny.us (Eli Pogonatus)
  3. Newsgroups: comp.mail.misc,news.admin.net-abuse.email,news.software.readers,comp.answers,news.answers
  4. Subject: Email Addressing FAQ (How to use user+box@host addresses)
  5. Supersedes: <eli$9710061443@qz.little-neck.ny.us>
  6. Followup-To: comp.mail.misc
  7. Date: 23 Oct 1997 19:45:04 GMT
  8. Organization: Some absurd concept
  9. Lines: 1192
  10. Approved: news-answers-request@MIT.EDU
  11. Message-ID: <eli$9710231532@qz.little-neck.ny.us>
  12. NNTP-Posting-Host: alpha.netusa.net
  13. X-Trace: news.netusa.net 877635904 1727 (None) 204.141.0.10
  14. X-Complaints-To: News@NetUSA.Net
  15. Summary: How to add and use submailboxes to your email address.
  16. Xref: senator-bedfellow.mit.edu comp.mail.misc:42190 news.admin.net-abuse.email:104694 news.software.readers:47145 comp.answers:28650 news.answers:115240
  17.  
  18. Archive-name: mail/addressing
  19. Last-modified: (06/10/97 14:32:39)
  20. URL: http://www.netusa.net/~eli/faqs/addressing.html
  21. Reason-for-last-modification: MMDF updated, Pine updated
  22. Reason-for-previous-modification: Added mention of zsh where appropriate,
  23.         fixed qmail compile option
  24.  
  25.    If you can add information PLEASE DO. This is Unix centric because I
  26.    have answers for Unix, not because I am trying to shun other
  27.    platforms.
  28.    
  29. Questions covered
  30.                                  __________
  31.    
  32.     1. What?
  33.     2. Why?
  34.     3. Things to consider
  35.     4. With qmail, how?
  36.     5. With sendmail, how?
  37.     6. With MMDF, how?
  38.     7. With other MTAs, how?
  39.     8. With mutt, how?
  40.     9. With elm, how?
  41.    10. Using them in trn, how?
  42.    11. Using them in slrn, how?
  43.    12. Using them in tin, how?
  44.    13. Using them in nn, how?
  45.    14. Using them in Gnus, how?
  46.    15. Using them in knews, how?
  47.    16. Using them in MH, how?
  48.    17. Using them in pine, how?
  49.    18. Using them elsewhere, how?
  50.    19. Any other addressing suggestions?
  51.        
  52.      * Appendix
  53.          1. General format of a From: header
  54.          2. Filtering
  55.          3. A word on address types
  56.          4. Comprehensive plan for a new account
  57.          5. Verifying Email Addresses
  58.        
  59.    A good many of the examples in this FAQ are for a generic user, Alice,
  60.    who receives mail at bobs-home.com. Her "login" at that host is
  61.    "alice" and she uses boxes called "mail" and "news" in the localpart
  62.    of her address. (The word "localpart" comes from RFC 822 which defines
  63.    the now standard internet email address. It refers to the portion of
  64.    the email address before the "@".) Bobs-home.com uses sendmail, and
  65.    the examples reflect that.
  66.    
  67.    I find this a slightly more interesting way of giving examples than
  68.    the crude "localpart@fully.qualified.domain.name" and
  69.    "localpart@hostname.tld" that earlier versions of this FAQ used.
  70.    
  71. Questions and answers:
  72.                                  __________
  73.    
  74.     1. What?
  75.        
  76.        Mail transfer agents (MTAs) usually deliver mail to a single
  77.        location for each user on the system. There are ways of having
  78.        mail sent to more than one email address being delivered to the
  79.        same user. The simplest conceptually is a mail alias. Aliases
  80.        affect the whole machine and generally can only be set up by
  81.        administrators. This is not convenient for anyone involved. So
  82.        some MTAs have special ways of creating user level aliases. To
  83.        keep these from interfering with other aspects of mail on the
  84.        machine, these addresses are the username with a piece of
  85.        punctuation and a boxname appended.
  86.                               ___________________
  87.        
  88.     2. Why?
  89.        
  90.        Traditionally it has been useful for special sorting of mail, eg
  91.        casanova+anna@love.org, casanova+beth@love.org,
  92.        casanova+cathy@love.org, etc. so that each of Anna, Beth, and
  93.        Cathy send mail to a particular address and it gets treated
  94.        specially. These days it is becoming popular as a way of providing
  95.        special filtering (such as with procmail) on email addresses
  96.        exposed to insecure channels such as Usenet.
  97.        
  98.        Nancy McGough's Filtering Mail FAQ, available at the URLs below,
  99.        is a good start to finding out how to filter once you have the use
  100.        of these addresses. See also the appendix of this FAQ.
  101.        
  102.         FAQ "launchers" for the Filtering Mail FAQ:
  103.                 
  104.                o
  105.                  http://www.ii.com/internet/faqs/launchers/mail/filtering-
  106.                  faq/ 
  107.                o http://www.best.com/~ii/faqs/archive/mail/filtering-faq/
  108.                  
  109.         FTP sites for the Filtering Mail FAQ:
  110.                 
  111.                o
  112.                  ftp://rtfm.mit.edu/pub/usenet/news.answers/mail/filtering
  113.                  -faq (and at the rtfm mirror sites)
  114.                o ftp://ftp.netusa.net/users/eli/mail.filtering-faq.txt
  115.                  (not strongly recommended)
  116.                               ___________________
  117.        
  118.     3. Things to consider
  119.        
  120.        For these to be useful you really must have several things working
  121.        together. Some of these things require system administrator
  122.        privileges to implement, if they are not working on your system
  123.        already, some do not. Some programs are as easy to configure as
  124.        adding a line by hand to the headers shown, others require
  125.        patching the code and recompiling. Hopefully the patches will
  126.        become part of the official distributions, when needed, to prevent
  127.        too much duplication of effort.
  128.        
  129.        Of primary importance, your system will need a mail transfer agent
  130.        (MTA) that can understand these addresses when there is an attempt
  131.        to give them to the system. Installing the MTA is definitely a
  132.        task for a system administrator. In some cases, configuring the
  133.        MTA will be as well.
  134.        
  135.        As a secondary, but not much less important, concern you will need
  136.        to be able to configure the various user-level mail handing
  137.        programs to use these aliases. There has not been a lot of
  138.        interest in these in the past, so very few programs make it easy
  139.        to do. The interest in filtering spam sent to addresses culled
  140.        from Usenet has made configuring news posters my primary concern
  141.        for this. I would like to add Q&As for mail user agents (MUAs),
  142.        those programs that generally act as a user interface to mail, but
  143.        I do not have a strong familiarity with any myself.
  144.        
  145.        As a last concern, you will want to know how to filter and sort
  146.        mail for maximum effectiveness. The appendix currently has that
  147.        information. Stephen R. van den Berg's procmail utility, available
  148.        in source form at
  149.        <URL:ftp://ftp.informatik.rwth-aachen.de/pub/packages/procmail/>,
  150.        is probably the best tool around. I found it difficult to learn
  151.        without lots of well-documented examples, so I have tried to
  152.        provide examples here.
  153.                               ___________________
  154.        
  155.     4. With qmail, how?
  156.        
  157.        Qmail is an MTA.
  158.        
  159.        Dave Sill <de5@sws5.ctd.ornl.gov> told me that with qmail all
  160.        Alice has to do is "touch ~/.qmail-news" to indicate that she
  161.        wants to receive mail at <alice-news@bobs-home.com>. Or she can
  162.        put the name of a mailbox in the file and mail will be delivered
  163.        there. If she doesn't have the .qmail-news file mail will normally
  164.        be bounced. She can also use a .qmail-default file to catch any
  165.        other case.
  166.        
  167.        If her .qmail is a single line consisting of just "#" all her mail
  168.        will silently be dropped. This might be a useful way to force
  169.        people to only send mail to her sub-boxes. She should be sure to
  170.        have files specified for her other mail, however. Since silently
  171.        discarding mail is the same as getting it and not responding (to
  172.        an outside observer), arranging to have the mail bounce might be
  173.        more useful. She could put a single line consisting of "| exit
  174.        100" there which will send a bland bounce message in the typical
  175.        qmail fashion.
  176.        
  177.        This is a user level configuration; it creates boxes of the form
  178.        <alias-boxname@bobs-home.com>.
  179.        
  180.        (At qmail compile time you can change the '-' delimiter to any
  181.        character you wish. Version 1.00, change the value of
  182.        USEREXT_BREAK in conf-unusual.h. Version 1.01, change the file
  183.        "conf-break". Both require a recompile to take effect. This may
  184.        seem trivial, but '-' is a legitimate character in a Unix username
  185.        and I have seen it used.)
  186.                               ___________________
  187.        
  188.     5. With sendmail, how?
  189.        
  190.        Sendmail is an MTA.
  191.        
  192.        Phil Edwards <pedwards@cs.wright.edu> talked about how to do it
  193.        with sendmail. Quoting him, because it doesn't paraphrase well,
  194.        "The usual setup is in ruleset 5, consisting of a couple lines
  195.        like
  196.  
  197.  
  198.         R$+ + *         $#local $@ $&h $: $1
  199.         R$+ + $*        $#local $@ $2 $: $1 + *
  200.  
  201.    with another one or two later on in the same ruleset. (I'm doing this
  202.        from memory; it'll probably differ from your .cf.) From there,
  203.        it's up to your local delivery program." He suggests using
  204.        procmail as the local delivery program; refer to the procmail
  205.        installation instructions for (a little) more information.
  206.        
  207.        This is an admin level configuration; it creates boxes of the form
  208.        <alias+boxname@bobs-home.com>. Once sendmail is configured, usage
  209.        of the mailboxes is user controlled. Recent releases of sendmail
  210.        come with this working already. (You can try to send yourself mail
  211.        at login+boxname to see if this is already set up on your system.
  212.        If not, you'll need to contact your system administrator.)
  213.                               ___________________
  214.        
  215.     6. With MMDF, how?
  216.        
  217.        MMDF is an MTA.
  218.        
  219.        Jerry Sweet, maintainer of the MMDF FAQ, has provided this
  220.        detailed answer.
  221.        
  222.      MMDF has long had an addressing feature of the form
  223.      "mailbox=string", which causes a message so addressed to be
  224.      delivered to "mailbox". The whole address, including the "=string"
  225.      part, appears in the $(address) variable for use in your
  226.      .maildelivery file.
  227.      
  228.      An application note on how to use MMDF's "=" addressing feature to
  229.      pre-sort incoming mail is available at this URL:
  230.      
  231.      http://www.irvine.com/~mmdf/auto-sort/index.html
  232.      
  233.      Note that MMDF doesn't preserve the "=string" information for use
  234.      following delivery, so all handling of the $(address) information
  235.      must take place at delivery time, using the .maildelivery file. So,
  236.      in order to take advantage of MMDF's "=" addressing feature, you
  237.      must use local delivery as opposed to POP delivery. (In other
  238.      words, you need a login account on the same host that runs MMDF.)
  239.      
  240.      For detailed information about using the "=" feature in one's
  241.      $HOME/.maildelivery file, refer to the MMDF maildelivery(5) on-line
  242.      man page.
  243.        
  244.        This is a user level configuration; it creates boxes of the the
  245.        form <alias=boxname@bobs-home.com>.
  246.                               ___________________
  247.        
  248.     7. With other MTAs, how?
  249.        
  250.        Nobody responded with smail, exim, etc solutions.
  251.        
  252.        If you are using the Andrew Messaging System (AMS), which you
  253.        probably are if you have any other Andrew stuff on your system,
  254.        then you have all of this already. In fact AMS introduced the
  255.        concept. Read the documentation on FLAMES to find out how to use
  256.        this.
  257.                               ___________________
  258.        
  259.     8. With mutt, how?
  260.        
  261.        Mutt is a MUA.
  262.        
  263.        To change the from header, Alice in her .muttrc defines additional
  264.        lines with the command "my_hdr":
  265.        
  266.  
  267. my_hdr From: alice+mail@bobs-home.com (Alice)
  268.  
  269.        To just change the Reply-to: header, she can use:
  270.        
  271.  
  272. my_hdr Reply-To: alice+mail@bobs-home.com (Alice)
  273.                               ___________________
  274.        
  275.     9. With elm, how?
  276.        
  277.        Elm is a MUA.
  278.        
  279.        Elm stores extra headers to be used in mail in a .elm/elmheaders
  280.        file in her home directory. She just needs to add a From: and/or
  281.        Reply-To: header in that file and it will be used automatically.
  282.        The headers should be properly formatted for mail. The appendix
  283.        has sample formats acceptable for a from line.
  284.                               ___________________
  285.        
  286.    10. Using them in trn, how?
  287.        
  288.        Trn is a newsreader.
  289.        
  290.        Trn uses two environment variables, NEWSHEADER and MAILHEADER, to
  291.        control the headers that appear in posts and replies respectively.
  292.        For the default values Alice can read the man page for her copy of
  293.        trn. In the comprehensive plan for a new account there is a sample
  294.        configuration for trn. Suffice to say that she can add a from
  295.        header herself with those variables, or she can add one by hand
  296.        every time she sends mail or news. (I use a combination approach
  297.        myself.)
  298.        
  299.        Note that newer versions of trn can be controlled by a user level
  300.        configuration file to do this stuff, so she doesn't need to
  301.        clutter the environment. The documentation should cover this.
  302.                               ___________________
  303.        
  304.    11. Using them in slrn, how?
  305.        
  306.        Slrn is a newsreader.
  307.        
  308.        Alice can add to her .slrnrc:
  309.  
  310. username "alice-news"
  311.  
  312.    With newer versions of slrn, she can set them per-group with the
  313.        article_mode_hook in the .slrn.sl file.
  314.                               ___________________
  315.        
  316.    12. Using them in tin, how?
  317.        
  318.        Tin is a newsreader.
  319.        
  320.        Some versions of tin use the USER environment variable to generate
  321.        the local part of the email address. Here are two aliases
  322.        resetting it just while using tin:
  323.        
  324.         csh or tcsh
  325.                 alias tin "env USER=alice+news tin"
  326.                 
  327.         ksh, bash, or zsh
  328.                 alias tin="env USER=alice+news tin"
  329.                 
  330.        If you already have a tin alias, it will not be used. Both aliases
  331.        will still allow you to give arguments to tin normally.
  332.        
  333.        Apparently there are some versions of the "unofficial" tin
  334.        floating about that would allow her to set a "forged" address from
  335.        the menu of configuration options. These are probably not too
  336.        commonly installed.
  337.                               ___________________
  338.        
  339.    13. Using them in nn, how?
  340.        
  341.        Nn is a newsreader.
  342.        
  343.        As in trn, Alice can add the from line by hand while posting or
  344.        configure nn to add them all the time. To get the latter, she
  345.        would add this to her .nn/init file:
  346.        
  347.  
  348. set news-header From: Alice <alice+news@bobs-home.com>
  349.  
  350.        She should be careful using semicolons (;) in it, unless escaped
  351.        they separate lines. The appendix has sample formats acceptable
  352.        for a from line. There is a mail-header setting for replies which
  353.        works the same way. In an over-zealous interpretation of RFC 1036,
  354.        nn will add a sender header to her posts with her un-boxed
  355.        address. I don't know any way around this. Using my inews may
  356.        work, but I have not tried.
  357.                               ___________________
  358.        
  359.    14. Using them in Gnus, how?
  360.        
  361.        Gnus is a newsreader and MUA.
  362.        
  363.        To change them in news she adds to her .gnus:
  364.  
  365. (setq message-default-news-headers
  366.       "From: Alice <alice+news@bobs-home.com>\n")
  367.  
  368.    For news and mail she can change message-default-headers instead. The
  369.        appendix describes the consideration for a From: header.
  370.        
  371.        If she would also use Gnus to read and filter your mail, she can
  372.        add an entry like the following to nnmail-split-fancy:
  373.  
  374.  
  375. ("to" "alice\\+news"
  376.   (| ("subject" "re:.*" "misc")
  377.      ("references" ".*@.*" "misc")
  378.      "spam"))
  379.  
  380.        This says that all mail to this address is suspect, but if it has
  381.        a Subject that starts with a Re: or has a References header, it's
  382.        probably ok, and will be put in the "misc" group. All the rest
  383.        goes to the "spam" group. This combines filters I use with those
  384.        used by Tim Pierce.
  385.        
  386.        This will sort virtually everything into the right group. She
  387.        still must check the "spam" group from time to time to check for
  388.        legitimate mail, though.
  389.        
  390.        See the Info documentation for nnmail-split-fancy for details and
  391.        variations.
  392.        
  393.        Mark T. Gray offers this further advice:
  394.        
  395.      Also gnus rather unfortunately will insert a Sender: line if it
  396.      finds that the From: line has a different username than it thinks
  397.      it should. To correct this put the following function redefinition
  398.      in your .gnus file:
  399.        
  400.  
  401. (defun message-make-sender ()
  402.   "Return the \"real\" user address.
  403. This replaces the function in message.el which tries to ignore all
  404. user modifications, and give as trustworthy answer as possible."
  405.   (cadr (mail-extract-address-components (message-fetch-field "from"))))
  406.  
  407.        It basically will return the same name as you stuck in her From:
  408.        field above and gnus is then happy to leave out the Sender: line.
  409.        Era Eriksson points out that this behavior is a configurable
  410.        option of Gnus:
  411.  
  412.  
  413. (nconc message-syntax-checks '((sender . disabled)) )
  414.  
  415.      This will preserve any existing overrides for message-syntax-checks
  416.      by merely adding (sender . disabled) to the end of any preset
  417.      values. If the variable is already being set e.g. in your site-wide
  418.      initialization files, you should still be able to use this without
  419.      clobbering anything.
  420.        
  421.        Another very useful function to put in her .gnus is the following
  422.        hook which will query the user for the alias to add on the
  423.        username whenever she sends a message:
  424.  
  425.  
  426. (defun my-address-choice ()
  427.   "This function chooses which alias-suffix to use"
  428.   (interactive)
  429.   (let ((alias-suffix (read-string "Which alias-suffix: ")) (alias))
  430.     (setq alias
  431.            (concat user-login-name "+" alias-suffix "@bobs-home.com")
  432.           mail-default-reply-to alias
  433.           user-mail-address     alias)
  434.     (message "%s" alias)))
  435.  
  436. (add-hook 'message-header-setup-hook 'my-address-choice)
  437.  
  438.        One person I have corresponded with is uncertain that will work
  439.        and believes it to be of dubious value anyway. Caveat emptor. All
  440.        of this question was written with Gnus 5.x in mind. I don't know
  441.        how much will apply to earlier versions.
  442.                               ___________________
  443.        
  444.    15. Using them in knews, how?
  445.        
  446.        Knews is a newsreader.
  447.        
  448.        David Kennedy says that to use these, Alice needs to put a line in
  449.        the Knews file like:
  450.        
  451.  
  452. Knews.mailName:         alice+news
  453.  
  454.        He also offers the warning "knews = executable, Knews = config
  455.        file." David was using version 0.9.8 when he offered the advice.
  456.                               ___________________
  457.        
  458.    16. Using them in MH, how?
  459.        
  460.        Answer submitted by Philip Guenther. I had thought that MH was an
  461.        MTA/MUA, but apparently it has a news section or I am confused.
  462.        
  463.        If you already have a components file for comp(1), then you just
  464.        need to add a Reply-To: or From: line to it. Be aware that if you
  465.        add a From: line then a Sender: line with your plain address will
  466.        be added by post(8), so your plain address will appear somewhere
  467.        in the message.
  468.        
  469.        If you don't already have a components file then create on in your
  470.        MH mail directory (probably $HOME/Mail), that contains:
  471.        
  472.  
  473. To:
  474. Cc:
  475. Subject:
  476. --------
  477.  
  478.        then follow the previous directions. In order for replies and
  479.        forwards to have the additional header you'll need to create or
  480.        edit replcomp and forwcomp file, and then tell repl and forw to
  481.        use them by editing your .mh_profile to include lines like:
  482.        
  483.  
  484. repl: -form replcomp
  485. forw: -from forwcomp
  486.  
  487.        For the default entries for those file check the repl and forw
  488.        manpages.
  489.                               ___________________
  490.        
  491.    17. Using them in pine, how?
  492.        
  493.        Pine is a MUA and newsreader.
  494.        
  495.        Pine tries to protect users from details and folly/ignorance, so
  496.        it is not easy. It requires editing the source code and
  497.        recompiling. If you feel up to it, here's how to do it.
  498.        
  499.        Edit the file pine/osdep/os-xxx.h of the source where xxx is the
  500.        3-letter abbreviation for your platform. Uncomment out the section
  501.        which applies to "ALLOW_CHANGING_FROM". Compile. Run it. Go to the
  502.        pine configuration control/menu and add an entry in
  503.        "customized-hdrs" for your new From: header. The appendix has
  504.        sample formats acceptable for a from line.
  505.        
  506.        Nancy McGough has a good web page on this that goes into more
  507.        detail. See it at either
  508.        <URL:http://www.ii.com/internet/messaging/pine/changing_from/> or
  509.        at
  510.        <URL:http://www.best.com/~ii/internet/messaging/pine/changing_from
  511.        />.
  512.                               ___________________
  513.        
  514.    18. Using them elsewhere, how?
  515.        
  516.        Well, if Alices uses sendmail directly to send mail (as I often
  517.        do) it is pretty obvious how. Otherwise, I am not sure. Netscape
  518.        and other programs which ask her to provide her own address will
  519.        doubtlessly accept these addresses readily.
  520.        
  521.        If she uses a program which has inews inject news into an NNTP
  522.        server, you might find the mini inews that I have hacked up
  523.        useful. It works like inews with programs that use it in one of
  524.        these forms:
  525.        
  526.           + inews -h < file (new inews)
  527.           + inews < file (old inews)
  528.           + inews -h file (new inews)
  529.           + inews file (old inews)
  530.        Anything that counts on command line options working is going to
  531.        be disappointed. Older versions of lynx and all versions of rn,
  532.        trn and nn that I know use inews in this fashion.
  533.        
  534.        This mini inews is from nn by way of lynx and has a number of
  535.        hacks and bug fixes by me. Of primary concern is that it is now
  536.        influenced by a NEWSMAILBOX environment variable when generating
  537.        the From: header. If you would like to use it, the source is kept
  538.        at ftp://ftp.netusa.net/users/eli/mini-inews.tgz in a tar/gzip
  539.        file.
  540.        
  541.        Alice would use one of these two set ups with this:
  542.          A. In her .login or her shell rc file (.cshrc or .tcshrc) for
  543.             csh or tcsh she would have:
  544.             setenv NEWSMAILBOX +news
  545.          B. For sh/ksh/bash/zsh she would have this in her .profile:
  546.             NEWSMAILBOX=+news
  547.             export NEWSMAILBOX
  548.                               ___________________
  549.        
  550.    19. Any other addressing suggestions?
  551.        
  552.        RFC822 is a long and complex document for those without strong
  553.        computer science backgrounds. Parts of it will be understandable
  554.        to most who read it, parts will not. Among other things it
  555.        specifies how email addresses can be formatted. News and SMTP mail
  556.        use RFC822 addresses. If she changes her address to one that is
  557.        equivalent but written differently, she may be able to use
  558.        procmail or another filtering tool process them.
  559.        
  560.        In particular the case sensitivity (upper vs. lower) of the
  561.        localpart (that which comes before the @ reading left to right) is
  562.        at the option of the destination machine. So if her MTA is (most
  563.        are) case insensitive for those addresses, she can change the case
  564.        of her name and all other mailers should preserve that
  565.        capitalization change. Humans typing the name tend not to be.
  566.        
  567.        Many mailers will preserve any "comments" included in an email
  568.        address. RFC822 defines a comment:
  569.  
  570.  
  571. comment     =  "(" *(ctext / quoted-pair / comment) ")"
  572. ctext       =  <any CHAR excluding "(", ")", "\" & CR, & including
  573.                 linear-white-space>
  574. quoted-pair =  "\" CHAR                     ; may quote any char
  575. linear-white-space =  1*([CRLF] LWSP-char)  ; semantics = SPACE
  576.                                             ; CRLF => folding
  577.  
  578.         CHAR
  579.                 7-bit character
  580.                 
  581.         LWSP
  582.                 linear whitespace: TAB and SPACE
  583.                 
  584.         CR
  585.                 carriage return, an ASCII control character
  586.                 
  587.         LF
  588.                 line feed, an ASCII control character
  589.                 
  590.        This is not very legible to the typical human. What it means is a
  591.        comment may contain any character, but some -- "(" ")" "\" CR --
  592.        must be "backslash escaped". That just means put a backslash (it
  593.        is "\" and not "/") in front of characters whose special meanings
  594.        that need to be escaped.
  595.        
  596.        Mostly. There is also that bit that comments may contain other
  597.        comments; this will preclude using regular expressions to match
  598.        addresses. Basically this translates to mean that your parentheses
  599.        must match in the normal manner or else should be backslash
  600.        escaped. So some valid comments are
  601.  
  602.  
  603. (hi-ya @lice here)
  604.  
  605. (This is //-\\lice)
  606.  
  607. (Let's (recurse (and (again (and (again (and (I'm (bored (now))))))))))
  608.  
  609. (\) whee)
  610.  
  611.    And some invalid comments would be
  612.  
  613. (\/\/\/\/\)
  614.  
  615. ()ops)
  616.  
  617. (Spiff()
  618.  
  619.    Now, if that were not ugly enough, RFC822 says that there can be
  620.        whitespace or comments by any delimiter. The delimiters are
  621.        
  622.           ( ) < > @ , ; : \ " . [ ]
  623.        
  624.        So the following are all legal and equivalent addresses for me:
  625.  
  626. < eli @ netusa . net >
  627.  
  628. <eli(jah)@netusa.net>
  629.  
  630. < eli(Elijah)@netusa(not associated with usa.net).net >
  631.  
  632. (Elijah) <eli@(dougs-home)netusa.net>
  633.  
  634. < eli @ (the raw IP for mail (and thus subject to change)) [204.141.0.25] >
  635.  
  636. < eli @ (a subtler variation on the above) [204.141.25] >
  637.  
  638. <eli (Pogonatus (latin for <the bearded>))@ (qz (pronounced (queasy) ) \
  639.  .little-neck (I did not want that, but RFC1480 required it) .ny (New \
  640.  F%@!: York) .us (USA) or ) netusa (Located on Long Island) . net> (Elijah)
  641.  
  642.    Alice will find that a lot of mailers are not RFC822 compliant by
  643.        trying some of those out, especially that last one. Most mailers
  644.        seem happy to accept and preserve addresses like the second one
  645.        from the top, so that may be a good way for Alice to modify her
  646.        address for filtering purposes. "Preserve" does not mean that the
  647.        comment will be in the same place, just that it will be included.
  648.        
  649.        The URL (uniform resource locator) mailto: scheme employs an
  650.        "RFC822 addr-spec" address in the scheme specific part. According
  651.        to my reading of the relevant RFCs, this means you can use
  652.        comments in mailto: addresses, but the "%", "+", and whitespace
  653.        characters should be "percent escaped". This escaping works by
  654.        having a % followed by the hexadecimal value of the character so
  655.        
  656.         %
  657.                 => %25
  658.                 
  659.         +
  660.                 => %2b
  661.                 
  662.         <space>
  663.                 => %20
  664.                 
  665.        Note that the "<" and ">" address delimiters should not be used in
  666.        a URL. The URL format itself precludes the need for them.
  667.        
  668.        Other people disagree with my reading of the RFCs on this issue.
  669.        They think comments are not allowed at all in the mailto: scheme.
  670.        And it is true that some of the more obscure web browsers
  671.        incorrectly percent escape parentheses, thus destroying the
  672.        address. I think all versions of Netscape, Explorer, Mosaic, and
  673.        Lynx get it right, but use with caution.
  674.                     ___________________________________
  675.    
  676. Appendix
  677.                                  __________
  678.    
  679.    General format of a From: header
  680.    
  681.    Here are the three generally accepted formats for a From: line. These
  682.    are actually just special cases of RFC 822 addresses appearing after
  683.    the string "From: ". RFC 1036 specifies that only one of these
  684.    variations should be used for news. I have tried other variations in
  685.    mail and seen weird things happen when people with combined mail and
  686.    news readers try to reply.
  687.  
  688.  
  689. From: alice+news@bobs-home.com (Alice)
  690. From: Alice <alice+news@bobs-home.com>
  691. From: alice+news@bobs-home.com
  692.  
  693.    localpart will be your username+box; the fully qualified domain name
  694.    is the full name of a machine you receive mail at; the name field has
  695.    whatever "full name" you want to use. See the other suggestions
  696.    question for more information on RFC 822 addresses.
  697.                                  __________
  698.    
  699.    Filtering
  700.    
  701.    Well, now that Alice has a means of marking addresses for different
  702.    handling, it is entirely reasonable that she might want some advice on
  703.    how to use the marks effectively. Nancy McGough's Filtering Mail FAQ
  704.    referenced earlier in this FAQ is a good place to start learning about
  705.    filtering tools. I am going to provide some advice here for what to
  706.    filter with. I have a filtering resource page that gives information
  707.    on the filters I use, including a link to an annotated version of my
  708.    procmailrc. The page is at
  709.    <URL:http://www.netusa.net/~eli/filtering.html>
  710.    
  711.    I have found it very effective to give addresses exposed to Usenet in
  712.    the form of a From: or Reply-To: line the most stringent filtering. I
  713.    use procmail to handle my filtering, and this is the exact recipe I
  714.    have for it (my Usenet posts go out from
  715.    <usenet-tag@qz.little-neck.ny.us>):
  716.  
  717.  
  718.         :0:
  719.         * ^TOusenet-tag@qz
  720.         * !^Subject:(.Re:|(.*[[({ -](was|Re):))
  721.         IN.junk
  722.  
  723.    IN.junk is a mbox file I check occasionally for false positives. Maybe
  724.    1-3% of it is false positives, often very easily distinguishable from
  725.    the other stuff by the subject line.
  726.    
  727.    For those unfamilar with regular expressions (REs), that recipe is
  728.    probably not very clear. Unfortunately REs are quite complicated and
  729.    beyond the scope of this document. Jeffrey Friedl has written a good
  730.    book about them, Mastering Regular Expressions published by O'Reilly
  731.    and Associates. Many other sources cover them in less detail. Check
  732.    your documentation for grep or egrep in particular. Be aware that most
  733.    egreps today are much more sophisticated than the one procmail claims
  734.    to be compatible with.
  735.    
  736.    In English, here's what that does. All mail sent to an address
  737.    containing the phrase "usenet-tag@qz" which gets delivered to me will
  738.    be tested for compliance with the second rule. The second rule says
  739.    any of that mail which does not have a subject which begins with "Re:"
  740.    or have a subject which anywhere in it contains a "[", "(", "{", " "
  741.    or "-" followed immediately by a "was:" or "Re:" is put into the junk
  742.    pile. The first part of the subject rule matches regular replies to
  743.    posts and so they do not get junked. The second part recognizes the
  744.    standard Usenet convention for changing a subject line, which is to
  745.    put the new subject in front and then leave the old one there
  746.    (sometimes parenthetically) after the word "was:".
  747.    
  748.    The types of mail this messes up on are those where someone takes the
  749.    time to note the address, and uses it to send new mail later. This
  750.    happens very infrequently in my experience. Tim Pierce and others have
  751.    advocated checking for headers left in by newsreaders when filtering
  752.    mail for Usenet addresses. This is subject to the same problem as my
  753.    technique, but is additionally dependent on people not replying from
  754.    copies found in DejaNews or Altavista and on relying upon newsreaders
  755.    to add headers not specified in any standards document. That second
  756.    bit makes it much too unreliable, in my opinion.
  757.    
  758.    A note about that recipe: My username is not "usenet" and that is not
  759.    a submailbox for me. With sendmail (at least how I had it configured,
  760.    YMMV with legacy sendmail.cf files) sub-boxing works just the same.
  761.    Other MTAs might not work that way: the box name may get canonicalized
  762.    out of the header. Mailers are not supposed to rewrite these headers,
  763.    but it happens all the time. In any case, Philip Guenther
  764.    <guenther@gac.edu> wrote on the procmail mailing list (to join, send
  765.    subscription requests to
  766.    <procmail-request@Informatik.RWTH-Aachen.DE>):
  767.    
  768.  
  769. Michael Ghens <michael@spconnect.com> writes:
  770. >I missed it, how does the + addressing get passed in
  771. >
  772. >as in michael+pgp@spconnect.com
  773.  
  774.  
  775. It shows up as $1 in your procmail, which you can then test with
  776. something like:
  777.  
  778.         ARG = $1
  779.  
  780.         :0
  781.         * ARG ?? ^^pgp^^
  782.         pgp-folder
  783.  
  784.         :0
  785.         * ARG ?? ^^cypher-punks^^
  786.         cypher-punks-folder
  787.  
  788.  
  789. You can't test $1 directly, thus the assignment to ARG.
  790.  
  791.    ^^ is a weird procmail-specific regexp anchor. ^ and $ work just as
  792.    well for what we want. (Gory details: ^ and $ match zero width
  793.    conditions near line ends, while ^^ matches zero width conditions near
  794.    string ends, much like \A and \Z in perl.) The main advantage of that
  795.    recipe is $1 is set to the correct subbox even for Bcc'ed stuff when
  796.    procmail is used as the local delivery agent from sendmail. (For
  797.    certain sendmail.cf configurations at least.)
  798.    
  799.    One can AND test together in a procmail recipe in a number of ways.
  800.    Including a number of separate * tests is one way, but it does not
  801.    allow if-then-else type structures easily. For those { ... } grouping
  802.    can be used. Here is an example for a submailbox named "news"
  803.    employing my subject rule.
  804.    
  805.  
  806.         ARG=$1
  807.  
  808.         # Rules to apply to Usenet responses.
  809.         :0
  810.         * ARG ?? ^news$
  811.         {
  812.           # Where to send stuff missing Re: or was: in the subject
  813.           :0:
  814.           * !^Subject:(.Re:|(.*[[({ -](was|Re):))
  815.           IN.junk
  816.  
  817.           # Where to send the rest of it.
  818.           :0:
  819.           IN.good
  820.         }
  821.                            _____________________
  822.    
  823.    A word on address types
  824.    
  825.    In the simple mail transport protocol (SMTP) there are two types of
  826.    sender address and two types of recipient address. This can be used
  827.    for all sorts of obfuscation, and often is. The types are,
  828.    respectively, the envelope addresses and the header addresses.
  829.    
  830.    Within the protocol, the difference between the two is that envelope
  831.    addresses are specified with protocol commands and header addresses
  832.    are specified as part of the mail data. There need not be any
  833.    correlation between a From: or To: in the headers and those from the
  834.    envelope. Most mailer delivery agents add a Return-Path: header that
  835.    has the envelope from address when delivering mail. Some delivery
  836.    agents add the envelope to address to a Received: header, but they do
  837.    not do it when there is more than one recipient at a site. If either
  838.    of the header to or from addresses are missing they will be added as
  839.    an Apparently-To: or Apparently-From: using the envelope addresses.
  840.    
  841.    Why the two different types? Well it turns out that this is really
  842.    useful for forwarding mail, especially for mailing lists. Mail sent to
  843.    a mailing list will be delivered with the envelope from set to the
  844.    list, the envelope to set to each member of the list, the header from
  845.    set to the sender of the message, and the header to set to the list.
  846.    Note that this is a convention, not a requirement. It makes a lot of
  847.    sense for a mailing list, if you think about it. Similar behavior is
  848.    used for blind carbon copied (BCC) mail.
  849.    
  850.    There is the problem however that people wishing to send bulk email
  851.    (legitimately or not) can just set up a mailing list and it all gets
  852.    delivered to the recipient without them knowing what address was used.
  853.    The implications of this on sub-box filtering should be obvious.
  854.    
  855.    Unless your mail delivery agent does your filtering, all mail to
  856.    desired mailing lists must be pre-filtered out and then all other
  857.    Bcc'ed mail must be considered suspect. Here is a sample procmailrc
  858.    for Alice if she were subscribed to several lists I read:
  859.    
  860.  
  861. # Process mail not specifically addressed to alice@bobs-home
  862. :0
  863. * !^TOalice@bobs-home
  864. {
  865.   # Sent by or to the quickcam driver developer list, a generic list
  866.   # example. Return-Path:, assuming your mailer adds it, is another
  867.   # good generic header to filter on. Some mailing lists are run by
  868.   # a special list user and so all lists from that machine will have
  869.   # the same Return-Path:. This will break things in some situations.
  870.   :0:
  871.   * ^(Sender|To):.*quickcam-drivers
  872.   IN.quickcam-list
  873.  
  874.   # Mail from the lynx developer's list -or- a Bcc'ed personal reply
  875.   # to mail from it. This is a filtering (dis)advantage of lists that
  876.   # modify the subject.
  877.   :0:
  878.   * ^Subject:.*LYNX-DEV
  879.   IN.lynx-list
  880.  
  881.   # From the procmail list. All smartlist mailing lists have a handy
  882.   # X-Loop header to filter on.
  883.   :0:
  884.   * ^X-Loop: procmail@informatik.rwth-aachen.de
  885.   IN.procmail-list
  886.  
  887.   # Remaining mail is either a Bcc or an unknown mailing list.
  888.   :0:
  889.   IN.bcc-suspect
  890. }
  891.  
  892.    With MMDF filtering or procmail as her local delivery agent and some
  893.    sendmail.cf magic, Alice can filter on the envelope address. For
  894.    procmail see the example above on the usage of $1. For MMDF she can
  895.    add to her .maildelivery file a line like:
  896.    
  897.  
  898. addr = | A "/path/to/procmail -a $(address) -d alice"
  899.  
  900.    This will enable procmail filtering on the envelope as above. Read the
  901.    man page for maildelivery(5) for more information on a MMDF
  902.    .maildelivery file.
  903.                            _____________________
  904.    
  905.    Comprehensive plan for a new account
  906.    
  907.    This is a plan of action Alice, mail id alice at bobs-home.com could
  908.    use. Bobs-home has sendmail configured to use + addresses, but not to
  909.    use procmail as a delivery agent. (So procmail cannot know the
  910.    envelope address.)
  911.    
  912.    Here is what she is going to do: bounce all mail addressed to
  913.    "alice@bobs-home", accept mail addressed to "alice+mail@bobs-home",
  914.    and filter mail to "alice+news@bobs-home". Then set the reply to for
  915.    all of her mail to "alice+mail@bobs-home.com" and send all of her
  916.    posts from "alice+news@bobs-home.com". This is hard to do on an old
  917.    account, because too many people know the regular address. With a new
  918.    account she can prevent them from ever getting into the habit of using
  919.    it.
  920.    
  921.    She starts off by creating this .forward file to invoke procmail on
  922.    all of her mail. The quotes used are an important part of this.
  923.    
  924.  
  925. "|IFS=' '&&exec /usr/local/bin/procmail -f-||exit 75 #alice"
  926.  
  927.    Here is a procmailrc that should do the filtering part. As yet this is
  928.    UNTESTED. The DEFAULT variable should be defined by procmail to her
  929.    system mailbox, setting it herself won't hurt, assuming she gets it
  930.    right.
  931.    
  932.  
  933. # The system mailboxes at bobs-home are in /var/spool/mail/.
  934. DEFAULT=/var/spool/mail/alice
  935.  
  936. # Where non-DEFAULT mailboxes live; Mutt uses $HOME/Mail/ by default.
  937. # Destination files in recipes will be relative to this unless they
  938. # start with a '/'. $HOME is set already.
  939. MAILDIR=$HOME/Mail
  940.  
  941. # Where to log.
  942. LOGFILE=$HOME/.procmaillog
  943.  
  944. # Set the shell, just to make sure it's /bin/sh
  945. SHELL=/bin/sh
  946.  
  947. # Three line summary log for each piece of mail.
  948. LOGABSTRACT=yes
  949.  
  950. # Addtionally, log the To: header. formail comes with procmail.
  951. LOG=`formail -X To:`"
  952. "
  953.  
  954. # Accept real mail
  955. :0:
  956. * ^TOalice\+mail@bobs-home
  957. $DEFAULT
  958.  
  959. # Accept mailer daemon mail
  960. :0:
  961. * ^FROM_MAILER
  962. $DEFAULT
  963.  
  964. # Filter news replies
  965. # (The plus character in the address is "magical" in REs
  966. #  and needs to be protected with a backslash)
  967. :0
  968. * ^TOalice\+news@bobs-home
  969. {
  970.         # Bad subject: not in reply form
  971.         :0:
  972.         * !^Subject:(.Re:|(.*[[({ -](was|Re):))
  973.         IN.junk
  974.  
  975.         # Reply to an article
  976.         :0:
  977.         $DEFAULT
  978. }
  979.  
  980. # Bounce remainder, saving a copy in junk, just in case. The EXITCODE is
  981. # the value procmail will return to sendmail on exit. 67 is a sendmail
  982. # specific value that will cause a bounce message to be sent.
  983. EXITCODE=67
  984. :0:
  985. IN.junk
  986.  
  987.    Alice uses trn to read and post news, so she sets the NEWSHEADER and
  988.    MAILHEADER environment variables. sh/ksh/bash/zsh commands that go
  989.    into a .profile for this are:
  990.    
  991.  
  992. # This is the default value of NEWSHEADER in 3.6 with a from line prepended.
  993. NEWSHEADER='From: Alice <alice+news@bobs-home.com>
  994. %(%[followup-to]=^$?:%(%[followup-to]=^%n$?:X-ORIGINAL-NEWSGROUPS: %n
  995. ))Newsgroups: %(%F=^$?%C:%F)
  996. Subject: %(%S=^$?%"\n\nSubject: ":Re: %S)
  997. Summary:
  998. Expires:
  999. %(%R=^$?:References: %R
  1000. )Sender:
  1001. Followup-To:
  1002. %(%{REPLYTO}=^$?:Reply-To: %{REPLYTO}
  1003. )Distribution: %(%i=^$?%"Distribution: ":%D)
  1004. Organization: %o
  1005. Keywords: %[keywords]
  1006. Cc: \n\n'
  1007.  
  1008. # This is the default value of MAILHEADER in 3.6 with a from line prepended.
  1009. MAILHEADER='From: Alice <alice+mail@bobs-home.com>
  1010. To: %t
  1011. Subject: %(%i=^$?:Re: %S
  1012. %(%{REPLYTO}=^$?:Reply-To: %{REPLYTO}
  1013. )Newsgroups: %n
  1014. In-Reply-To: %i)
  1015. %(%[references]=^$?:References: %[references]
  1016. )Organization: %o
  1017. Cc:
  1018. Bcc: \n\n'
  1019.  
  1020. export NEWSHEADER MAILHEADER
  1021.  
  1022.    This will cause the Originator: header to be set to
  1023.    "alice@bobs-home.com", but since she is bouncing that address it
  1024.    shouldn't matter too much. If she really wanted to clean that up, she
  1025.    could use a different inews and Pnews. (Stuff that is posted and
  1026.    mailed using the Cc: header on a post will appear to be from the
  1027.    "alice+news" address.)
  1028.    
  1029.    Alice uses mutt to read and reply to mail, so she creates a .muttrc
  1030.    with the following line it it:
  1031.    
  1032.  
  1033. my_hdr From: Alice <alice+mail@bobs-home.com>
  1034.  
  1035.    When Alice wants to subscribe to mailing lists she will have to adjust
  1036.    her .procmailrc accordingly. She also can't get Bcc'ed mail as sent by
  1037.    most programs. As a last comment let me state that there is nothing
  1038.    inherently special about her using "+mail" and "+news" as the box
  1039.    names, it was just convient.
  1040.                            _____________________
  1041.    
  1042.    Verifying Email Addresses
  1043.    
  1044.    An often asked question in many newsgroups is "How can I verify an
  1045.    email address?" Sometimes people mean that they want to verify
  1046.    deliverability, sometimes they wish to verify valid syntax. The
  1047.    reasons for doing this vary from not wanting to accept invalid
  1048.    addresses in databases to wanting to discard all mail from invalid
  1049.    addresses. Neither verification variant is probably worth the effort.
  1050.    A sanity check might be worthwhile for catching obvious problems, but
  1051.    that is about it.
  1052.    
  1053.    Some of the techniques and pitfalls of the deliverability variant
  1054.    include:
  1055.    
  1056.      * Technique: "Verify that the destination machine name is real"
  1057.        
  1058.        Pitfalls: Between mailer exchange (MX records) redirections and
  1059.        wildcarded mailer exchanges for whole domains, a real address
  1060.        might be incorrectly flagged as bad. Combine that with temporary
  1061.        domain name service (DNS) and other transient problems that crop
  1062.        up and the complexity becomes apparent. Then you have to worry
  1063.        about routed addresses which have multiple hostnames to worry
  1064.        about, at least one of them probably not Internet accessible. UUCP
  1065.        bang ("!") paths are probably the best known variety of these.
  1066.        
  1067.      * Technique: "Use the SMTP VRFY command"
  1068.        
  1069.        Pitfalls: The most common pitfall with this is that most modern
  1070.        MTAs can be configured to not give out useful information in
  1071.        response to this or to the related EXPN command. Gateways,
  1072.        remailers, and various transient problems will further frustrate
  1073.        the would-be VRFYer.
  1074.        
  1075.      * Technique: "Attempt to mail to the address and check for a bounce"
  1076.        This sometimes includes actually sending mail, and sometimes just
  1077.        presenting a mail envelope to the mail server.
  1078.        
  1079.        Pitfalls: Some addresses never bounce mail even if it is an
  1080.        invalid address. Some addresses send faked bounces to some mail
  1081.        while still saving it for a recipient to read. Sometimes MTAs send
  1082.        informational transient error bounce messages to indicate the mail
  1083.        is spooled and delivery will be reattempted. These do not provide
  1084.        any information about validity of the address.
  1085.        
  1086.      * Technique: "Send mail to the address asking for a reply"
  1087.        
  1088.        Pitfalls: Getting a reply from this is the only way to be sure
  1089.        that an address was valid at the time you sent the mail. Since
  1090.        then, of course, the address could have become invalid. Not
  1091.        getting a reply doesn't help too much. Getting a bounce may help.
  1092.        
  1093.    The "check for bounce" tests are probably the best sanity check for
  1094.    address deliverability. Most addresses that bounce are invalid, most
  1095.    that don't are valid.
  1096.    
  1097.    The other variant, checking for valid syntax in an address, is doable,
  1098.    even when isolated from a network. It is not done easily however. Look
  1099.    at some of the valid address examples I gave earlier in this FAQ. The
  1100.    most pathological of the lot are probably these two:
  1101.    
  1102.  
  1103. < eli @ [ 204 . 141 . 25 ] >
  1104.  
  1105. <eli (Pogonatus (latin for <the bearded>))@ (qz (pronounced (queasy) ) \
  1106.  .little-neck (I did not want that, but RFC1480 required it) .ny (New \
  1107.  F%@!: York) .us (USA) or ) netusa (Located on Long Island) . net> (Elijah)
  1108.  
  1109.    The first one uses a domain literal, hence the [brackets]. Many people
  1110.    seem to think that it is fine to just use raw IP addresses in the
  1111.    route specification portion of an address. This is not true. Some
  1112.    mailers may accept it, but the proper notation uses brackets. Even
  1113.    when people do know that, they don't often know that in dot quad
  1114.    notation the third quad or both the second and third quads may be
  1115.    dropped if they are zeros. So "[127.1]" is equivalent to "[127.0.0.1]"
  1116.    and "[204.141.25]" is equivalent to "[204.141.0.25]".
  1117.    
  1118.    The second example is designed to break all regexps I have seen to
  1119.    check for a valid RFC 822 address. Jeffrey Friedl designed the most
  1120.    comprehensive one I have seen as an example for his book Mastering
  1121.    Regular Expressions. But because regular expressions may not match
  1122.    arbitrary paired nestings, e.g. properly matched parentheses, his
  1123.    effort was only designed to match two deep nesting. For other efforts
  1124.    to recognize addresses, that example includes six characters special
  1125.    in email addresses ( < > % @ ! : ) inside of comments in it. Not to
  1126.    mention all that whitespace, since it's allowed and improves
  1127.    readibility so much. :^)
  1128.    
  1129.    The two practical options are to write a full RFC 822 address parser
  1130.    or to "destructively" test a copy of the address. The first is not too
  1131.    difficult, but there are about three pages of BNF in RFC822 so it
  1132.    would probably take at least an afternoon's time to write. The second
  1133.    involves making a temporary copy of the address and then iteratively
  1134.    removing comments and other trouble- some things with say a regexp,
  1135.    and then feeding it to Friedl's verifier. Here's some perl code that
  1136.    should work for such a destructive preprocessor:
  1137.    
  1138.  
  1139. $copy = $address_to_test;
  1140.  
  1141.         $copy =~ s:\\.:a:g          ;    # replace \quoted stuff
  1142.         $copy =~ s:\\\n::gs         ;    # unfold lines
  1143.         $copy =~ s:"[^"]*":b:g      ;    # replace "quoted" stuff
  1144. while ( $copy =~ s:\([^()]*\)::g ) {;}   # (remove ((all) comments))
  1145.  
  1146.    The while loop removes nested comments one layer at a time. Friedl's
  1147.    code to check the address is available from his web pages:
  1148.    <URL:http://enterprise.ic.gc.ca/~jfriedl/regex/code.html>. It is about
  1149.    5k. If the copy is a syntactically valid address, then the original
  1150.    was as well.
  1151.    
  1152.    For a reasonable sanity check after my destructive rewriting, try
  1153.    this.
  1154.    
  1155.  
  1156.         $copy =~ s:\s+::g ;      # suppress whitespace
  1157.  
  1158. $lft = ($copy =~ y:<:<: ); # count <s
  1159. $rgt = ($copy =~ y:>:>: ); # count >s
  1160.  
  1161.    if (( $rgt != $lft ) || ( $lft < 0 ) || ( $lft > 1 )) {
  1162.                 print "Address has invalid encapsulation\n";
  1163. }
  1164. else {
  1165.         # extract from encapsulation, if any
  1166.         $copy =~ s:.*<([^>]*)>.*:$1: ;
  1167.  
  1168.    if ( $copy =~ m:\@\.|\.\.|\.$: ) {
  1169.                 print "Address has invalid dot placement\n";
  1170. }
  1171. elsif ( $copy =~ m:\@.*\@|^\@|\@$: ) {
  1172.                 # There are legal addresses this will reject, but they
  1173.                 # are mind-numbingly rare in practice. The most common
  1174.                 # form is illustrated in this routed address for me:
  1175.                 # <@alpha.netusa.net:eli@mail.netusa.net>
  1176.                 print "Address has dubious \@ usage\n";
  1177. }
  1178. elsif(!($copy =~ y:@:@:)) {
  1179.                 print "Address does not have an at sign\n";
  1180. }
  1181. elsif(!($copy =~ y:.:.:)) {
  1182.                 print "Address does not have a dot\n";
  1183. }
  1184. else {          print "Address is probably good.\n";  }
  1185.  
  1186. }
  1187.  
  1188.    People often try to make other tests, many of them ill-advised. One
  1189.    common one is testing for a known top level domain (TLD). There are a
  1190.    lot of these, so doing it right involves a lot of tests or a very
  1191.    large and probably slow regexp. And that ignores the fact that new
  1192.    ones get added every now and then. As I write this there is the case
  1193.    of Zaire. Until recently it was ".zr", but now that Laurent Kabila has
  1194.    forced Mobutu Sese Seko out, the country has been renamed the
  1195.    Democratic Republic of Congo. It is not unreasonable to expect that a
  1196.    new TLD might be added for it.
  1197.    
  1198.    Another common but unreliable test is checking for spaces. Besides the
  1199.    case I have often illustrated of whitespace being allowed around the
  1200.    delimiting characters, it is legitimate to have spaces in the local
  1201.    part of an address. Try sending mail to my
  1202.    "echo request"@qz.little-neck.ny.us address. Don't worry about the
  1203.    subject, but put just the word "ping" in the body. This toy will reply
  1204.    from the address it receives your mail from. Thus you can see if your
  1205.    mailer is breaking things, such as sending the mail to "request@qz"
  1206.    instead.
  1207.      _________________________________________________________________
  1208.    
  1209.    Comments on this FAQ? Send me mail.
  1210.