Skip to content

Commit 59516ce

Browse files
authored
[+] allow specify content-type for SendMail built-in task, closes #225 (#227)
1 parent b6c8783 commit 59516ce

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

internal/tasks/mail.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type emailConn struct {
2020
Subject string `json:"subject"`
2121
MsgBody string `json:"msgbody"`
2222
Attachments []string `json:"attachment"`
23+
ContentType string `json:"contenttype"`
2324
}
2425

2526
// Dialer implements DialAndSend function for mailer
@@ -32,7 +33,7 @@ var getNewDialer func(host string, port int, username, password string) Dialer =
3233
}
3334

3435
func taskSendMail(ctx context.Context, paramValues string) error {
35-
var conn emailConn
36+
conn := emailConn{ServerPort: 587, ContentType: "text/plain"}
3637
if err := json.Unmarshal([]byte(paramValues), &conn); err != nil {
3738
return err
3839
}
@@ -84,7 +85,7 @@ func sendMail(conn emailConn) error {
8485
mail.SetHeader("Bcc", bccrecipients...)
8586

8687
mail.SetHeader("Subject", conn.Subject)
87-
mail.SetBody("text/html", conn.MsgBody)
88+
mail.SetBody(conn.ContentType, conn.MsgBody)
8889

8990
//attach multiple documents
9091
for _, attachment := range conn.Attachments {

0 commit comments

Comments
 (0)