11.6 Handling user@thishost
The
user@thishost
Here, the
R$-@$+
This form is easy to use because the
But how could the sender's address not be from the local machine?
Recall that
sendmail
gets the sender address from one
of four places: from the envelope, from the
Consider, for example, a Usenet news-posting program that posts news by sending
mail. It may be desirable to have all posted news messages appear
to be from the news program
on the news server machine. One
way to achieve this is by running
sendmail
with
the
-f news@news.server
Here, the
But in this example you would not want to change
the address of the sender to appear as though it were from the
hub. That would undo what
A better approach is to match the user, the
R$-@$w
Recall that Add this new rule to the client.cf file:
SHubset # Rewrite the sender for the hub R$- $@ $1@${HUB} user -> user@hub Notice that, other than their comments, the two rules differ only in their LHS. The flow through these rules is that the first tries to match a lone username in the workspace. If that match fails, the second rule tries to match the workspace. It matches only a workspace that contains the name of a user at the local machine. To observe this rule in action, run sendmail in rule-testing mode again:
%
This time, we added the
Version 8.8.4 Compiled with: LOG MATCHGECOS MIME7TO8 MIME8TO7 NAMED_BIND NDBM NETINET NETUNIX NIS SCANF XDEBUG ============ SYSTEM IDENTITY (after readcf) ============ (short domain name) $w = here (canonical domain name) $j = here.us.edu (subdomain name) $m = us.edu (node name) $k = here ======================================================== ADDRESS TEST MODE (ruleset 3 NOT automatically invoked) Enter <ruleset> <address> >
Note that
sendmail
, in this example, defines
Now give
sendmail
rule sets 3 and
>
The user part can be any login name. The host part must be
the text in the
rewrite: ruleset 3 input: you @ here rewrite: ruleset 3 returns: you @ here rewrite: ruleset 199 input: you @ here rewrite: ruleset 199 returns: you @ mail . us . edu
As intended, Note, however, that you cannot specify macros when testing addresses; that is, the following does not work:
> The sendmail program does not recognize macros in addresses. They aren't recognized because macros in rule sets are expanded when the configuration file is read, not when sendmail reads addresses. The command above results in the following erroneous output:
rewrite: ruleset 3 input: you @ $w rewrite: ruleset 3 returns: you @ $w rewrite: ruleset 199 input: you @ $w rewrite: ruleset 199 returns: you @ $w
Also note that the value in |
|