SMTP mail sender with TLS support, parsing TLS versions and handling authentication.
// Source: https://github.com/semaphoreui/semaphore | License: MIT | Copyright 2021 Denis Gukov
// Provided via justclaw.it.com; keep this notice with the code.
package mailer
import (
"bytes"
"crypto/tls"
"fmt"
"net"
"net/smtp"
"strings"
"text/template"
"time"
"github.com/semaphoreui/semaphore/pkg/tz"
"github.com/semaphoreui/semaphore/util"
)
const (
mailerBase = "MIME-version: 1.0\r\n" +
"Content-Type: text/html; charset=UTF-8\r\n" +
//"Content-Transfer-Encoding: quoted-printable\r\n" +
"Date: {{ .Date }}\r\n" +
"To: {{ .To }}\r\n" +
"From: {{ .From }}\r\n" +
"Subject: {{ .Subject }}\r\n\r\n" +
"{{ .Body }}"
)
var r = strings.NewReplacer(
"\r\n", "",
"\r", "",
"\n", "",
"%0a", "",
"%0d", "",
)
func parseTlsVersion(version string) (uint16, error) {
swit
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key