Clicky

20200208

hMailserver: reject emails that have long subjects

Some people paste long strings in the Subject field of emails. The maximum number of characters of the Subject field is 998 characters but can be tweaked to more. It does not make sense to have more than ~160 characters so lets reject messages that have long Subject fields.

In hMailserver we can reject those emails very simply. In the OnSMTPData sub the Subject field is available and we can measure the amount of characters (length):

Sub OnSMTPData(oClient, oMessage)

    subjectLength = len(oMessage.Subject)


    if subjectLength > 160 then
        Eventlog.Write("OnAcceptMessage: email rejected because of Subject = " &  subjectLength & " characters (>160). From: " & oMessage.FromAddress)
        result.value=1
    end if

end sub

When a subject field of an email is longer than 160 characters, the event will be logged in the hMailserver logfile and the email will be rejected.

4144    "2020-02-08 09:02:37.138"    "OnAcceptMessage: email rejected because of Subject = 236 characters (>160). From: email@sender.com"

Also, the sender gets an email that the email is rejected:


Your message did not reach some or all of the intended recipients.

      Subject:     RE: 1234567890RE: 1234567890RE: 1234567890RE: 1234567890RE: 1234567890RE: 1234567890RE: 1234567890RE: 1234567890RE: 12345678901234567890
      Sent:  2/8/2020 9:03 AM

The following recipient(s) cannot be reached:

      Email Sender (email@sender.com) on 2/8/2020 9:03 AM
            554 Rejected

No comments :

Post a Comment

Real Time Web Analytics