B4J Question [SOLVED]BAD Header for SMTP when running on a Server app

Peter Lewis

Active Member
Licensed User
Longtime User
Hi All

I am get this error on the server when running a simple SMTP function. I have tried port 465 and SSL , then HTML and now Plain Text Port 25.

Waiting for debugger to connect...
Program started.
Mail Sent Started
java.lang.RuntimeException: Empty writer returned: 554 5.5.1 Error: no valid recipients
at anywheresoftware.b4a.net.SMTPWrapper$1.run(SMTPWrapper.java:312)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)

this is the Code

        Dim smtp As SMTP
        smtp.HtmlBody = False
        smtp.UseSSL = False
        smtp.Body ="Started"
        smtp.Subject = "Started"
        Log("Mail Sent "&"Started")
    End Try

At one stage I also got an bounced email back to the address saying this

The message WAS NOT relayed to:


554 5.6.0 bounce, id=00725-02 - bad header

This nondelivery report was generated by the program amavisd-new at host server1.praxos-hosting.co.za. Our internal reference code for your message is 00725-02/ohtYiguqgrEI


Missing required header field: "Date"

Return-Path: <c****e@***s.co.za> (OK)

From: "Microsoft Outlook" <****@j****s.co.za> (dkim:AUTHOR)

Sender: "Microsoft Outlook" <c*****e@****.co.za> (dkim:SENDER)

Subject: Microsoft Outlook Test Message

on investigation I came across this article

Re: Error 554 5.6.0 with bad header​

Please add below lines in Amavisd config file, restart Amavisd service and try again:

# Selectively disable some of the header checks
# Duplicate or multiple occurrence of a header field
$allowed_header_tests{'multiple'} = 0;

# Missing some headers. e.g. 'Date:'
$allowed_header_tests{'missing'} = 0;
It's part of iRedMail-0.9.3, and it's enabled by default.
This I tried as I am in control of the full path including the mail server.

So now I am out of ideas. Has anyone had problems like this before.

I tried using the code in the background worker, Handler and in desperation evening in the server startup APPSTART

I have sent emails to the email address and it works and Also copied the Email address and password from my mail server and PASTED it .