[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: exmh and the From field.



shaul@rakefet.debian.org writes:

> From time to time I am still trying to convince exmh to use the login and 
> address of my ISP's account (beitamos@inter.net.il).
>
    [ ... excerpts from PPP-HOWTO, on configuring MH ... ]
>
> But it didn't give me the correct From field. 
>
    [ ... more from PPP-HOWTO on configuring sendmail ... ]
>
> If I can't make step 0 to work and I don't use sendmail, is it possible to 
> convert this to something useful with smail ?

There are instructions for configuring smail to rewrite your From field, in
the Debian FAQOMATIC (Courtesy of Daniel Gross <dg@bingo.baynet.de> ):

	<http://www.debian.org/fom/137.html>

I followed the instructions, and it works perfectly.  But I had a little
trouble at first, partly because in the FAQOMATIC, at least as it displays in
my browser, the lines are broken in ways that would be invalid in the actual
configuration files.  I've also found there's an additional glitch when using
mh (or exmh).  So I'll paraphrase the instructions below, and expand on them a
little.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 NOTE TO DEBIAN DEVELOPERS: Could something like this be added to the choices
 in the smailconfig script?  It seems like such a common problem.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Here are the steps.


1. Create the file `/etc/smail/maps/from' (the file name is arbitrary, but is
used in step 3 below).  This file should give the mapping from local
usernames, to valid Internet-email addresses.  The syntax is

localuser ispuser@isphost (full name)

Here `localuser' is your login name on your local machine; `ispuser@isphost'
is the address you want to appear in the From field; and `full name' is your
full name, as you want it to appear in the From field.

So, for instance, if your local user name is `joe', and your email address is
`jshmoe@myisp.net', and your full name is `Joe W. Shmoe', you should have this
line in /etc/smail/maps/from:

joe jshmoe@myisp.net (Joe W. Shmoe)

If there are other users on your local system, you should add the appropriate
entry for each of them.


2. Edit `/etc/smail/routers', replacing every occurrence of `transport=smtp'
with `transport=smtp-rewrite'.


3. At the bottom of `/etc/smail/transports', add the following 6 lines:

smtp-rewrite:
	 driver=tcpsmtp, max_addrs=100, -max_chars, inet,
	 remove_header="From",
	 insert_header="From: ${lookup:from:lsearch{maps/from}{$value}}",
	 insert_header="Sender: ${lookup:from:lsearch{maps/from}{$value}}";
	 use_bind, defer_no_connect, -local_mx_okay, defnames

[The syntax of all this is explained in the smail(5) man page.]

IMPORTANT: Make sure you get all the punctuation exactly as it's shown.  In
particular, there are several commas, and only one semicolon.  It's crucial
that the semicolon be there, and not a comma!

Lines 3-5 of the 6 lines above cause smail to replace the From and Sender
fields of all outgoing mail, with new addresses that it gets from the
`/etc/smail/maps/from' file, that you created in step 1.  (Lines 2 and 6 are
the same as in the `smtp' entry in /etc/smail/transports.)

If you want, you can add a default value for the From and Sender fields, which
should be used if no entry is found in maps/from, corresponding to the
sender's local username.  This would appear in braces, immediately following
{$value} and before the final }.  For example:

 ...${lookup:from:lsearch{maps/from}{$value}{jshmoe@myisp.net ($fullname)}}",

This would give a default return address of <jshmoe@myisp.net>, but would
indicate the full name of the actual local user, even if it's not Joe Shmoe.

(But this doesn't seem to work with mh -- see below).

----------

Now you should be able to send mail to the Internet, with most mail agents
(command-line `mail', for example), and have a valid return address.

However, for some reason which I don't quite understand, this doesn't work
with mh (or exmh).  Apparently, when sending mail from mh, the From field is
initially set to `user@host' instead of just `user', so it's looking for
`user@host' in /etc/smail/maps/from, and it doesn't find it.  Furthermore,
even if you've specified a default value as above, to be used if there's no
matching entry in /etc/smail/maps/from, mh seems to ignore it, too.

Can anyone explain why this happens?  It almost looks as though mh is itself
parsing the transports file -- bypassing smail -- but doing it incorrectly.

Anyway, there's a simple fix: Just put an additional entry in
/etc/smail/maps/from, corresponding to each existing entry, but with the local
hostname appended to the username.  So, in the example I used above, suppose
the hostname of your local machine is `myhome'.  Then there would be two
entries in /etc/smail/maps/from:
	
joe jshmoe@myisp.net (Joe Shmoe)
joe@myhome jshmoe@myisp.net (Joe Shmoe)

Then mh finds the user@host entry, and everyone is happy.  You may still get
warnings in the logfile (/var/log/smail/logfile), since the message is
initially presented with the user@home address; but no harm is done.
Ultimately the message gets sent with the correct return address.

--
David Zelinsky
zelinsky@us.net


Reply to: