How to config standard SMTP Smarthost with auth for outgoing mail?

Here’s what I ended up doing, to make it a little more generic rather than specific to one relay service:

Edit /etc/exim4/exim4.conf.template

(1) At top, after the spam and clamd macros, add the following macros, changing the values to your relay service details:

SMARTHOST_ADDR = your.relay.service.com
SMARTHOST_PORT = 587
SMARTHOST_USER = yourusername
SMARTHOST_PASS = yourpassword

(2) Under “begin authenticators” add the following (order doesn’t matter):

.ifdef SMARTHOST_ADDR
smarthost_login:                            
  driver = plaintext                    
  public_name = LOGIN           
  client_send =:SMARTHOST_USER:SMARTHOST_PASS
.endif                                                                                                                                      

(3) Under “begin routers” add the following lines before the “dnslookup” router (order matters in the routers section):

.ifdef SMARTHOST_ADDR
smarthost:
  driver = manualroute
  domains = ! +local_domains
  transport = smarthost_smtp
  route_list = * SMARTHOST_ADDR
  no_verify
  no_more
.endif

(4) Under “begin transports” add the following (order doesn’t matter):

.ifdef SMARTHOST_ADDR
smarthost_smtp:
  driver = smtp
  .ifdef SMARTHOST_PORT
  port = SMARTHOST_PORT
  .endif
  hosts_require_auth = *
  hosts_require_tls = *
.endif

(5) Restart exim

Here’s another question:
The exim documentation says to use either the smarthost router or the dnslookup router, for non-local email. If that is the case, should the “redirect_router = dnslookup” lines within the “aliases” and “catchall” routers be changed to the following?

  .ifdef SMARTHOST_ADDR
  redirect_router = smarthost
  .else
  redirect_router = dnslookup
  .endif

Thanks
–Dan

4 Likes