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) {
8585 prop .put ("mail.smtp.host" , connectionConfig .getHost ());
8686 prop .put ("mail.smtp.port" , connectionConfig .getPort () <= 0 ? DEFAULT_PORT : connectionConfig .getPort ());
8787 prop .put ("mail.smtp.auth" , true );
88+ prop .put ("mail.smtp.username" , connectionConfig .getUsername ());
8889 prop .put ("mail.smtp.starttls.enable" , "true" );
8990 prop .put ("mail.smtp.ssl.protocols" , "TLSv1.2" );
91+ prop .put ("mail.smtp.ssl.checkserveridentity" , false );
9092
9193 return Mono .fromSupplier (() ->
9294 // blocked call
@@ -119,9 +121,15 @@ public Mono<DatasourceTestResult> testConnection(SmtpDatasourceConfig connection
119121 return sessionMono
120122 .map (session -> {
121123 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+ }
123130 return DatasourceTestResult .testSuccess ();
124131 } catch (MessagingException e ) {
132+ log .debug ("SmtpPlugin.testConnection() failed!" , e );
125133 return DatasourceTestResult .testFail (e );
126134 }
127135 })
You can’t perform that action at this time.
0 commit comments