Processing Incoming Read Receipts
Processing Incoming Read Receipts
Is there a way to find that whether the email is a "Read Receipt" of the mail sent and not an Email?
so as a custom Header can be sent to it "X-Hmailserver-ReadReceipt" via Script.
TIA
GP
so as a custom Header can be sent to it "X-Hmailserver-ReadReceipt" via Script.
TIA
GP
Re: Processing Incoming Read Receipts
have you tried checking Content-Type header?
it contains ...report-type=disposition-notification...
and ...delivery-status... for DSNs
it contains ...report-type=disposition-notification...
and ...delivery-status... for DSNs
Katip
--
HMS 5.7, MariaDB 10.4.10, SA 4.0.0, ClamAV 0.103.8
--
HMS 5.7, MariaDB 10.4.10, SA 4.0.0, ClamAV 0.103.8
Re: Processing Incoming Read Receipts
Thanks for the tip. Found them as below
READ RECEIPTS
EMAILS
Now is this GLOBAL rule right?
IF (USE AND)
Custom Header field: Content-Type
Contains: report-type=disposition-notification
THEN
Run Script: My processing plan
READ RECEIPTS
Code: Select all
Content-Type: multipart/mixed;
report-type=disposition-notification;
boundary="----=_NextPart_000_001C_01D77E1B.8A0ACF60"
Content-Type: multipart/mixed;
boundary="_000_CWXP265MB4570857051E368A1F4FF04DB9DE19CWXP265MB4570GBRP_";
report-type=disposition-notification
Content-Type: multipart/mixed;
boundary="----=_NextPart_000_001E_01D77BE4.A5B39A50";
report-type=disposition-notification
EMAILS
Code: Select all
Content-Type: multipart/mixed; boundary="000000000000397b9905c78afd89"
Content-Type: multipart/related; boundary="00000000000045677305c735d933"
Content-Type: multipart/alternative; boundary="----=_NextPart_000_000F_01D775B4.F2F82230"
Content-Type: multipart/alternative; boundary="----=_Part_1043721_120166650.1622528055318"
Content-Type: multipart/mixed;
boundary="----=_NextPart_000_0033_01D7820B.94097D60"
Content-Type: multipart/related;
boundary="----=_NextPart_000_0015_01D78135.A018F940"
IF (USE AND)
Custom Header field: Content-Type
Contains: report-type=disposition-notification
THEN
Run Script: My processing plan
Re: Processing Incoming Read Receipts
looks good. give it a try
Katip
--
HMS 5.7, MariaDB 10.4.10, SA 4.0.0, ClamAV 0.103.8
--
HMS 5.7, MariaDB 10.4.10, SA 4.0.0, ClamAV 0.103.8
Re: Processing Incoming Read Receipts
You cannot use a rule for that other than to launch a script...
Rule will look for first instance of string (top down) and use that. You need to process message line by line.
Something like this:
Rule will look for first instance of string (top down) and use that. You need to process message line by line.
Something like this:
Code: Select all
For i = 0 To oMessage.Headers.Count-1
If (oMessage.Headers(i).Name = "Content-Type") Then
....
If InStr(1, oMessage.Headers(i).Value, "disposition-notification", 1) > 0 Then
....
Do Stuff
....
Exit For ' Found it, no need to look further.
End If
....
End If
Next
SørenR.
Woke is Marxism advancing through Maoist cultural revolution.
Woke is Marxism advancing through Maoist cultural revolution.
Re: Processing Incoming Read Receipts
SorenR wrote: ↑2021-07-26 11:36You cannot use a rule for that other than to launch a script...
Rule will look for first instance of string (top down) and use that. You need to process message line by line.
Something like this:
Code: Select all
For i = 0 To oMessage.Headers.Count-1 If (oMessage.Headers(i).Name = "Content-Type") Then .... If InStr(1, oMessage.Headers(i).Value, "disposition-notification", 1) > 0 Then .... Do Stuff .... Exit For ' Found it, no need to look further. End If .... End If Next
MY actual Intention is that if it is a read receipt or DSN then I don't want to apply the rule "External Email", (this rule appends a Header to email originating from outside the organization.
Re: Processing Incoming Read Receipts
do you mean a Read Receipt may contain multiple Content-Type headers?
just checked 20 recent, received from different sources. all with unique Content-Type header.
i use similar rule and don't remember to have missed any of them.
but who knows, we see something new every day..
Katip
--
HMS 5.7, MariaDB 10.4.10, SA 4.0.0, ClamAV 0.103.8
--
HMS 5.7, MariaDB 10.4.10, SA 4.0.0, ClamAV 0.103.8
Re: Processing Incoming Read Receipts
I use the same logic to process every message arriving either direct or via my BackupMX to extract the original sender IP and greeting...
I need the IP address of the original sender to check if a banned server send to me via my BackupMX and the EHLO greeting to verify it is RFC compliant.
I need the IP address of the original sender to check if a banned server send to me via my BackupMX and the EHLO greeting to verify it is RFC compliant.
Code: Select all
Function setEnvelope(oClient, oMessage)
Dim i, a, strTo, strOriginalTo, strIP, strRegEx, oMatch, oMatchCollection
If Lookup("from " & BACKUPMX, oMessage.HeaderValue("Received")) Then
'
' Received from BackupMX ?
'
For i = 0 To oMessage.Headers.Count-1
'
' Process all "Received" headers
'
If (oMessage.Headers(i).Name = "Received") Then
If Lookup("by " & BACKUPMX & " with", oMessage.Headers(i).Value) Then
'
' Received from BackupMX !
'
a = Split( oMessage.Headers(i).Value, " " )
oMessage.HeaderValue("X-Envelope-HELO") = Trim(a(1))
strRegEx = "(?:\[)((?:[0-9]{1,3}\.){3}[0-9]{1,3})(?:\])"
Set oMatchCollection = oLookup(strRegEx, oMessage.Headers(i).Value, False)
For Each oMatch In oMatchCollection
If oMatch.SubMatches.Count > 0 Then
oMessage.HeaderValue("X-Envelope-IP") = oMatch.SubMatches(0)
Else
'
' Oops, something went wrong ...
'
oMessage.HeaderValue("X-Envelope-IP") = ""
End If
Next
'
' Mission accomplished !
'
Exit For
'
' No dice - NEXT
'
End If
End If
Next
Else
'
' Nope, delivered directly
'
oMessage.HeaderValue("X-Envelope-HELO") = Trim(oClient.HELO)
oMessage.HeaderValue("X-Envelope-IP") = Trim(oClient.IPAddress)
End If
oMessage.Save
Set oMatch = Nothing
Set oMatchCollection = Nothing
End Function
SørenR.
Woke is Marxism advancing through Maoist cultural revolution.
Woke is Marxism advancing through Maoist cultural revolution.
Re: Processing Incoming Read Receipts
In theory it can contain multiple "Content-Type" headers. I have never investigated it.katip wrote: ↑2021-07-26 12:17do you mean a Read Receipt may contain multiple Content-Type headers?
just checked 20 recent, received from different sources. all with unique Content-Type header.
i use similar rule and don't remember to have missed any of them.
but who knows, we see something new every day..
In Theory There Is No Difference Between Theory and Practice, In Practice There Is
SørenR.
Woke is Marxism advancing through Maoist cultural revolution.
Woke is Marxism advancing through Maoist cultural revolution.
Re: Processing Incoming Read Receipts
OK, I have been tracking "Content-Type" on a couple of incoming emails.katip wrote: ↑2021-07-26 12:17do you mean a Read Receipt may contain multiple Content-Type headers?
just checked 20 recent, received from different sources. all with unique Content-Type header.
i use similar rule and don't remember to have missed any of them.
but who knows, we see something new every day..
This is one of the first things I do in OnAcceptMessage()
Code: Select all
'
' Testing "Content-Type"
'
EventLog.Write( "From: " & oMessage.From & " To: " & oMessage.To )
EventLog.Write( "Subject: " & oMessage.Subject )
For i = 0 To oMessage.Headers.Count-1
If oMessage.Headers(i).Name = "Content-Type" Then
EventLog.Write( "Content-Type: " & oMessage.Headers(i).Value )
End If
Next
EventLog.Write( "." )
Code: Select all
1912 "2021-07-26 14:28:06.583" "From: blabla@somewhere> To: unknown@nowhere"
1912 "2021-07-26 14:28:06.583" "Subject: Servicemeddelelse fra Gjensidige"
1912 "2021-07-26 14:28:06.583" "Content-Type: text/html; charset=UTF-8"
1912 "2021-07-26 14:28:06.583" "."
1544 "2021-07-26 15:04:46.488" "From: Lavinia Medium <lavinia@laviniaspoh.com> To: "
1544 "2021-07-26 15:04:46.488" "Subject: I have important information to transmit to you !"
1544 "2021-07-26 15:04:46.488" "Content-Type: text/html; charset=UTF-8"
1544 "2021-07-26 15:04:46.488" "."
1912 "2021-07-26 15:13:26.429" "From: Melitta Isabel <melisabelmo@outlook.com> To: "
1912 "2021-07-26 15:13:26.429" "Subject: Kan du se længslen i mine øjne?"
1912 "2021-07-26 15:13:26.429" "Content-Type: multipart/related; boundary="_005_BLAPR19MB4308497F35ED21DE83EF26B1AAE89BLAPR19MB4308namp_"; type="multipart/alternative""
1912 "2021-07-26 15:13:26.429" "."
3512 "2021-07-26 15:13:34.507" "From: Kathyrn Kletschka <kathyrnf6nyk@outlook.com> To: "
3512 "2021-07-26 15:13:34.507" "Subject: Kan du se længslen i mine øjne?"
3512 "2021-07-26 15:13:34.507" "Content-Type: multipart/related; boundary="_005_DM5PR16MB175551F1A718DA73C3826B1A83E89DM5PR16MB1755namp_"; type="multipart/alternative""
3512 "2021-07-26 15:13:34.507" "."
1912 "2021-07-26 15:36:05.937" "From: "Web Camera Pro" <sb@web-camera.pro> To: unknown@nowhere"
1912 "2021-07-26 15:36:05.937" "Subject: Web Camera Pro: Free software download link"
1912 "2021-07-26 15:36:05.937" "Content-Type: multipart/mixed; boundary="MW04MGx6LWxSYWRMYy1NbA==""
1912 "2021-07-26 15:36:05.937" "."
3512 "2021-07-26 15:36:43.813" "From: "Web Camera Pro" <sb@web-camera.pro> To: unknown@nowhere"
3512 "2021-07-26 15:36:43.813" "Subject: Web Camera Pro - Download link for SorenR"
3512 "2021-07-26 15:36:43.813" "Content-Type: multipart/mixed; boundary="MW04MG1mLVBDOEVEYy1NbA==""
3512 "2021-07-26 15:36:43.813" "."
So I guess you are correct in assuming the first occurance is sufficient.
SørenR.
Woke is Marxism advancing through Maoist cultural revolution.
Woke is Marxism advancing through Maoist cultural revolution.
Re: Processing Incoming Read Receipts
ok, alles klar.
now this made me recall something different. do your remember this : viewtopic.php?f=10&t=36903#p231060
mattg made a remark:
in my cases (today twice again) it's always the same sender site, exactly with this symptom. isn't <... blah>CRLF + CRLF<blah...> illegal in headers? if so how does HMS react in such case?the .tmp has some CRLFs that are changed to spaces in the main file as currently saved in the data directory (domain / account path)
if you mean this is something worth to investigate, i'll open a topic with full source of one of that .tmp file. this is something still unresolved.
Katip
--
HMS 5.7, MariaDB 10.4.10, SA 4.0.0, ClamAV 0.103.8
--
HMS 5.7, MariaDB 10.4.10, SA 4.0.0, ClamAV 0.103.8
Re: Processing Incoming Read Receipts
RFC 2047
Section 8 ...
Bottom page 12
Section 8 ...
Bottom page 12
Code: Select all
encoded form displayed as
---------------------------------------------------------------------
(=?ISO-8859-1?Q?a?=) (a)
(=?ISO-8859-1?Q?a?= b) (a b)
Within a 'comment', white space MUST appear between an
'encoded-word' and surrounding text. [Section 5,
paragraph (2)]. However, white space is not needed between
the initial "(" that begins the 'comment', and the
'encoded-word'.
(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=) (ab)
White space between adjacent 'encoded-word's is not
displayed.
(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=) (ab)
Even multiple SPACEs between 'encoded-word's are ignored
for the purpose of display.
(=?ISO-8859-1?Q?a?= (ab)
=?ISO-8859-1?Q?b?=)
Any amount of linear-space-white between 'encoded-word's,
even if it includes a CRLF followed by one or more SPACEs,
is ignored for the purposes of display.
(=?ISO-8859-1?Q?a_b?=) (a b)
In order to cause a SPACE to be displayed within a portion
of encoded text, the SPACE MUST be encoded as part of the
'encoded-word'.
(=?ISO-8859-1?Q?a?= =?ISO-8859-2?Q?_b?=) (a b)
In order to cause a SPACE to be displayed between two strings
of encoded text, the SPACE MAY be encoded as part of one of
the 'encoded-word's.
Ehm... The MIME translated message SHOULD exclude CRLF and SPACE'es in hMailServer.Any amount of linear-space-white between 'encoded-word's,
even if it includes a CRLF followed by one or more SPACEs,
is ignored for the purposes of display.
SørenR.
Woke is Marxism advancing through Maoist cultural revolution.
Woke is Marxism advancing through Maoist cultural revolution.
Re: Processing Incoming Read Receipts
This is what I did
Created a Global rule
IF
Content-Type:
Contains
report-type=disposition-notification
THEN
Set header Value
X-hmailserver-ReadReceipt
YES
and it is working as of now.
And regarding the Function Setenvelope()
I tried implementation as is and called it first thing in Sub onacceptmessage.
It works BUT FOR OUTGOING MAILS (I sent mail from Hmail to outside and verified)
How to implement it to work On the INCOMING MAIL.
shall I call the function in Sub onexternaldownload ??
Created a Global rule
IF
Content-Type:
Contains
report-type=disposition-notification
THEN
Set header Value
X-hmailserver-ReadReceipt
YES
and it is working as of now.
And regarding the Function Setenvelope()
I tried implementation as is and called it first thing in Sub onacceptmessage.
It works BUT FOR OUTGOING MAILS (I sent mail from Hmail to outside and verified)
How to implement it to work On the INCOMING MAIL.
shall I call the function in Sub onexternaldownload ??
Re: Processing Incoming Read Receipts
Global rule
If recipient includes *@example.com
AND
rest of your global rule
With action to run function
If recipient includes *@example.com
AND
rest of your global rule
With action to run function
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation
https://www.hmailserver.com/documentation