DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 26th May 2021
discostew discostew is offline
Port Guard
 
Join Date: May 2021
Posts: 14
Default OpenSMTPD rewrite sender of relayed mail to virtual entry

Hi DaemonForums!

The "as" keyword in OpenSMTPD smtpd.conf on the "relay via" directive allows you to change either the user, the domain, or whole email address of the sender on relayed email. This is great, however I would really like it to change the sender to the final expanded virtual address for the domain.. For example:

Code:
/etc/mail/smtpd.conf:

accept from any sender foo@bar.com for any recipient relay-recipient@externaldomain.com relay via secure+auth://myispuser@smtp.myisp.net auth <credentials> as '@mail.mydomain.com' hostname mail.mydomain.com
WIth mail from foo@bar.com => virtual-address@mydomain.com

With virtual table entry:

Code:
/etc/mail/virtuals:

virtual-address@mydomain.com    localuser,relay-recipient@externaldomain.com
Will properly relay the email from "foo@bar.com" to "relay-recipient@externaldomain.com" and rewrite the sender as "foo@mail.mydomain.com"...

However what I'd really like it to do is rewrite the sender as "virtual-address@mydomain.com" when relaying to "relay-recipient@externaldomain.com.

I can't think of any reason why this _couldn't_ be done, I'm just not sure smtpd.conf currently has the syntax to pull this off.

Can anyone think of a creative way to achieve this with current smtpd.conf syntax / virtual table entries?

Thank you for all of your help!

Cheers,
discostew

Code:
uname -a
OpenBSD myserver@mydomain.com 6.1 GENERIC.MP#20 amd64

Last edited by discostew; 26th May 2021 at 08:59 PM.
Reply With Quote
  #2   (View Single Post)  
Old 26th May 2021
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,182
Default

Quote:
Originally Posted by discostew View Post
Code:
uname -a
OpenBSD myserver@mydomain.com 6.1 GENERIC.MP#20 amd64
OpenBSD 6.1? If that is not a typo, you have a problem In the 8 releases from 6.1 -> 6.9 a lot has changed in OpenSMTP.
I only started using OpenSMTP a couple of weeks ago, so I am unable to help you with this.
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote
  #3   (View Single Post)  
Old 26th May 2021
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 8,082
Default

6.1 is probably correct, as "relay via" was last part of the grammar with release 6.3. The major operational and syntax changes to OpenSMTPd were released with 6.4.

Hello and welcome, discostew. Unfortunately, 6.1 support ended 4 years ago.
Reply With Quote
  #4   (View Single Post)  
Old 26th May 2021
discostew discostew is offline
Port Guard
 
Join Date: May 2021
Posts: 14
Default

Thank you for the very quick reply J65nko / jggimi!

Yes, sadly it is 6.1.. I setup this machine before starting medical school to handle my email, and now that I'm finished (4 years later) I finally have a bit of time to spend tweaking / upgrading things. I have a few other machines upgraded to 6.8, but haven't taken a stab at this one quite yet.

I did plan on doing some upgrades with this time off - looking through the smtpd.conf 6.9 man page I'm having trouble finding the new syntax for the previous "as" directive for "relay via"..

Do you know what syntax replaced this functionality, or perhaps it's been taken out?
Reply With Quote
  #5   (View Single Post)  
Old 26th May 2021
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,182
Default

My impression is that you have to write or use a filter to do the rewriting.

I am not sure whether something like this could be useful and/or adapted to your situation : https://github.com/jirutka/opensmtpd...r-rewrite-from

There are a couple of other filters listed at https://github.com/topics/opensmtpd-filter
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump

Last edited by J65nko; 26th May 2021 at 11:32 PM.
Reply With Quote
  #6   (View Single Post)  
Old 27th May 2021
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 8,082
Default

The restructuring of smtpd(8)'s process management resulted in the match/action grammar now used in smtpd.conf(5). "Relay via" is now a choice of options to the relay delivery method which is selected via an action. Rewriting is supported through mail filtering, as J65nko noted. See the MAIL FILTERING section of an up-to-date smtpd.conf(5).
Reply With Quote
  #7   (View Single Post)  
Old 27th May 2021
discostew discostew is offline
Port Guard
 
Join Date: May 2021
Posts: 14
Default

Thank you both J65nko and jggimi! I will upgrade this machine, convert to the new smtpd.conf, and try out the new mail filtering syntax.

Thank you again!
Reply With Quote
  #8   (View Single Post)  
Old 27th May 2021
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,182
Default

Going from 6.1 to 6.9 means 8 upgrades. A lot of work, but for many Asians the number '8' brings good luck ;-)

Wouldn't be easier to do a fresh install of 6.9 on another VPS?. You then can test and play around with the filter/rewrite stuff and when that works, move the data, mailboxes etc from the existing 6.1 system to the new 6.9.
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote
  #9   (View Single Post)  
Old 3rd June 2021
discostew discostew is offline
Port Guard
 
Join Date: May 2021
Posts: 14
Default

Thank you J65nko - I will start from a fresh install, do some testing, and migrate my configuration over once everything looks good. I agree 8 upgrades does seem like an arduous / time consuming task
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with httpd rewrite rule notooth OpenBSD Packages and Ports 2 15th September 2019 08:42 PM
OpenSMTPd will be the default Mail Transfer Agent in OpenBSD 5.6 jggimi OpenBSD General 5 17th March 2014 04:09 PM
OpenSMTPD incoming mail server gpatrick OpenBSD General 2 9th August 2011 10:19 AM
Virtual domains on multiple mail servers running Exim4 as MTA satimis General software and network 10 27th November 2008 02:42 PM
fdisk -B does not rewrite the mbr kasse NetBSD General 0 25th November 2008 11:07 PM


All times are GMT. The time now is 07:40 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick