email

package
v0.41.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2020 License: MIT Imports: 2 Imported by: 0

README

阿里云邮箱

import "github.com/alex-my/ghelper/email"

email.SetConfig(&email.Config{
	Host:     "smtp.mxhichina.com",
	Port:     465,
	Username: "阿里云邮箱地址",
	Password: "阿里云邮箱密码",
})

// 允许同时发送给多个目标
err := email.Send("xxx1@qq.com,xxx2@126.com", "这是标题", "<p>这是内容</p>")

QQ 邮箱

import "github.com/alex-my/ghelper/email"

email.SetConfig(&email.Config{
	Host:     "smtp.qq.com",
	Port:     465,
	Username: "QQ邮箱地址",
	Password: "QQ邮箱授权码",
})

err := email.Send("xxx@example.com", "这是标题", "<p>这是内容</p>")

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Send

func Send(from, to, subject, html string) error

Send 发送邮件 from: 发送人地址,可以是 xxx@xxx,也可以是 XXX <xxx@xxx> to: 目标邮箱地址,多个地址使用英文逗号隔离 subject: 邮件标题 html: 邮件内容, 支持 text/html 格式

func SetConfig

func SetConfig(c *Config)

SetConfig 初始化参数 服务器启动时初始化一次

Types

type Config

type Config struct {
	// Host SMTP server 地址, 例如 smtp.example.com
	Host string
	// Port SMTP server 端口, 例如 25, 465, 587
	Port int
	// Username 邮箱账号
	Username string
	// Password 邮箱密码或者授权码
	Password string
}

Config 邮件配置

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL