Re: Relaying local mail

2020-08-24 Thread Thomas Bohl

Is there a reason you don't want to make root@host2 or @host2 a valid
recipient on host1?



Mainly because if I were to spin up host3, 4 and 5, I'd prefer not to
have to change the config on host1.


Than I would suggest to use authentication.

On hostX:

action "relay2host1" relay \
host smtps://foo@host1 \
auth { foo = password }

match from any for any action "relay2host1"



And on host1 mail from foo gets accepted no matter what:

listen on $v4adr port 12345 smtps \
hostname host1 pki host1 \
auth { foo = $2b$08$dB1z...$ smtpctl encrypt password }

action "send_by_hostX" ... virtual { "@" => user }

match auth foo from any for any action "send_by_hostX"


HTH



Re: Relaying local mail

2020-08-24 Thread Frank Gaspari
On Saturday, August 22, 2020 12:56:21 PM EDT, Thomas Bohl wrote:
> Hi,
>
> > If on host2 I do
> >
> >  # sendmail -t <<- .
> >  From: root
> >  To: root
> >  Subject: Test
> >
> >  .
> >
> > it expands the address to root@host2 and gets rejected by the host1
> > because it doesn't know what to do with the address.
>
> Is there a reason you don't want to make root@host2 or @host2 a valid
> recipient on host1?
>

Mainly because if I were to spin up host3, 4 and 5, I'd prefer not to
have to change the config on host1.



Re: Relaying local mail

2020-08-24 Thread Frank Gaspari
On Friday, August 21, 2020 5:49:25 PM EDT, edgar wrote:
> You could probably write a filter to do this. If you search
> github there is a filter for rewriting the "from" shouldn't be
> too difficult to make it change the "to".

Thanks, found it. I suppose I could adapt it but debugging a 60 line awk
script sort of defeats the purpose.
https://github.com/jirutka/opensmtpd-filter-rewrite-from/blob/master/filter-rewrite-from

I also tried an inline "phase rcpt-to" filter, but sadly it doesn't take
format specifiers.

sendmail: command failed: 550 Invalid recipient: <%{rcpt.user}@localhost>

Basically I'm looking for something like "myorigin" here:
http://www.postfix.org/STANDARD_CONFIGURATION_README.html#null_client

I guess opensmtpd doesn't have it yet

> Edgar
>
> On Aug 20, 2020 9:13 PM, Frank Gaspari wrote:
> > I'm looking to relay all local mail from host2 to corresponding users on
> > host1.
> >
> > Here's host2 smtpd.conf
> >
> > table aliases file:/etc/mail/aliases
> > listen on lo
> > action "relay" relay host smtp://10.9.0.1
> > match for local action "relay"
> >
> > If on host2 I do
> >
> > # sendmail -t <<- .
> > From: root
> > To: root
> > Subject: Test
> >
> > .
> >
> > it expands the address to root@host2 and gets rejected by the host1
> > because it doesn't know what to do with the address. But if I change
> > "To" explicitly to root@localhost it gets delivered.
> >
> > Is there a way to change the domain on rcpt-to for local mail being
> > relayed, similar to "mail-from"?
> >
> > If not, can the default domain be set to localhost rather than the
> > actual host name?
>



Re: Relaying local mail

2020-08-22 Thread Thomas Bohl

Hi,


If on host2 I do

 # sendmail -t <<- .
 From: root
 To: root
 Subject: Test

 .

it expands the address to root@host2 and gets rejected by the host1
because it doesn't know what to do with the address.


Is there a reason you don't want to make root@host2 or @host2 a valid 
recipient on host1?




Relaying local mail

2020-08-20 Thread Frank Gaspari
I'm looking to relay all local mail from host2 to corresponding users on
host1.

Here's host2 smtpd.conf

table aliases file:/etc/mail/aliases
listen on lo
action "relay" relay host smtp://10.9.0.1
match for local action "relay"

If on host2 I do

# sendmail -t <<- .
From: root
To: root
Subject: Test

.

it expands the address to root@host2 and gets rejected by the host1
because it doesn't know what to do with the address. But if I change
"To" explicitly to root@localhost it gets delivered.

Is there a way to change the domain on rcpt-to for local mail being
relayed, similar to "mail-from"?

If not, can the default domain be set to localhost rather than the
actual host name?