B4J Question [SOLVED] [WebApp] SMTP working in debug but not on release

ziovec

Member
Licensed User
Hello there!
I noticed that during debug and local testing I'm able to send emails with smtp.
I tried just now with the release jar file over a VPS and everything is workin, except the smtp stuff.

Code snippet:

B4X:
Sub SendInfoMail  
    SMTP.Initialize(Main.settings.Get("smtp"), Main.settings.Get("port"), Main.settings.Get("account"), Main.settings.Get("pwd"), "SMTP")
    SMTP.UseSSL = True
    SMTP.To.Add(Main.settings.Get("infomail"))
    SMTP.Subject = $"WEBAPP - Nuovo ordine da ${ws.Session.GetAttribute("username")}"$
    SMTP.Sender.Replace(SMTP.Sender, "WEBAPP PELISSA")
    SMTP.HtmlBody = True
    SMTP.Body = $"Nuovo ordine inoltrato da <b>${ws.Session.GetAttribute("username")}</b><br>
    spedito il ${giorno} alle ${ora}<br><br>
    In allegato copia PDF come spedita al cliente.
    <br><br><br>
    Si prega di intervenire su VERDE per la corretta acquisizione del documento."$
    SMTP.AddAttachment(File.DirApp, $"${documentName}.pdf"$)
    SMTP.Send

    Sleep(100000)
    File.Delete(File.DirApp, $"${documentName}.pdf"$)
   
End Sub

Main.settings is a text files that contains all the parameters for the email adress.
I would like to underline again that this code works in debug, but seems to not work aftere release :(
Am I missing something?
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
I would like to underline again that this code works in debug, but seems to not work aftere release :(
Am I missing something?
Where is the full errormessage?
 
Upvote 0

ziovec

Member
Licensed User
Where is the full errormessage?
Dumbness solved.
Here's the error:

Java:
java.lang.RuntimeException: Empty writer returned: 530-5.7.0 Authentication Requ
ired. Learn more at
530 5.7.0  https://support.google.com/mail/?p=WantAuthError m2sm8122439wml.34 -
gsmtp

        at anywheresoftware.b4a.net.SMTPWrapper$1.run(SMTPWrapper.java:312)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executo
rs.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoo
lExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPo
olExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)

Looks like an auth error...but how?

In my settings file I'm using
smtp=smtp.gmail.com
port=465
Already checked in google account settings for third party allow.
Already tried port 587, getting a slightly different error about SSL (I guess it's because it's not the righ port)

As I said, with the same exact configuration everything works fine in debug mode :confused:
 
Last edited:
Upvote 0

jahswant

Well-Known Member
Licensed User
Longtime User
You are surely moving the application to your server In a new location than the development areas. What I did is to create a gmail account from the server location. And use it only there.
 
Upvote 0

ziovec

Member
Licensed User
You are surely moving the application to your server In a new location than the development areas. What I did is to create a gmail account from the server location. And use it only there.
Doesn't make sense to me.

Gmail should work regardless the platform if user and password are given correctly.
 
Upvote 0

jahswant

Well-Known Member
Licensed User
Longtime User
Gmail should work regardless the platform if user and password are given correctly.
Yes theoretically. When you change your location or even phone or computer they seem to create an authentication issue. I'm talking out of experience. Try creating a Gmail test account on server and see the results.
 
Upvote 0
Top