@@ -14,8 +14,6 @@ import (
1414 "github.com/jhillyerd/enmime"
1515 "net"
1616 "net/mail"
17- "os"
18- "os/user"
1917)
2018
2119const (
@@ -103,30 +101,8 @@ func (ch *Email) SetConfig(jsonStr json.RawMessage) error {
103101 return fmt .Errorf ("failed to load config: %s %w" , jsonStr , err )
104102 }
105103
106- if ch .Host == "" {
107- ch .Host = "localhost"
108- }
109-
110- if ch .Port == "" {
111- ch .Port = "25"
112- }
113-
114- if ch .SenderMail == "" {
115- hostname , err := os .Hostname ()
116- if err != nil {
117- return fmt .Errorf ("failed to get the OS hostname: %w" , err )
118- }
119-
120- usr , err := user .Current ()
121- if err != nil {
122- return fmt .Errorf ("failed to get the OS current user: %w" , err )
123- }
124-
125- ch .SenderMail = usr .Username + "@" + hostname
126- }
127-
128- if ch .User == "" {
129- ch .User = ch .SenderMail
104+ if (ch .User == "" ) != (ch .Password == "" ) {
105+ return fmt .Errorf ("user and password fields must both be set or empty" )
130106 }
131107
132108 return nil
@@ -143,25 +119,28 @@ func (ch *Email) GetInfo() *plugin.Info {
143119 },
144120 },
145121 {
146- Name : "sender_mail" ,
147- Type : "string" ,
122+ Name : "sender_mail" ,
123+ Type : "string" ,
124+ Required : true ,
148125 Label : map [string ]string {
149126 "en_US" : "Sender Address" ,
150127 "de_DE" : "Absenderadresse" ,
151128 },
152129153130 },
154131 {
155- Name : "host" ,
156- Type : "string" ,
132+ Name : "host" ,
133+ Type : "string" ,
134+ Required : true ,
157135 Label : map [string ]string {
158136 "en_US" : "SMTP Host" ,
159137 "de_DE" : "SMTP Host" ,
160138 },
161139 },
162140 {
163- Name : "port" ,
164- Type : "number" ,
141+ Name : "port" ,
142+ Type : "number" ,
143+ Required : true ,
165144 Label : map [string ]string {
166145 "en_US" : "SMTP Port" ,
167146 "de_DE" : "SMTP Port" ,
0 commit comments