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
|
||||
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
|
||||
* **port** - SMTP server port, defaults to `587`
|
||||
* **username** - SMTP username
|
||||
|
@ -29,7 +30,8 @@ steps:
|
|||
- name: notify
|
||||
image: drillster/drone-email
|
||||
settings:
|
||||
from: noreply@github.com
|
||||
from.address: noreply@github.com
|
||||
from.name: John Smith
|
||||
host: smtp.mailgun.org
|
||||
username: octocat
|
||||
password: 12345
|
||||
|
@ -45,7 +47,7 @@ steps:
|
|||
- name: notify:
|
||||
image: drillster/drone-email
|
||||
settings:
|
||||
from: noreply@github.com
|
||||
from.address: noreply@github.com
|
||||
host: smtp.mailgun.org
|
||||
+ username:
|
||||
+ from_secret: email_username
|
||||
|
@ -91,7 +93,7 @@ steps:
|
|||
- name: notify
|
||||
image: drillster/drone-email
|
||||
settings:
|
||||
from: noreply@github.com
|
||||
from.address: noreply@github.com
|
||||
host: smtp.mailgun.org
|
||||
username: octocat
|
||||
password: 12345
|
||||
|
|
|
@ -42,7 +42,8 @@ Execute from the working directory:
|
|||
|
||||
```sh
|
||||
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_USERNAME=drone \
|
||||
-e PLUGIN_PASSWORD=test \
|
||||
|
|
19
main.go
19
main.go
|
@ -30,6 +30,16 @@ func main() {
|
|||
Usage: "from address",
|
||||
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{
|
||||
Name: "host",
|
||||
Usage: "smtp host",
|
||||
|
@ -325,6 +335,12 @@ func main() {
|
|||
}
|
||||
|
||||
func run(c *cli.Context) error {
|
||||
|
||||
var fromAddress string = c.String("from")
|
||||
if fromAddress == "" {
|
||||
fromAddress = c.String("from.address")
|
||||
}
|
||||
|
||||
plugin := Plugin{
|
||||
Repo: Repo{
|
||||
FullName: c.String("repo.fullName"),
|
||||
|
@ -384,7 +400,8 @@ func run(c *cli.Context) error {
|
|||
PullRequest: c.Int("pullRequest"),
|
||||
DeployTo: c.String("deployTo"),
|
||||
Config: Config{
|
||||
From: c.String("from"),
|
||||
FromAddress: fromAddress,
|
||||
FromName: c.String("from.name"),
|
||||
Host: c.String("host"),
|
||||
Port: c.Int("port"),
|
||||
Username: c.String("username"),
|
||||
|
|
|
@ -81,7 +81,8 @@ type (
|
|||
}
|
||||
|
||||
Config struct {
|
||||
From string
|
||||
FromAddress string
|
||||
FromName string
|
||||
Host string
|
||||
Port int
|
||||
Username string
|
||||
|
@ -212,7 +213,7 @@ func (p Plugin) Exec() error {
|
|||
if len(recipient) == 0 {
|
||||
continue
|
||||
}
|
||||
message.SetHeader("From", p.Config.From)
|
||||
message.SetAddressHeader("From", p.Config.FromAddress, p.Config.FromName)
|
||||
message.SetAddressHeader("To", recipient, "")
|
||||
message.SetHeader("Subject", subject)
|
||||
message.AddAlternative("text/plain", plainBody)
|
||||
|
|
Loading…
Reference in a new issue