Problem with second server

Use this forum if you have installed hMailServer and want to ask a question related to a production release of hMailServer. Before posting, please read the troubleshooting guide. A large part of all reported issues are already described in detail here.
Post Reply
csepulveda
New user
New user
Posts: 2
Joined: 2020-01-27 07:56

Problem with second server

Post by csepulveda » 2020-01-27 08:12

Hi everyone, i broke my head trying to do this I have two servers for same domain and different accounts.
Sample:
Server IP1: account1@domain.com
Server IP2: account2@domain.com

Main DNS MX record to Server IP1
Server IP2 use SMTP relay to Server IP1

Server IP1 define SMTP route to IP2 and address account2@domain.com
Server IP2 defint SMTP route to IP1 with all address

I can send emails from account1@domain.com to account2@domain.com
I can send emails from account2 to account1
I can send emails from (account1, account2) to gmail
I can send emails from gmail to account1
but I CANNOT send emails from gmail to account2 or CC to account2.... just it lost in limbo

The goal is administer differents account in differents servers for same domain.
Thank you very much for reading

palinka
Senior user
Senior user
Posts: 1717
Joined: 2017-09-12 17:57

Re: Problem with second server

Post by palinka » 2020-01-27 13:38

This is a guess, but give it a try.

Create catch-all@domain.com on server 1.

Create route on server 1 that points to server 2 - route should have catch-all as the only address for delivery.

If that doesn't work, then add a global rule IF to catch-all THEN use route.

Obviously this won't work if server 2 users have accounts on server 1.

User avatar
SorenR
Senior user
Senior user
Posts: 3402
Joined: 2006-08-21 15:38
Location: Denmark

Re: Problem with second server

Post by SorenR » 2020-01-27 16:06

The theoretical setup is as follows:

MX "axme.inc" -> Server 1

Server 1 domain: "acme.inc"
Account 1: "road.runner@acme.inc"
Account 2: "daffy.duck@acme.inc"
Route "acme.inc" -> Server 2

Server 2 domain: "acme.inc"
Account 1: "wile.e.cyote@acme.inc"
Account 2: "elmer.fudd@acme.inc"
Incoming relays: Server 1

The rationale is that Server 1 will handle locally matched accounts and pass everything else on to Server 2. If configured, a catch-all account should exist on Server 2 ONLY!.

Local clients MUST use Server 1 as SMTP host as there is NO reverse path from Server 2 to Server 1.
One CAN create a "Return Route" but it will create a circular dependency that only a script can break.
SørenR.

“With age comes wisdom, but sometimes age comes alone.”
- Oscar Wilde

csepulveda
New user
New user
Posts: 2
Joined: 2020-01-27 07:56

Re: Problem with second server

Post by csepulveda » 2020-01-27 20:05

Thanks for your answers... after some tests.

I need create routes on both servers, because I cannot send messages from one to other. If local users of Server 2 use Server 1 as SMTP, need authentication.

I was thinking about to create a script to review messages on Server 1 and evaluate if has recipients of Server 2 and send to it.



Sub OnDeliveryStart(oMessage)
For j = 0 To oMessage.Recipients.Count -1
If LCase(oMessage.Recipients(j).Address) = "accountserver2@domain.com" Then

'Send to Server 2 (how?)

End If
Next
End Sub

User avatar
SorenR
Senior user
Senior user
Posts: 3402
Joined: 2006-08-21 15:38
Location: Denmark

Re: Problem with second server

Post by SorenR » 2020-01-27 22:11

csepulveda wrote:
2020-01-27 20:05
Thanks for your answers... after some tests.

I need create routes on both servers, because I cannot send messages from one to other. If local users of Server 2 use Server 1 as SMTP, need authentication.

I was thinking about to create a script to review messages on Server 1 and evaluate if has recipients of Server 2 and send to it.



Sub OnDeliveryStart(oMessage)
For j = 0 To oMessage.Recipients.Count -1
If LCase(oMessage.Recipients(j).Address) = "accountserver2@domain.com" Then

'Send to Server 2 (how?)

End If
Next
End Sub
You can do this with "global" rules. I have not tried it but you may have to play with the X-hMailServer-LoopCount numbers. X-hMailServer-LoopCount is an internal header hMailServer will set and increment for every time the email is forwarded. I am not sure if it is affected by Route's.

Server 1:
Create a global rule (AND) "1: Check"
Criteria:
- Custom header field "X-hMailServer-LoopCount" Less than 1
- Custom header field "X-FirstServer" Contains "YES"
- Custom header field "X-SecondServer" Contains "YES"
Action:
- Forward email "postmaster@..." <=== CHANGE THIS!!
- Delete e-mail

Create a global rule (AND) "2: Set FLAG"
Criteria:
- Custom header field "X-hMailServer-LoopCount" Less than 1
Action:
- Set header field "X-FirstServer" = "YES"

Server 2:
Create a global rule (AND) "1: Check"
Criteria:
- Custom header field "X-hMailServer-LoopCount" Less than 1
- Custom header field "X-FirstServer" Contains "YES"
- Custom header field "X-SecondServer" Contains "YES"
Action:
- Forward email "postmaster@..." <=== CHANGE THIS!!
- Delete e-mail

Create a global rule (AND) "2: Set FLAG"
Criteria:
- Custom header field "X-hMailServer-LoopCount" Less than 1
Action:
- Set header field "X-SecondServer" = "YES"
SørenR.

“With age comes wisdom, but sometimes age comes alone.”
- Oscar Wilde

Post Reply