MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / sendEmailWithClient

Function sendEmailWithClient

agent/utils/email/smtp_sender.go:232–252  ·  view source on GitHub ↗
(client *smtp.Client, config SMTPConfig, toList []string, msg string)

Source from the content-addressed store, hash-verified

230}
231
232func sendEmailWithClient(client *smtp.Client, config SMTPConfig, toList []string, msg string) error {
233 if err := client.Mail(config.Sender); err != nil {
234 return fmt.Errorf("setting sender failed: %w", err)
235 }
236 for _, addr := range toList {
237 if err := client.Rcpt(addr); err != nil {
238 return fmt.Errorf("adding recipient %s failed: %w", addr, err)
239 }
240 }
241 w, err := client.Data()
242 if err != nil {
243 return fmt.Errorf("preparing data failed: %w", err)
244 }
245 defer w.Close()
246
247 if _, err := w.Write([]byte(msg)); err != nil {
248 return fmt.Errorf("writing message failed: %w", err)
249 }
250
251 return nil
252}
253
254func tryAuth(client *smtp.Client, username, password, host string) error {
255 ok, authCap := client.Extension("AUTH")

Callers 3

sendWithSSLFunction · 0.85
sendWithStartTLSFunction · 0.85
sendPlaintextFunction · 0.85

Calls 2

CloseMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected