mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-25 07:00:49 +01:00
Added WriteToSendmailWithCommand which is more generic and takes a command to sendmail
The code of WriteToSendmail has been refactored to return the new WriteToSendmailWithCommand using SendmailPath
This commit is contained in:
parent
00264b6f70
commit
3c642be4eb
1 changed files with 8 additions and 2 deletions
10
msg.go
10
msg.go
|
@ -490,11 +490,17 @@ func (m *Msg) appendFile(c []*File, f *File, o ...FileOption) []*File {
|
|||
return append(c, f)
|
||||
}
|
||||
|
||||
// WriteToSendmail returns WriteToSendmailWithContext with a default timeout of 5 seconds
|
||||
// WriteToSendmail returns WriteToSendmailWithCommand with a default sendmail path
|
||||
func (m *Msg) WriteToSendmail() error {
|
||||
return m.WriteToSendmailWithCommand(SendmailPath)
|
||||
}
|
||||
|
||||
// WriteToSendmailWithCommand returns WriteToSendmailWithContext with a default timeout
|
||||
// of 5 seconds and a given sendmail path
|
||||
func (m *Msg) WriteToSendmailWithCommand(sp string) error {
|
||||
tctx, tcfn := context.WithTimeout(context.Background(), time.Second*5)
|
||||
defer tcfn()
|
||||
return m.WriteToSendmailWithContext(tctx, SendmailPath)
|
||||
return m.WriteToSendmailWithContext(tctx, sp)
|
||||
}
|
||||
|
||||
// WriteToSendmailWithContext opens an pipe to the local sendmail binary and tries to send the
|
||||
|
|
Loading…
Reference in a new issue