1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-10 05:25:58 +00:00

E-mail through linux command with UseCommand configuration field

This commit is contained in:
Makis Maropoulos
2016-06-02 23:29:29 +03:00
parent b58c16113a
commit 679b707751
3 changed files with 9 additions and 4 deletions

View File

@@ -49,8 +49,8 @@ func (m *mailer) sendSMTP(to []string, subject, body string) error {
defer buf.Put(buffer)
if !m.authenticated {
if m.config.Username == "" || m.config.Password == "" || m.config.Host == "" {
return fmt.Errorf("Username, Password, Host cannot be empty when using SMTP!")
if m.config.Username == "" || m.config.Password == "" || m.config.Host == "" || m.config.Port <= 0 {
return fmt.Errorf("Username, Password, Host & Port cannot be empty when using SMTP!")
}
m.auth = smtp.PlainAuth("", m.config.Username, m.config.Password, m.config.Host)
m.authenticated = true
@@ -75,7 +75,7 @@ func (m *mailer) sendSMTP(to []string, subject, body string) error {
func (m *mailer) sendCmd(to []string, subject, body string) error {
buffer := buf.Get()
defer buf.Put(buffer)
// buffer.WriteString(body)
cmd := utils.CommandBuilder("mail", "-s", subject, strings.Join(to, ","))
cmd.AppendArguments("-a", "Content-type: text/html") //always html on