0

I've got a server on my LAN runnnig exim4 configured to use a smarthost on the WAN like this:

disable_ipv6='true'
dc_eximconfig_configtype='smarthost'
dc_other_hostnames='hostname.mydomain.com'
dc_local_interfaces='127.0.0.1'
dc_readhost='mydomain.com'
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost='smtp.mydomain.com::587'
CFILEMODE='644'
dc_use_split_config='true'
dc_hide_mailname='true'
dc_mailname_in_oh='true'
dc_localdelivery='mail_spool

If I do a hostname -f on this server, I get hostname.mydomain.com. "hostname" isn't in the public DNS for mydomain.com though.

If I send out a test mail using swaks:

swaks --tls --auth --to me@mydomain.com --server smtp.mydomain.com:587

it sends out as username@hostname.mydomain.com, and smtp.mydomain.com says:

<~  235 2.7.0 Authentication successful
 ~> MAIL FROM:<username@hostname.mydomain.com>
<~  250 2.1.0 Ok
 ~> RCPT TO:<me@mydomain.com>
<~* 450 4.1.8 <username@hostname.mydomain.com>: Sender address rejected: Domain not found
 ~> QUIT
<~  221 2.0.0 Bye

But if I try --from username@mydomain.com then it's fine.

Oddly though, if I try using bsd-mailx to send a mail:

mail me@mydomain.com

smtp.mydomain.com rejects it with a different error:

Recipient address rejected: Access denied

I'm not sure what part of the chain is causing the problem. It would seem the easiest fix is to make sure mail is being sent from @mydomain.com rather than @hostname.mydomain.com*, since that's what all other mail clients sending out to that smarthost are doing (on the same domain as the server in question too) - but how?

*Although the recipient address rejected error is weird

TommyPeanuts
  • 472
  • 1
  • 7
  • 24
  • Look like the smarthost need some configuration too. At least it must know to be used as smarthost. – Kondybas Nov 26 '17 at 10:04
  • It's working OK for other mail clients on other networks sending out through it via TLS though. – TommyPeanuts Nov 26 '17 at 10:10
  • BTW I'm using the same smarthost to send out emails from the same LAN using an email address on the same domain as the host in question here. The issue seems to be that while in that case I'm sending out as @mydomain.com, if I send as @hostname.mydomain.com it rejects it. So how do I get the host to send mail from mydomain.com and not hostname.mydomain.com? – TommyPeanuts Nov 26 '17 at 10:18
  • For now, I've found that if I send out via smtp.gmail.com then it all works. I don't mind that Gmail will present the From address to the recipient as a Gmail address, since I'm the recipient in any case. – TommyPeanuts Nov 26 '17 at 16:18

1 Answers1

1

The missing piece here is that Exim has an address rewrite table:

/etc/email-addresses

This file allows you to specify which email addresses you want each user on the system to use in their From: header, otherwise Exim will use the fqdn of the host as the domain (the part following the @), which was causing my smarthost to reject them.

So I added the following lines to the file:

root: username@mydomain.com
username: username@mydomain.com

I also made dc_other_hostnames blank, and dc_hide_mailname='false' so my Exim config looked like this:

disable_ipv6='true'
dc_eximconfig_configtype='smarthost'
dc_other_hostnames=''
dc_local_interfaces='127.0.0.1'
dc_readhost='mydomain.com'
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost='smtp.mydomain::587'
CFILEMODE='644'
dc_use_split_config='true'
dc_hide_mailname='false'
dc_mailname_in_oh='true'
dc_localdelivery='mail_spool'

Also note that where DNS/PTR records resolve to different host names for the smarthost (as in my case), you should put a line in your /ext/exim/passwd.client for each one since Exim may be using the canonical one.

I then ran update-exim4.conf, and restarted Exim.

TommyPeanuts
  • 472
  • 1
  • 7
  • 24