Score:1

OpenSMTPD multiple outgoing server hostnames

kw flag

I'm running OpenSMTPD to receive and send e-mails on FreeBSD. I'm accepting e-mails on a multiple different top-level domains and also send out from multiple different top-level domains (hosting different services on the same server). Now, when my applications send out e-mails then outgoing server hostname will be set correctly since application e-mail library usually sets hostname based on the from parameter value (so for example if from is specified as [email protected] then outgoing e-mail will have example.org as it's hostname).

Now, however when system tries to send out e-mails (or sending out via sendmail under non-privileged user) then server hostname will be used as a hostname. This however, is not correct (not even a real-life domain name) and does not work with DKIM signing.

I can see this under /var/log/maillog where there are errors similar to these:

Jul 30 14:41:38 myserver smtpd[79549]: 0000000000000000 mta delivery evpid=755a2abf780a7383 from=<root@myserver> to=<root@myserver> rcpt=<-> source="-" relay="myserver" delay=2d10h46m40s result="TempFail" stat="No MX found for domain"

Where myserver is the server hostname value. to here is not that important since I should be able to add myserver into /etc/mail/domains and use that in smtpd.conf, however I would like to control from depending on the user sending e-mail. So for example, when non-privileged user john sends e-mail then it would be set as [email protected] automatically.

Is there a way to specify via OpenSMTPD configuration somehow how would the outgoing server hostname be determined based on the from field?

Score:0
fr flag

If I understand you correctly, you are trying to control based upon who the username is. Right? How are you controlling which domain name is used? As-in, which domain is actually used by smtpd in particular to send out from the correct IP address for just that domain and not for a different one you are also supporting?

That is the problem I am having, I can't figure out how to force OpenSMTPD to send from the correct IP address that matches whichever domain is being sent from. Not the username, like john versus mary, but the domain name like example.com example.org.

I have that question open right now on the [email protected] mailing list. This would be a superb time if you want to ask your question over there. If you want to temporarily just [email protected], add your question either to my question or add a new thread. If you don't want to post over there directly, clarify your question a bit better and I will forward it onto the list for you.

Jarmo Pertman avatar
kw flag
Basically, I wanted to use hostname from the "from" header. Problem happened only when using `sendmail` command where under non-privileged user I can't set the from field and it will be `user@host` automatically. However, I would have liked to set it automatically to a specific host for each freebsd user. Basically if john is sending e-mail then from would be `john@foobar` instead of `john@host` where `foobar` would be somehow configured for opensmtpd. In the end it's not a big problem for me anymore since I do set `from` accordingly in the code and I'm not using `sendmail` command.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.