Merge pull request #56 from tiggerlee2/master
Extended from configuration to support utf8 name
This commit is contained in:
commit
5e36812d7f
10
DOCS.md
10
DOCS.md
|
@ -3,7 +3,8 @@ Use the Email plugin for sending build status notifications via email.
|
||||||
## Config
|
## Config
|
||||||
You can configure the plugin using the following parameters:
|
You can configure the plugin using the following parameters:
|
||||||
|
|
||||||
* **from** - Send notifications from this address
|
* **from.address** - Send notifications from this address
|
||||||
|
* **from.name** - Notifications sender name
|
||||||
* **host** - SMTP server host
|
* **host** - SMTP server host
|
||||||
* **port** - SMTP server port, defaults to `587`
|
* **port** - SMTP server port, defaults to `587`
|
||||||
* **username** - SMTP username
|
* **username** - SMTP username
|
||||||
|
@ -29,7 +30,8 @@ steps:
|
||||||
- name: notify
|
- name: notify
|
||||||
image: drillster/drone-email
|
image: drillster/drone-email
|
||||||
settings:
|
settings:
|
||||||
from: noreply@github.com
|
from.address: noreply@github.com
|
||||||
|
from.name: John Smith
|
||||||
host: smtp.mailgun.org
|
host: smtp.mailgun.org
|
||||||
username: octocat
|
username: octocat
|
||||||
password: 12345
|
password: 12345
|
||||||
|
@ -45,7 +47,7 @@ steps:
|
||||||
- name: notify:
|
- name: notify:
|
||||||
image: drillster/drone-email
|
image: drillster/drone-email
|
||||||
settings:
|
settings:
|
||||||
from: noreply@github.com
|
from.address: noreply@github.com
|
||||||
host: smtp.mailgun.org
|
host: smtp.mailgun.org
|
||||||
+ username:
|
+ username:
|
||||||
+ from_secret: email_username
|
+ from_secret: email_username
|
||||||
|
@ -91,7 +93,7 @@ steps:
|
||||||
- name: notify
|
- name: notify
|
||||||
image: drillster/drone-email
|
image: drillster/drone-email
|
||||||
settings:
|
settings:
|
||||||
from: noreply@github.com
|
from.address: noreply@github.com
|
||||||
host: smtp.mailgun.org
|
host: smtp.mailgun.org
|
||||||
username: octocat
|
username: octocat
|
||||||
password: 12345
|
password: 12345
|
||||||
|
|
|
@ -42,7 +42,8 @@ Execute from the working directory:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
-e PLUGIN_FROM=drone@test.test \
|
-e PLUGIN_FROM_ADDRESS=drone@test.test \
|
||||||
|
-e PLUGIN_FROM_NAME="John Smith" \
|
||||||
-e PLUGIN_HOST=smtp.test.test \
|
-e PLUGIN_HOST=smtp.test.test \
|
||||||
-e PLUGIN_USERNAME=drone \
|
-e PLUGIN_USERNAME=drone \
|
||||||
-e PLUGIN_PASSWORD=test \
|
-e PLUGIN_PASSWORD=test \
|
||||||
|
|
19
main.go
19
main.go
|
@ -30,6 +30,16 @@ func main() {
|
||||||
Usage: "from address",
|
Usage: "from address",
|
||||||
EnvVar: "PLUGIN_FROM",
|
EnvVar: "PLUGIN_FROM",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "from.address",
|
||||||
|
Usage: "from address",
|
||||||
|
EnvVar: "PLUGIN_FROM_ADDRESS",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "from.name",
|
||||||
|
Usage: "from name",
|
||||||
|
EnvVar: "PLUGIN_FROM_NAME",
|
||||||
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "host",
|
Name: "host",
|
||||||
Usage: "smtp host",
|
Usage: "smtp host",
|
||||||
|
@ -325,6 +335,12 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func run(c *cli.Context) error {
|
func run(c *cli.Context) error {
|
||||||
|
|
||||||
|
var fromAddress string = c.String("from")
|
||||||
|
if fromAddress == "" {
|
||||||
|
fromAddress = c.String("from.address")
|
||||||
|
}
|
||||||
|
|
||||||
plugin := Plugin{
|
plugin := Plugin{
|
||||||
Repo: Repo{
|
Repo: Repo{
|
||||||
FullName: c.String("repo.fullName"),
|
FullName: c.String("repo.fullName"),
|
||||||
|
@ -384,7 +400,8 @@ func run(c *cli.Context) error {
|
||||||
PullRequest: c.Int("pullRequest"),
|
PullRequest: c.Int("pullRequest"),
|
||||||
DeployTo: c.String("deployTo"),
|
DeployTo: c.String("deployTo"),
|
||||||
Config: Config{
|
Config: Config{
|
||||||
From: c.String("from"),
|
FromAddress: fromAddress,
|
||||||
|
FromName: c.String("from.name"),
|
||||||
Host: c.String("host"),
|
Host: c.String("host"),
|
||||||
Port: c.Int("port"),
|
Port: c.Int("port"),
|
||||||
Username: c.String("username"),
|
Username: c.String("username"),
|
||||||
|
|
|
@ -81,7 +81,8 @@ type (
|
||||||
}
|
}
|
||||||
|
|
||||||
Config struct {
|
Config struct {
|
||||||
From string
|
FromAddress string
|
||||||
|
FromName string
|
||||||
Host string
|
Host string
|
||||||
Port int
|
Port int
|
||||||
Username string
|
Username string
|
||||||
|
@ -212,7 +213,7 @@ func (p Plugin) Exec() error {
|
||||||
if len(recipient) == 0 {
|
if len(recipient) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
message.SetHeader("From", p.Config.From)
|
message.SetAddressHeader("From", p.Config.FromAddress, p.Config.FromName)
|
||||||
message.SetAddressHeader("To", recipient, "")
|
message.SetAddressHeader("To", recipient, "")
|
||||||
message.SetHeader("Subject", subject)
|
message.SetHeader("Subject", subject)
|
||||||
message.AddAlternative("text/plain", plainBody)
|
message.AddAlternative("text/plain", plainBody)
|
||||||
|
|
Loading…
Reference in a new issue