B4J Question smtp error

Status
Not open for further replies.

zhangbao

Member
How to handle the error message when sending an email via SMTP
B4X:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private xui As XUI
    Private Button1 As B4XView
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
End Sub

Sub Button1_Click
    SendEmail("[email protected]","tttt","wwwwww")
End Sub

Sub SendEmail(email As String, subject As String, message As String)
    Dim smtp As SMTP
    smtp.Initialize("smtp.qq.com",465,"[email protected]","***********","mail")
        
    smtp.UseSSL = True
    smtp.MailFrom = "[email protected]"
    smtp.Subject = subject
    
    If email.Contains(";") Then
        Dim emails() As String = Regex.split(";",email)
                
        For Each address As String In emails
            smtp.To.Add(address)
        Next
    Else
        smtp.To.Add(email)
    End If
    
    smtp.Body = message
    smtp.Send
End Sub



1753867663342.png
 

zhangbao

Member
正在等待调试器连接...
程序开始。
java.lang.RuntimeException:返回空写入器:502从 61.169.72.91 到 newxmesmtplogicsvrszc16-0.qq.com 的输入无效
在任何地方软件.b4a.net.SMTPWrapper$1.run(SMTPWrapper.java:312)
在 java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577)
在 java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
在 java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
在 java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
在 java.base/java.lang.Thread.run(Thread.java:1589)
 
Upvote 0

zhangbao

Member
Waiting for debugger to connect...
Program started.
org.apache.commons.net.smtp.SMTPConnectionClosedException: Connection closed without indication.
at org.apache.commons.net.smtp.SMTP.__getReply(SMTP.java:199)
at org.apache.commons.net.smtp.SMTP.__sendCommand(SMTP.java:171)
at org.apache.commons.net.smtp.SMTP.__sendCommand(SMTP.java:186)
at org.apache.commons.net.smtp.SMTP.rcpt(SMTP.java:524)
at org.apache.commons.net.smtp.SMTPClient.addRecipient(SMTPClient.java:314)
at anywheresoftware.b4a.net.SMTPWrapper$1.run(SMTPWrapper.java:298)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.lang.Thread.run(Thread.java:1589)
 
Upvote 0
Status
Not open for further replies.
Top