File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
server/api-service/lowcoder-plugins/smtpPlugin/src/main/java/org/lowcoder/plugins Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -85,8 +85,10 @@ public Mono<Session> createConnection(SmtpDatasourceConfig connectionConfig) {
85
85
prop .put ("mail.smtp.host" , connectionConfig .getHost ());
86
86
prop .put ("mail.smtp.port" , connectionConfig .getPort () <= 0 ? DEFAULT_PORT : connectionConfig .getPort ());
87
87
prop .put ("mail.smtp.auth" , true );
88
+ prop .put ("mail.smtp.username" , connectionConfig .getUsername ());
88
89
prop .put ("mail.smtp.starttls.enable" , "true" );
89
90
prop .put ("mail.smtp.ssl.protocols" , "TLSv1.2" );
91
+ prop .put ("mail.smtp.ssl.checkserveridentity" , false );
90
92
91
93
return Mono .fromSupplier (() ->
92
94
// blocked call
@@ -119,9 +121,15 @@ public Mono<DatasourceTestResult> testConnection(SmtpDatasourceConfig connection
119
121
return sessionMono
120
122
.map (session -> {
121
123
try {
122
- session .getTransport ().connect ();
124
+ if (connectionConfig .getUsername () != null ) {
125
+ session .getTransport ().connect (connectionConfig .getUsername (), connectionConfig .getPassword ());
126
+ }
127
+ else {
128
+ session .getTransport ().connect ();
129
+ }
123
130
return DatasourceTestResult .testSuccess ();
124
131
} catch (MessagingException e ) {
132
+ log .debug ("SmtpPlugin.testConnection() failed!" , e );
125
133
return DatasourceTestResult .testFail (e );
126
134
}
127
135
})
You can’t perform that action at this time.
0 commit comments