forked from byzer-org/byzer-lang
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
27 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -488,20 +488,21 @@ class SQLSendMessage(override val uid: String) extends SQLAlg with Functions wit | |
|```sql | ||
|set EMAIL_TITLE = "This is the title of the email"; | ||
|set EMAIL_BODY ='''<div>This is the first line</div><br/><hr/><div>This is the second line</div>'''; | ||
|set EMAIL_TO = "137297351@qq.com"; | ||
|set EMAIL_TO = "yourMailAddress@qq.com"; | ||
| | ||
|run command as SendMessage. | ||
|run command as SendMessage.`` | ||
|where method="mail" | ||
|and content="${EMAIL_BODY}" | ||
|and from = "137297351@qq.com" | ||
|and from = "yourMailAddress@qq.com" | ||
|and to = "${EMAIL_TO}" | ||
|and subject = "${EMAIL_TITLE}" | ||
|and contentType="text/html" | ||
|and attachmentContentType="text/csv" | ||
|and attachmentPaths="/tmp/employee.csv,/tmp/employee.csv" | ||
|and smtpHost = "smtp.qq.com" | ||
|and smtpPort="587" | ||
|and `userName`="[email protected]" | ||
|and `properties.mail.smtp.starttls.enable`= "true" | ||
|and `userName`="[email protected]" | ||
|and password="---" | ||
|; | ||
|``` | ||
|
@@ -649,15 +650,32 @@ class MailAgent() extends Logging with WowLog with DslTool { | |
val smtpHost = params("smtpHost") | ||
val smtpPort = params.getOrElse("smtpPort", "465") | ||
require(smtpHost != null) | ||
properties.put("mail.host", smtpHost) | ||
properties.put("mail.localhost", smtpHost) | ||
properties.put("mail.smtp.host", smtpHost) | ||
properties.put("mail.smtp.localhost", smtpHost) | ||
properties.put("mail.smtp.auth", "true") | ||
properties.setProperty("mail.host", smtpHost) | ||
properties.setProperty("mail.localhost", smtpHost) | ||
properties.setProperty("mail.smtp.host", smtpHost) | ||
properties.setProperty("mail.smtp.localhost", smtpHost) | ||
properties.setProperty("mail.smtp.auth", "true") | ||
properties.setProperty("mail.smtp.socketFactory.fallback", "false") | ||
properties.setProperty("mail.smtp.port", smtpPort) | ||
properties.setProperty("mail.smtp.socketFactory.port", smtpPort) | ||
|
||
params.filter(_._1.startsWith("properties.")).foreach { case (k, v) => | ||
properties.setProperty(k.stripPrefix("properties."), v) | ||
} | ||
|
||
/** | ||
* In order to ensure account security and simple configuration, the default secure communication | ||
* framework standard protocol is SSL. If your mail service provider requires a non-SSL method, | ||
* please set `properties.mail.smtp.ssl.enable= "false"`, or `properties.mail.smtp.starttls.enable= "false"` | ||
*/ | ||
if (!smtpPort.equals("25") && !properties.containsKey("properties.mail.smtp.starttls.enable") | ||
&& !properties.containsKey("properties.mail.smtp.ssl.enable")) { | ||
properties.setProperty("properties.mail.smtp.ssl.enable", smtpPort) | ||
if (!properties.containsKey("properties.mail.smtp.starttls.enable")) { | ||
properties.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory") | ||
} | ||
} | ||
|
||
val userName = params.getOrElse("userName", GLOBAL_USER_NAME) | ||
val password = params.getOrElse("password", GLOBAL_IDENTIFY_CODE) | ||
assert(userName != null, "userName can not be null!") | ||
|