Send E-mails from another server?

jdn1976

Verified User
Joined
Mar 30, 2020
Messages
105
Hello, I have a doubt about configure to sending e-mails. I have two servers. The servers are not on the same datacenter.
I want the main server where I host the account, only to host but I want to use another dedicated server only to send e-mail.
Is it possible configure the main server (hosting), to send e-mail from another IP on another server?

I am using DirectAdmin to host the accounts.

Is there any kind of tutorial?

Thank you!
 

mxroute

Verified User
Joined
Sep 24, 2019
Messages
67
It's possible, but if you're talking about two DirectAdmin servers then you're going to need to use custom config that will be replaced on exim updates, unless you authenticate as an SMTP user on the second server when sending from the first (it wouldn't change your From header so it might look fine).

The easiest way would probably be the second way that I mentioned, authenticating as a user on your second server. So if you made an email account on Server 2, let's call it "relay@myotherdomain.com" with password "123456" for this example. Let's also assume for this example that Server 2 is named server2.myotherdomain.com. You could then do this on Server 1:

In /etc/exim.routers.pre.conf:

Code:
smart_route:
  driver = manualroute
  domains = ! +local_domains
  ignore_target_hosts = 127.0.0.0/8
  condition = "${perl{check_limits}}"
  transport = auth_relay
  route_list = * server2.myotherdomain.com::25
  no_more
In /etc/exim.transports.pre.conf:

Code:
auth_relay:
  driver = smtp
  hosts_require_auth = server2.myotherdomain.com
  tls_tempfail_tryclear = true
  headers_add = X-AuthUser: ${if match {$authenticated_id}{.*@.*}\
  {$authenticated_id} {${if match {$authenticated_id}{.+}\
  {$authenticated_id@$primary_hostname}{$authenticated_id}}}}
  headers_remove = Received
  dkim_domain = ${if eq{${lc:${domain:$h_from:}}}{}{$primary_hostname}{${lookup{${lc:${domain:$h_from:}}}lsearch,ret=key{/etc/virtual/domainowners}{$value}}}}
  dkim_selector = x
  dkim_private_key = ${if exists{/etc/virtual/$dkim_domain/dkim.private.key}{/etc/virtual/$dkim_domain/dkim.private.key}{0}}
  dkim_canon = relaxed
  dkim_strict = 0
In /etc/exim.authenticators.post.conf:

Code:
auth_login:
  driver = plaintext
  public_name = LOGIN
  hide client_send = : relay@myotherdomain.com : 123456
Then restart exim and see what happens.
 
Top