From header local mail

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

From header local mail

xegroeg
Hi. In a new install of Postfix 3.4.7-0+deb10u1 on Debian buster, I would like Postfix to append $myhostname instead of $myorigin to local mail with a From header containing just a username, like cron or fail2ban emails.  This server is listed in mx records for example.com.  In older Postfix installations (3.1) it seemed that only setting the below would be enough for local mail to be addressed from, for example, [hidden email].  Wondering what I am missing or what to check next.

myhostname              = mx.example.com
myorigin                = example.com
mydestination           = mx.example.com, localhost

/etc/mailname is mx.example.com

Feb  7 10:45:00 mx postfix/pickup[27300]: EF3E31C0CA0: uid=0 from=<root>
Feb  7 11:02:04 mx postfix/pickup[27300]: 49A2D1C0CA0: uid=114 from=<logcheck>
Feb  7 11:02:04 mx postfix/pickup[27300]: EAD661C112C: uid=110 from=<[hidden email]>
Feb  7 11:02:06 mx postfix/pickup[27300]: 85CF81C112C: uid=110 from=<[hidden email]>
Feb  7 11:06:06 mx postfix/pickup[27300]: AC8851C112C: uid=110 from=<[hidden email]>
Feb  7 11:06:54 mx postfix/pickup[28725]: CF91B1C0CA0: uid=0 from=<root>
Feb  7 11:12:28 mx postfix/pickup[28725]: D5D581C0CA0: uid=0 from=<fail2ban>
Feb  7 11:16:42 mx postfix/pickup[29054]: AADAC1C0CA0: uid=0 from=<root>


Feb  7 11:16:42 mx postfix/pickup[29054]: AADAC1C0CA0: uid=0 from=<root>
Feb  7 11:16:42 mx postfix/cleanup[29078]: AADAC1C0CA0: warning: header Subject: test from local; from=<[hidden email]>
Feb  7 11:16:42 mx postfix/cleanup[29078]: AADAC1C0CA0: message-id=<[hidden email]>
Feb  7 11:16:42 mx postfix/qmgr[29055]: AADAC1C0CA0: from=<[hidden email]>, size=420, nrcpt=1 (queue active)
Feb  7 11:16:42 mx postfix/smtp[29080]: AADAC1C0CA0: to=<[hidden email]>, orig_to=<root>, relay=mail.example.com[<snip>]:25, delay=0.23, delays=0.03/0.02/0.02/0.16, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as BA2DA4E014F)
Feb  7 11:16:42 mx postfix/qmgr[29055]: AADAC1C0CA0: removed

Possibly relevant?:

always_add_missing_headers = yes
header_from_format = obsolete



Reply | Threaded
Open this post in threaded view
|

Re: From header local mail

Bill Cole-3
On 7 Feb 2020, at 13:01, [hidden email] wrote:

> Hi. In a new install of Postfix 3.4.7-0+deb10u1 on Debian buster, I
> would like Postfix to append $myhostname instead of $myorigin to local
> mail with a From header containing just a username, like cron or
> fail2ban emails.

Then just don't explicitly set $myorigin. Its only purpose is to qualify
bare local-parts and it defaults to $myhostname.

If for some reason that is unacceptable, see
http://www.postfix.org/DEBUG_README.html#mail for how best to document
your problem to get useful help here. A selection of the configuration
directives that you *think* are relevant is much less useful than your
actual "postconf -n output."


--
Bill Cole
[hidden email] or [hidden email]
(AKA @grumpybozo and many *@billmail.scconsult.com addresses)
Not Currently Available For Hire
Reply | Threaded
Open this post in threaded view
|

Re: From header local mail

xegroeg

Thanks. If I remove $myorigin than all mail ends up going to @mx.example.com and bounces.

postconf -n output https://pastebin.com/WwVdT8CF

> On Feb 7, 2020, at 12:59 PM, Bill Cole <[hidden email]> wrote:
>
> On 7 Feb 2020, at 13:01, [hidden email] wrote:
>
>> Hi. In a new install of Postfix 3.4.7-0+deb10u1 on Debian buster, I would like Postfix to append $myhostname instead of $myorigin to local mail with a From header containing just a username, like cron or fail2ban emails.
>
> Then just don't explicitly set $myorigin. Its only purpose is to qualify bare local-parts and it defaults to $myhostname.
>
> If for some reason that is unacceptable, see http://www.postfix.org/DEBUG_README.html#mail for how best to document your problem to get useful help here. A selection of the configuration directives that you *think* are relevant is much less useful than your actual "postconf -n output."
>
>
> --
> Bill Cole
> [hidden email] or [hidden email]
> (AKA @grumpybozo and many *@billmail.scconsult.com addresses)
> Not Currently Available For Hire
Reply | Threaded
Open this post in threaded view
|

Re: From header local mail

xegroeg
In reply to this post by xegroeg

Thanks. If I remove $myorigin than all mail ends up going to @mx.example.com and bounces.

postconf -n output https://pastebin.com/WwVdT8CF

>> On Feb 7, 2020, at 12:59 PM, Bill Cole <[hidden email]> wrote:
>>
>> On 7 Feb 2020, at 13:01, [hidden email] wrote:
>>
>> Hi. In a new install of Postfix 3.4.7-0+deb10u1 on Debian buster, I would like Postfix to append $myhostname instead of $myorigin to local mail with a From header containing just a username, like cron or fail2ban emails.
>
> Then just don't explicitly set $myorigin. Its only purpose is to qualify bare local-parts and it defaults to $myhostname.
>
> If for some reason that is unacceptable, see http://www.postfix.org/DEBUG_README.html#mail for how best to document your problem to get useful help here. A selection of the configuration directives that you *think* are relevant is much less useful than your actual "postconf -n output."
>
>
> --
> Bill Cole
> [hidden email] or [hidden email]
> (AKA @grumpybozo and many *@billmail.scconsult.com addresses)
> Not Currently Available For Hire
Reply | Threaded
Open this post in threaded view
|

Re: From header local mail

Matus UHLAR - fantomas
In reply to this post by xegroeg
On 07.02.20 12:01, [hidden email] wrote:
>Hi.  In a new install of Postfix 3.4.7-0+deb10u1 on Debian buster, I would
> like Postfix to append $myhostname instead of $myorigin to local mail

That is the point of myorigin, why you want it else?

--
Matus UHLAR - fantomas, [hidden email] ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
10 GOTO 10 : REM (C) Bill Gates 1998, All Rights Reserved!
Reply | Threaded
Open this post in threaded view
|

Re: From header local mail

Bob Proulx
In reply to this post by xegroeg
[hidden email] wrote:
> Hi. In a new install of Postfix 3.4.7-0+deb10u1 on Debian buster, I
> would like Postfix to append $myhostname instead of $myorigin to
> local mail with a From header containing just a username, like cron
> or fail2ban emails.  This server is listed in mx records for
> example.com.

I see you are using Gmail.  One must be careful and look at the "Show
original message" in order to see what is actually being set on
headers as Gmail does not display that information to you otherwise.
For example if a comment is included then Gmail will display the
comment and hide the address.

Cron emails look like this for me:

    From: CronDaemon <[hidden email]>
    To: [hidden email]

In Gmail that would display the "CronDaemon" comment and the root@
address part would be hidden.  One must use Show original message with
Gmail in order to see the actual contents of the header.

If you want a specific From: then either set $myorigin to the domain
you wish, or do not set myorigin and let it use $myhostname which is
the default.

  http://www.postfix.org/postconf.5.html#myorigin

> In older Postfix installations (3.1) it seemed that only setting the
> below would be enough for local mail to be addressed from, for
> example, [hidden email].  Wondering what I am missing or what
> to check next.

Are you thinking of "masquerade_exceptions = root" with
"masquerade_domains = example.com" here?  That would match the
description as you have written.

> myhostname              = mx.example.com
> myorigin                = example.com
> mydestination           = mx.example.com, localhost

The above will make [hidden email] be the From: address for
locally created email.  But the system will not accept mail for that
domain since it does not appear in mydestination.  I think
mydestination should include $myhostname here.

Meanwhile, I always have localhost.$mydomain in my list too.

  mydestination = $myhostname, localhost.$mydomain, localhost

> /etc/mailname is mx.example.com

Debian has a downstream patch that allows "myorigin = /etc/mailname"
and the actual contents in that file in order to facilitate a generic
image being customized across several different MTA installations all
uniformly the same way.  The contents of /etc/mailname are only used
if also using the Debian patch functionality myorigin = /etc/mailname
AFAIK.  In the above you are not setting it to /etc/mailname and
therefore that file's contents are not used.

> postconf -n output https://pastebin.com/WwVdT8CF

I see:

    append_dot_mydomain = yes

Not sure if this plays into what you are asking.  The default is yes.
But previously you might have had it set to no.

  http://www.postfix.org/COMPATIBILITY_README.html

  http://www.postfix.org/postconf.5.html#append_dot_mydomain

