Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[AMaViS-user] Multiple domains - getting the right domain name in headers

1,040 views
Skip to first unread message

email builder

unread,
Oct 20, 2009, 4:42:23 PM10/20/09
to
Hi everyone,

I am trying to see if it's possible when hosting mail for multiple domains if it's possible to get the actual domain to which the message belongs in all the email headers instead of always having it fall back to the "main" domain/hostname.

I think the following header is written out by amavisd-new (please correct me if I'm wrong):

Received: from mail.example.com ([127.0.0.1])
by localhost (diamond.example.com [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id 26IWMZMJeY2B for <us...@somewhere.com>;
Tue, 13 Oct 2009 17:11:50 -0400 (EDT)

In my case, the local machine hostname is "diamond.example.com" and it is also my mail server, "mail.example.com". But in this case, the message is being sent by a user in a domain called, say, "other.com". I have a Postfix configuration where its headers are added using "other.com", but this header is the problem.

It seems that "diamond.example.com" in this header is just caused by amavis grabbing the local machine hostname (problem #1 - is this possible to change?).

But as for how amavis got "mail.example.com", I am not entirely sure, since the handoff came from a Postfix instance where its mydomain is "other.com" and its myhostname is "mail.other.com" (problem #2 - where does this come from and can I change it?).

Problem #3 is in regard to the handoff back to Postfix. Is is possible to determine the mydomain from what Postfix is using and then change the $notify_method and $forward_method according to that domain?

I really appreciate any tips.


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
AMaViS-user mailing list
AMaVi...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amavis-user
AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3
AMaViS-HowTos:http://www.amavis.org/howto/

email builder

unread,
Oct 20, 2009, 10:42:04 PM10/20/09
to

> > > > I am trying to see if it's possible when hosting mail for multiple domains

>
>
> > if
> >
> > > it's possible to get the actual domain to which the message belongs in all
> the
> >
> > > email headers instead of always having it fall back to the "main"
> > > domain/hostname.
> > > >
> > > > I think the following header is written out by amavisd-new (please correct
>
> > me
> > > if I'm wrong):
> > >

> > > inbound, or outbound?
> >
> > In this case, outbound, but I'm not sure it matters, at least when amavis is
> > used as a content_filter in postfix - you can use that in both scenarios and
> I'm
> > sure the functionality differs, at least with mostly default settings.
> >
> > > and, munging the names/ip's can mess things up, since, amavisd, postfix,
> > > x-forward all some into play here.
> > >
> > > (as an example, its hard to tell what part is munged, and what part to
> > > help you on)
> >
> > That's why I specifically pointed out the issues (#1, #2, #3). Please re-read
>
> > what I wrote. To reiterate, "diamond.example.com" is the local hostname. The
>
> > machine is also known as "mail.example.com". I host another domain on the
> > machine called "other.com." I DO NOT want the two "example.com" parts in the
> > header. I am looking for a way to replace them with "other.com" (when the
> > sender sends from that domain, in which case postfix's myhostname and mydomain
>
> > are "mail.other.com"/"other.com").
> >
> > The ONLY things of importance that I munged were the domain names, but they
> are
> > consistent with my explanations/questions.
> >
> > I am additionally trying to understand how to forward back to postfix on a
> > different port depending on this domain.
> >
> > > mung the user name, ok, maybe not the domain, what can it hurt?
> > >
> > > your ip/dns names, internal ip's all show up in the headers to this
> > > email anyway.
> > >
> > > all you do is make it harder for people to look at it and help. Like I
> > > said, we don't know what amavis or postfix munged, and what you munged.
> >
> > I don't think it's rocket science. I'm only needing to change the domain
> names
> > that show up in the header amavis spits out.


> >
> > > > Received: from mail.example.com ([127.0.0.1])
> > > > by localhost (diamond.example.com [127.0.0.1]) (amavisd-new, port
> > > 10024)

> > > > with ESMTP id 26IWMZMJeY2B for ;


> > > > Tue, 13 Oct 2009 17:11:50 -0400 (EDT)
> > > >
> > > > In my case, the local machine hostname is "diamond.example.com" and it is
> > also
> > > my mail server, "mail.example.com". But in this case, the message is being
> > sent
> > > by a user in a domain called, say, "other.com". I have a Postfix
> > configuration
> > > where its headers are added using "other.com", but this header is the
> problem.
> > > >
> > > > It seems that "diamond.example.com" in this header is just caused by
> amavis
> > > grabbing the local machine hostname (problem #1 - is this possible to
> > change?).
> > > >
> > > > But as for how amavis got "mail.example.com", I am not entirely sure,
> since
> > > the handoff came from a Postfix instance where its mydomain is "other.com"
> and
> >
> > > its myhostname is "mail.other.com" (problem #2 - where does this come from
> and
> >
> > > can I change it?).
> > > > \
> > > >
> > >
> > > > Problem #3 is in regard to the handoff back to Postfix. Is is possible to
>
> > > determine the mydomain from what Postfix is using and then change the
> > > $notify_method and $forward_method according to that domain?
> > > >
> > > >

> > > use policy banks, different ports to listen to, or different ip's.
> >
> > I'm happy to read about how to do this, but not sure where to look. Are you
> > saying it's possible to run ONE instance of amavis listening on more than one
> > port, and that I can apply different configuration values depending on that
> > port? That'd be the easiest and best way to do this, but it seems to me that
> > I'd have to run multiple instances of amavis, which is not desirable in this
> > case.
>
> "policy banks" was the keyword I needed. The document I also needed was:
>
> http://amavisd.de.postfix.org/amavisd-new-docs.html#pbanks
>
> Oh, and to listen on multiple ports with a single instance, the example's right
> there in the configuration file:
>
> $inet_socket_port = [10022,10024];
>
> I have successfully redefined the re-injection method (port) using a port-based
> policy bank. Great start! However, I also tried to re-define $mydomain
> therein, but it does not seem to work:
>
> X-Virus-Scanned: amavisd-new at example.com
>
> However, if I set $mydomain in the main, top-level configuration to "other.com",
> I successfully get:
>
> X-Virus-Scanned: amavisd-new at other.com
>
> Hmm, is $mydomain off limits in policy banks? Here is how I defined it:

I see. The original value for $mydomain is used to build any other configuration setting that uses it (such as $virus_admin = "virusalert\@$mydomain";) That means it's too late to just change $mydomain by the time my new policy bank is used. So I had to redefine X_HEADER_LINE instead:

$policy_bank{'OTHER'} = {
mydomain => 'other.com',
notify_method => 'smtp:[127.0.0.1]:10023',
forward_method => 'smtp:[127.0.0.1]:10023',
X_HEADER_LINE => "$myproduct_name at other.com",
insert_received_line => 0,
};

> Please note that this does NOT address the problem of the Received header I
> mentioned above (problem #1 and #2), which I don't know how to change.

I cannot find any configuration settings that seem to deal with how this Received header is constructed by amavis. So, unfortunately, it looks like the only choice I have is to override the value for $insert_received_line in my policy bank so the header is removed entirely (see above). If there are ways to actually change how the Received header is built, I'd love to know.

Thanks

email builder

unread,
Oct 20, 2009, 11:01:57 PM10/20/09
to

But it does look like $mydomain is off limits for policy banks. When sending emails, I see this in my maillog:

(!)loading policy bank "YTFO": unknown field "mydomain"

I didn't really need "mydomain" in my policy bank, so I just commented it out.

Mark Martinec

unread,
Oct 21, 2009, 8:02:03 PM10/21/09
to
> I think the following header is written out by amavisd-new

It is.

> Received: from mail.example.com ([127.0.0.1])
> by localhost (diamond.example.com [127.0.0.1]) (amavisd-new, port 10024)

> with ESMTP id 26IWMZMJeY2B for <us...@somewhere.com>;


> Tue, 13 Oct 2009 17:11:50 -0400 (EDT)
>
> In my case, the local machine hostname is "diamond.example.com" and it is
> also my mail server, "mail.example.com". But in this case, the message is
> being sent by a user in a domain called, say, "other.com". I have a Postfix
> configuration where its headers are added using "other.com", but this header
> is the problem.

Here is a complete breakdown of component fields that make up
the Received header field, as generated by amavisd. It closely
follows the RFC 2821 'Trace Information' syntax and semantics
(now RFC 5321).

> Received: from mail.example.com ([127.0.0.1])

^^^^^^^^^^^^^^^^
mail.example.com is whatever your Postfix presented to amavisd in its
EHLO command while handing the message over to amavisd

> Received: from mail.example.com ([127.0.0.1])

^^^^^^^^^^^
127.0.0.1 is the source IP address from which amavisd received
the TCP connection

> by localhost (diamond.example.com [127.0.0.1]) (amavisd-new, port 10024)

^^^^^^^^^
localhost is your $localhost_name setting, it is a member of policy banks.

> by localhost (diamond.example.com [127.0.0.1]) (amavisd-new, port 10024)

^^^^^^^^^^^^^^^^^^^
diamond.example.com is the $myhostname setting, member of policy banks

> by localhost (diamond.example.com [127.0.0.1]) (amavisd-new, port 10024)

^^^^^^^^^
127.0.0.1 is the IP address of amavisd socket that received a connection

> by localhost (diamond.example.com [127.0.0.1]) (amavisd-new, port 10024)

^^^^^^^^^^^
amavisd-new is the $myproduct_name setting

> by localhost (diamond.example.com [127.0.0.1]) (amavisd-new, port 10024)

^^^^^
dst socket port number on which the connection was received by amavisd

> with ESMTP id 26IWMZMJeY2B for <us...@somewhere.com>;
^^^^^
ESMPT is derived from the session type (smtp/lmtp, authenticated or not, ...)

> with ESMTP id 26IWMZMJeY2B for <us...@somewhere.com>;
^^^^^^^^^^^^
26IWMZMJeY2B is the mail_id (also available as macro %i), i.e. a unique
identification of this SMTP transaction. It is commonly used in the
quarantine name template, in notifications and in the log

> Tue, 13 Oct 2009 17:11:50 -0400 (EDT)

The date/time corresponds to the moment at which the SMTP transaction
was opened (the MAIL FROM command)

> It seems that "diamond.example.com" in this header is just caused by amavis
> grabbing the local machine hostname (problem #1 - is this possible to
> change?).

Yes, it is the $myhostname. Actually the 'myhostname' key from the
currently loaded policy bank.

> But as for how amavis got "mail.example.com", I am not entirely sure, since
> the handoff came from a Postfix instance where its mydomain is "other.com"
> and its myhostname is "mail.other.com" (problem #2 - where does this come
> from and can I change it?).

It's what Postfix provided when introducing itself with EHLO.
Configurable through 'smtp_helo_name' Postfix option (global or per-service).

> Problem #3 is in regard to the handoff back to Postfix. Is is possible
> to determine the mydomain from what Postfix is using and then change the
> $notify_method and $forward_method according to that domain?

Yes, through policy banks.

> I am additionally trying to understand how to forward back to postfix
> on a different port depending on this domain.

Again, through policy banks, key 'forward_method'.

> I have successfully redefined the re-injection method (port) using a
> port-based policy bank. Great start! However, I also tried to re-define
> $mydomain therein, but it does not seem to work:

> Hmm, is $mydomain off limits in policy banks? Here is how I defined it:

> $policy_bank{'OTHER'} = {
> mydomain => 'other.com',
> notify_method => 'smtp:[127.0.0.1]:10023',
> forward_method => 'smtp:[127.0.0.1]:10023',

> };

Wrong variable. What you need is 'myhostname'.

The $mydomain is just a convenience variable which you can use
in the config file to more consistently define other settings
and to provide a default for them, such as @local_domains_maps.
It is not a member of policy banks, in fact it is not used
by amavisd at all (with one tiny exception).

Mark

email builder

unread,
Oct 22, 2009, 3:39:39 AM10/22/09
to

----- Original Message ----
> From: Mark Martinec <Mark.Marti...@ijs.si>
> To: amavi...@lists.sourceforge.net
> Sent: Wed, October 21, 2009 5:02:03 PM
> Subject: Re: [AMaViS-user] Multiple domains - getting the right domain name in headers
>
> > I think the following header is written out by amavisd-new
>
> It is.
>
> > Received: from mail.example.com ([127.0.0.1])
> > by localhost (diamond.example.com [127.0.0.1]) (amavisd-new, port 10024)

> > with ESMTP id 26IWMZMJeY2B for ;

> > with ESMTP id 26IWMZMJeY2B for ;


> ^^^^^
> ESMPT is derived from the session type (smtp/lmtp, authenticated or not, ...)
>

> > with ESMTP id 26IWMZMJeY2B for ;

Wow, that's way above and beyond the call of duty. That answers all my questions and more. Thanks very very very very much, Mark.

0 new messages