My hMailServer is a primarily a bridgehead. I have a series of Routes defined for inbound domains, and I use a smart relay for outbound messages.
I have some use cases where I'd like to send outbound email though an alternate smart relay, and I've defined a Route to configure the target host parameters for that relay.
I'd like to use a Global Rule with a Send via Route Action to select the messages to be processed though this outbound Route, but I'm concerned that the Rule Criteria will include some messages that are inbound and I still want those messages to be handled by domain-based (as opposed to Rule-based) Routes.
All incoming mail arrives on port 25 unauthenticated and all outgoing mail arrives on port 587 and is authenticated.
Any ideas how I can use Rule Condition to positively identify outbound mail?
Rule That Applies to Outbound Messages Only
-
- Senior user
- Posts: 435
- Joined: 2016-12-08 02:21
Re: Rule That Applies to Outbound Messages Only
A shot in the dark:
Add a header value when user is authenticated AND on port 587, then make your rule check the header for header.
Add a header value when user is authenticated AND on port 587, then make your rule check the header for header.
Re: Rule That Applies to Outbound Messages Only
Hmmm.... I presume only clients authenticate on this server.
Criteria:
Custom header field -> "Received"
- Search type -> Regular expression -> "(?i:^.*(ESMTPSA|ESMTPA).*$)"
AND
Predefined field -> "To"
- Search type -> Contains -> "Santa"
Action:
Send using route -> "Northpole"
Note:
Referencing the "Received:" header will ALLWAYS point to the topmost "Received:" header in the raw email.
ESMTPSA = Extended SMTP SSL/TLS Authenticated
ESMTPA = Extended SMTP Authenticated
Criteria:
Custom header field -> "Received"
- Search type -> Regular expression -> "(?i:^.*(ESMTPSA|ESMTPA).*$)"
AND
Predefined field -> "To"
- Search type -> Contains -> "Santa"
Action:
Send using route -> "Northpole"
Note:
Referencing the "Received:" header will ALLWAYS point to the topmost "Received:" header in the raw email.
ESMTPSA = Extended SMTP SSL/TLS Authenticated
ESMTPA = Extended SMTP Authenticated
SørenR.
Algorithm (noun.)
Word used by programmers when they do not want to explain what they did.
Algorithm (noun.)
Word used by programmers when they do not want to explain what they did.
-
- Senior user
- Posts: 435
- Joined: 2016-12-08 02:21
Re: Rule That Applies to Outbound Messages Only
I use it here..mikedibella wrote: ↑2020-12-16 02:04Clever. I prefer this approach to adding a custom header in OnAcceptMessage. I will give it a try. TYVM all.
Code: Select all
Sub OnDeliveryStart(oMessage)
'Local: Received: from computer.genious (sorens_acer [192.168.0.61]) by mx.acme.inc with ESMTPSA (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256) ; Mon, 16 Nov 2020 21:24:26 +0100
'Remote: Received: from 66-220-155-155.mail-mail.facebook.com (66-220-155-155.mail-mail.facebook.com [66.220.155.155]) by mx.lolle.org with ESMTPS (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256) ; Thu, 13 Aug 2020 21:46:29 +0200
Dim strReceived
strReceived = oMessage.HeaderValue("Received")
If InStr(strReceived, "ESMTPSA") or InStr(strReceived, "ESMTPA") Then
oMessage.HeaderValue("Received") = Mid(strReceived, InStr(strReceived, "by "))
oMessage.Save
End If
End Sub

SørenR.
Algorithm (noun.)
Word used by programmers when they do not want to explain what they did.
Algorithm (noun.)
Word used by programmers when they do not want to explain what they did.