> If I remove $myorigin than all mail ends up going to @mx.example.com and bounces.

Why is it bouncing?  And isn't mail going to @mx.example.com exactly
what you have asked for?  Why does that mail bounce?

Bob
Reply | Threaded
Open this post in threaded view
|

Re: From header local mail

xegroeg
In reply to this post by xegroeg
I guess my problem is that when I have that set, myhostname is added to all mail. TO: aliases looked up in LDAP are returned as just usernames and end up as [hidden email] and bounce.

To clarify, i would expect that the FROM: changes, and this is what I want for local mail, but the TO: address changes as well.

An example internal fail2ban alert:
* pickup shows From:<fail2ban>, $mydomain is appended. To: is an alias in LDAP. LDAPnames@$mydomain

With /etc/mailname,
* pickup shows From:<fail2ban>, $myhostname is appended. To: is an alias in LDAP. LDAPnames@$myhostname. Not local, bounces no mailbox for users.

Cron is the same. On an older system greps for pickup and fail2ban, cron, etc show From:<fail2ban@fqdn>

Gmail is not being used in the domain in question. I’m just using this to submit my question.


>> On Feb 7, 2020, at 2:45 PM, Matus UHLAR - fantomas <[hidden email]> wrote:
>>
>> On 07.02.20 12:01, [hidden email] wrote:
>> Hi.  In a new install of Postfix 3.4.7-0+deb10u1 on Debian buster, I would
>> like Postfix to append $myhostname instead of $myorigin to local mail
>
> That is the point of myorigin, why you want it else?
>
> --
> Matus UHLAR - fantomas, [hidden email] ; http://www.fantomas.sk/
> Warning: I wish NOT to receive e-mail advertising to this address.
> Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
> 10 GOTO 10 : REM (C) Bill Gates 1998, All Rights Reserved!
Reply | Threaded
Open this post in threaded view
|

Re: From header local mail

xegroeg
And the second server listed as MX for this domain has an identical main.cf, but is running an older Postfix.

> On Feb 7, 2020, at 5:03 PM, [hidden email] wrote:
>
> I guess my problem is that when I have that set, myhostname is added to all mail. TO: aliases looked up in LDAP are returned as just usernames and end up as [hidden email] and bounce.
>
> To clarify, i would expect that the FROM: changes, and this is what I want for local mail, but the TO: address changes as well.
>
> An example internal fail2ban alert:
> * pickup shows From:<fail2ban>, $mydomain is appended. To: is an alias in LDAP. LDAPnames@$mydomain
>
> With /etc/mailname,
> * pickup shows From:<fail2ban>, $myhostname is appended. To: is an alias in LDAP. LDAPnames@$myhostname. Not local, bounces no mailbox for users.
>
> Cron is the same. On an older system greps for pickup and fail2ban, cron, etc show From:<fail2ban@fqdn>
>
> Gmail is not being used in the domain in question. I’m just using this to submit my question.
>
>
>>>> On Feb 7, 2020, at 2:45 PM, Matus UHLAR - fantomas <[hidden email]> wrote:
>>>
>>> On 07.02.20 12:01, [hidden email] wrote:
>>> Hi.  In a new install of Postfix 3.4.7-0+deb10u1 on Debian buster, I would
>>> like Postfix to append $myhostname instead of $myorigin to local mail
>>
>> That is the point of myorigin, why you want it else?
>>
>> --
>> Matus UHLAR - fantomas, [hidden email] ; http://www.fantomas.sk/
>> Warning: I wish NOT to receive e-mail advertising to this address.
>> Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
>> 10 GOTO 10 : REM (C) Bill Gates 1998, All Rights Reserved!
Reply | Threaded
Open this post in threaded view
|

Re: From header local mail

Wietse Venema
In reply to this post by xegroeg
[hidden email]:
> Hi. In a new install of Postfix 3.4.7-0+deb10u1 on Debian buster,
> I would like Postfix to append $myhostname instead of $myorigin
> to local mail with a From header containing just a username, like
> cron or fail2ban emails.  This server is listed in mx records for
> example.com.  In older Postfix installations (3.1) it seemed that
> only setting the below would be enough for local mail to be addressed
> from, for example, [hidden email].  Wondering what I am missing
> or what to check next.

Postfix 3.3 changes the default From: header format:

    Old:    From: address (name)

    New:    From: name <address>

To get the old form (which is non-standard):

/etc/postfix/main.cf:
    header_from_format = obsolete

        Wietse