@ -1529,6 +1529,7 @@ type Mailer struct {
FromName string
FromName string
FromEmail string
FromEmail string
SendAsPlainText bool
SendAsPlainText bool
MailerType string
// SMTP sender
// SMTP sender
Host string
Host string
@ -1541,7 +1542,6 @@ type Mailer struct {
IsTLSEnabled bool
IsTLSEnabled bool
// Sendmail sender
// Sendmail sender
UseSendmail bool
SendmailPath string
SendmailPath string
SendmailArgs [ ] string
SendmailArgs [ ] string
}
}
@ -1562,6 +1562,7 @@ func newMailService() {
QueueLength : sec . Key ( "SEND_BUFFER_LEN" ) . MustInt ( 100 ) ,
QueueLength : sec . Key ( "SEND_BUFFER_LEN" ) . MustInt ( 100 ) ,
Name : sec . Key ( "NAME" ) . MustString ( AppName ) ,
Name : sec . Key ( "NAME" ) . MustString ( AppName ) ,
SendAsPlainText : sec . Key ( "SEND_AS_PLAIN_TEXT" ) . MustBool ( false ) ,
SendAsPlainText : sec . Key ( "SEND_AS_PLAIN_TEXT" ) . MustBool ( false ) ,
MailerType : sec . Key ( "MAILER_TYPE" ) . In ( "" , [ ] string { "smtp" , "sendmail" , "dummy" } ) ,
Host : sec . Key ( "HOST" ) . String ( ) ,
Host : sec . Key ( "HOST" ) . String ( ) ,
User : sec . Key ( "USER" ) . String ( ) ,
User : sec . Key ( "USER" ) . String ( ) ,
@ -1574,7 +1575,6 @@ func newMailService() {
KeyFile : sec . Key ( "KEY_FILE" ) . String ( ) ,
KeyFile : sec . Key ( "KEY_FILE" ) . String ( ) ,
IsTLSEnabled : sec . Key ( "IS_TLS_ENABLED" ) . MustBool ( ) ,
IsTLSEnabled : sec . Key ( "IS_TLS_ENABLED" ) . MustBool ( ) ,
UseSendmail : sec . Key ( "USE_SENDMAIL" ) . MustBool ( ) ,
SendmailPath : sec . Key ( "SENDMAIL_PATH" ) . MustString ( "sendmail" ) ,
SendmailPath : sec . Key ( "SENDMAIL_PATH" ) . MustString ( "sendmail" ) ,
}
}
MailService . From = sec . Key ( "FROM" ) . MustString ( MailService . User )
MailService . From = sec . Key ( "FROM" ) . MustString ( MailService . User )
@ -1584,6 +1584,13 @@ func newMailService() {
MailService . SendAsPlainText = ! sec . Key ( "ENABLE_HTML_ALTERNATIVE" ) . MustBool ( false )
MailService . SendAsPlainText = ! sec . Key ( "ENABLE_HTML_ALTERNATIVE" ) . MustBool ( false )
}
}
if sec . HasKey ( "USE_SENDMAIL" ) {
log . Warn ( "USE_SENDMAIL is deprecated, use MAILER_TYPE=sendmail" )
if MailService . MailerType == "" && sec . Key ( "USE_SENDMAIL" ) . MustBool ( false ) {
MailService . MailerType = "sendmail"
}
}
parsed , err := mail . ParseAddress ( MailService . From )
parsed , err := mail . ParseAddress ( MailService . From )
if err != nil {
if err != nil {
log . Fatal ( 4 , "Invalid mailer.FROM (%s): %v" , MailService . From , err )
log . Fatal ( 4 , "Invalid mailer.FROM (%s): %v" , MailService . From , err )
@ -1591,7 +1598,11 @@ func newMailService() {
MailService . FromName = parsed . Name
MailService . FromName = parsed . Name
MailService . FromEmail = parsed . Address
MailService . FromEmail = parsed . Address
if MailService . UseSendmail {
if MailService . MailerType == "" {
MailService . MailerType = "smtp"
}
if MailService . MailerType == "sendmail" {
MailService . SendmailArgs , err = shellquote . Split ( sec . Key ( "SENDMAIL_ARGS" ) . String ( ) )
MailService . SendmailArgs , err = shellquote . Split ( sec . Key ( "SENDMAIL_ARGS" ) . String ( ) )
if err != nil {
if err != nil {
log . Error ( 4 , "Failed to parse Sendmail args: %v" , CustomConf , err )
log . Error ( 4 , "Failed to parse Sendmail args: %v" , CustomConf , err )