https://github.com/mouday/notifier
基于Golang的邮件通知服务
https://github.com/mouday/notifier
api email golang web
Last synced: about 1 month ago
JSON representation
基于Golang的邮件通知服务
- Host: GitHub
- URL: https://github.com/mouday/notifier
- Owner: mouday
- Created: 2023-09-10T07:36:39.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-01-26T08:15:15.000Z (over 2 years ago)
- Last Synced: 2025-01-26T02:42:42.076Z (over 1 year ago)
- Topics: api, email, golang, web
- Language: Go
- Homepage:
- Size: 31.3 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Notifier
基于Golang的邮件通知服务
## 使用方式
1、下载适合所在运行平台的二进制文件
[https://github.com/mouday/notifier/releases](https://github.com/mouday/notifier/releases)
2、配置邮件验证信息
```bash
mv env.example .env
```
配置说明
```bash
# == 应用配置 ==
# 运行模式 debug test release (默认:release)
GIN_MODE=release
# 监听端口 (默认:127.0.0.1:8000)
APP_RUN_ADDRESS=127.0.0.1:8000
# == 邮件配置 ==
# 账号
APP_EMAIL_USERNAME=admin@163.com
# 密码
APP_EMAIL_PASSWORD=123456
# 邮件服务地址
APP_EMAIL_HOST=smtp.163.com
# 邮件服务端口号
APP_EMAIL_PORT=25
```
3、启动服务
```bash
# macos:
./notifier
# linux:
./notifier
# windows:
notifier.exe
```
4、调用api接口发送邮件
发送示例
```json
POST http://127.0.0.1:8000/sendEmail
content-type: application/json
{
"to": ["123456@qq.com"],
"subject": "测试邮件标题",
"body": "测试邮件内容"
}
```
返回响应
```json
{
"code": 0,
"msg": "success"
}
```
curl命令
```bash
curl -H "Content-Type:application/json" -X POST -d '{"to": ["123456@qq.com"], "subject": "测试邮件标题", "body": "测试邮件内容"}'http://127.0.0.1:8000/sendEmail
```
用到的第三方库
- https://github.com/cosmtrek/air
- https://github.com/subosito/gotenv
- https://github.com/jordan-wright/email
- https://github.com/gin-gonic/gin
参考文章
- [使用 GOLANG 发送邮件](https://blog.csdn.net/m0_37322399/article/details/118558600)