Page 1 of 1

Rule That Applies to Outbound Messages Only

Posted: 2020-12-15 20:52
by mikedibella
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?

Re: Rule That Applies to Outbound Messages Only

Posted: 2020-12-16 00:57
by palinka
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.

Re: Rule That Applies to Outbound Messages Only

Posted: 2020-12-16 01:46
by SorenR
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

Re: Rule That Applies to Outbound Messages Only

Posted: 2020-12-16 02:04
by mikedibella
SorenR wrote:
2020-12-16 01:46
- Search type -> Regular expression -> "(?i:^.*(ESMTPSA|ESMTPA).*$)"
Clever. I prefer this approach to adding a custom header in OnAcceptMessage. I will give it a try. TYVM all.

Re: Rule That Applies to Outbound Messages Only

Posted: 2020-12-16 02:24
by SorenR
mikedibella wrote:
2020-12-16 02:04
SorenR wrote:
2020-12-16 01:46
- Search type -> Regular expression -> "(?i:^.*(ESMTPSA|ESMTPA).*$)"
Clever. I prefer this approach to adding a custom header in OnAcceptMessage. I will give it a try. TYVM all.
I use it here..

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
This is now anonymous -> Received: 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

:mrgreen: