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:
When I contacted the shared hosting company to find out why it failed, they told me:
The code I am using (which was working):
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).
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 ?
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:
It looks like the outgoing spam filter is blocking the outgoing email.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
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):
B4X:
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"
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 ?