(smtpAddr, to, subject, body string)
| 187 | } |
| 188 | |
| 189 | func sendTestEmail(smtpAddr, to, subject, body string) error { |
| 190 | from := "noreply@coder.com" |
| 191 | now := time.Now().Format(time.RFC1123Z) |
| 192 | |
| 193 | msg := strings.Builder{} |
| 194 | _, _ = msg.WriteString(fmt.Sprintf("From: %s\r\n", from)) |
| 195 | _, _ = msg.WriteString(fmt.Sprintf("To: %s\r\n", to)) |
| 196 | _, _ = msg.WriteString(fmt.Sprintf("Subject: %s\r\n", subject)) |
| 197 | _, _ = msg.WriteString(fmt.Sprintf("Date: %s\r\n", now)) |
| 198 | _, _ = msg.WriteString("Content-Type: text/html; charset=UTF-8\r\n") |
| 199 | _, _ = msg.WriteString("\r\n") |
| 200 | _, _ = msg.WriteString(body) |
| 201 | |
| 202 | return smtp.SendMail(smtpAddr, nil, from, []string{to}, []byte(msg.String())) |
| 203 | } |
no test coverage detected