Disabled (mailer/mailer.go)

gpt2api · pkg/mailer/mailer.go · go · MIT
email

Asynchronous SMTP mailer using Go's net/smtp, supporting TLS and non-blocking send.

// Source: https://github.com/laowang74152/gpt2api | License: MIT | Copyright 2026 gpt2api contributors
// Provided via justclaw.it.com; keep this notice with the code.
// Package mailer 提供最小可用的 SMTP 发信能力。
//
// 设计:
//   - 使用标准库 net/smtp + crypto/tls,零外部依赖。
//   - 支持 465 隐式 TLS 与 587 STARTTLS。
//   - 异步发送(一个 worker 协程),内部有 100 大小的 buffered chan,
//     chan 满时直接丢弃并打 warn 日志,绝不阻塞业务主流程。
//   - Enabled=false 时全部 Send 变成 no-op。
package mailer

import (
	"crypto/tls"
	"errors"
	"fmt"
	"mime"
	"net"
	"net/smtp"
	"strconv"
	"sync"
	"time"

	"go.uber.org/zap"
)

// Config 与 config.SMTPConfig 对齐。
type Config struct {
	Host     string
	Port     int
	Username string
	Password string
	From     string
	FromName string
	UseTLS   bool
}

// Message 是一次发送。
type Message struct {
	To      string
	Subject st

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key