B4J Question SMTP - Rejected by outbound spam filtering

aaronk

Well-Known Member
Licensed User
Longtime User
Hi,

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:

The code I am using (which was working):

B4X:
    Dim smtpPort As Int = 465
    Dim smtpServer As String = "mail.mysite.net"
    Dim user As String = "noreply@mysite.net"
    Dim Password As String = "xxxxxxxxx"
    SMTP.Initialize(smtpServer, smtpPort, user, Password, "smtp")   
    SMTP.UseSSL = True
    
    SMTP.To.Add("xxxxxx@gmail.com")
    SMTP.Sender = "MyName" & "<" & "noreply@mysite.net" & ">"
    SMTP.HtmlBody = True
    SMTP.Body = "this is a test message"
    SMTP.Subject = "test"
    SMTP.Send
    
    wait for SMTP_MessageSent(Success As Boolean)
    If Success Then
        Log("eMail Sent OK")   
    Else
        Log("eMail Failed to send")
        Log(LastException.Message)
    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).

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

    Dim M As Map
    M.Initialize
    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 ?
 

drgottjr

Expert
Licensed User
Longtime User
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…