Commit eb9fa6ed authored by Pasan Mallawaarachchi's avatar Pasan Mallawaarachchi 💻

context added to MG send function

parent 9079da3f
......@@ -9,6 +9,7 @@ package main
* - ./<file_name>
*/
import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
......@@ -318,7 +319,9 @@ func worker(i int) {
if len(cc) > 0 {
message.AddCC(cc)
}
MailgunResp, id, err := mg.Send(message)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
defer cancel()
MailgunResp, id, err := mg.Send(ctx, message)
if err != nil {
log.Fatal(err)
//alertAdmin(" MAilgun Error \n" + err.Error())
......@@ -367,7 +370,9 @@ func sendMessage(mg mailgun.Mailgun, sender, subject, body, recipient, cc string
* Add CC if cc recipiants are available
*/
if len(cc) > 0 {
message.AddCC(cc)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
defer cancel()
message.AddCC(ctx, cc)
}
resp, id, err := mg.Send(message)
if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment