简介
偶尔会遇到需要在服务器上发送邮件的场景。这种情况下一般都是通过python脚本来完成,但对于某些没有python环境的机器或不熟悉pyhton的人员,未免有些麻烦。因此,就有的本工具的诞生。
这个简陋的command-line工具是基于我的另一篇文章中提供的库--emailagent,也算是一个代码使用的示例。并且它的代码库也在那里--example。
下载
地址:email 已编译文件直接放在exmaple里面,直接下载即可。
Usage
config.toml
Host = "smtp.aliyun.com"
Port = 465
IsSSL = true
User ="exmaple@aliyun.com"
NickName = "nick"
Password = ""
command
./email plain/html <email_body_file> [<flags>]
$ go build -o email main.go
$ ./email plain email.txt -c config.toml -s 'email for test' -t exmaple1@aliyun.com -t exmaple2@aliyun.com -a attachment_file -a another_attachment_file
$ ./email html email.html -c config.toml -s 'test for sending html' -t example@aliyun.com
$ ./email --help
usage: email --conf=CONF --to=TO --subject=SUBJECT [<flags>] <type> <content-file>
Flags:
--help Show context-sensitive help (also try --help-long and --help-man).
-c, --conf=CONF authuration configuraion
-a, --attach=ATTACH ... attach file
-t, --to=TO ... target
-s, --subject=SUBJECT email subject
Args:
<type> content type
<content-file> content body