B4J Question SMTP - Rejected by outbound spam filtering


Well-Known Member
Licensed User
Longtime User

My B4J non-UI app will send emails from the B4J app (which is hosted on a VPS) and it uses my shared hosting providers SMTP server from cPanel.

Everything was working fine until the past few days. I can send emails from the RoundedCube Webmail and the email gets sent and delivered fine.

In cPanel's Delivery Report it shows the result as:
ECDHE-RSA-AES256-GCM-SHA384:256 CV=no: SMTP error from remote mail server after end of data: 550 5.7.1 Rejected by outbound spam filtering E005
It looks like the outgoing spam filter is blocking the outgoing email.

When I contacted the shared hosting company to find out why it failed, they told me:
Taking a look at this one I can see those emails are being rejected as the SpamAssassin score is higher than the spam threshold, these emails are receiving a score of 6.3, the spam threshold is 5.0.

The 3 biggest contributors to the high spam score are the following:

MISSING_DATE - Missing Date: header
MISSING_MID - Missing Message-Id: header
TO_NO_BRKTS_FROM_MSSP - Multiple header formatting problems

You will need to look at adjusting the way these emails are sent from your software, they are being rejected because they are poorly formed emails.

The code I am using (which was working):

    Dim smtpPort As Int = 465
    Dim smtpServer As String = "mail.mysite.net"
    Dim user As String = "[email protected]"
    Dim Password As String = "xxxxxxxxx"
    SMTP.Initialize(smtpServer, smtpPort, user, Password, "smtp")   
    SMTP.UseSSL = True
    SMTP.To.Add("[email protected]")
    SMTP.Sender = "MyName" & "<" & "[email protected]" & ">"
    SMTP.HtmlBody = True
    SMTP.Body = "this is a test message"
    SMTP.Subject = "test"
    wait for SMTP_MessageSent(Success As Boolean)
    If Success Then
        Log("eMail Sent OK")   
        Log("eMail Failed to send")
    End If

Looking at the B4J IDE logs, it shows the email got sent successfully.

However, in cPanel Delivery Report it shows it got blocked.

From searching the forum, I think I worked out how to add the additional headers (as below).

DateTime.DateFormat="EEE, dd MMM yyyy HH:mm:ss Z"
    Dim datevalue As String =DateTime.Date(DateTime.now)

    Dim M As Map
    M.Put("Message-Id", Rnd(1,99999999999))
    M.Put("Date", datevalue)
    SMTP.AdditionalHeaders = M

The email does send by adding the above code, but not sure if the Message-Id is correct, or if I should be doing it differently?
I also don't know if I need to add any other additional headers to the code ?


Licensed User
Longtime User
Upvote 0