You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added the following code to message.go. This adds the ability for the user to send email from the command line of a server using a pipe. This is very useful when sending yourself and / or others a chunk from a log file.
if list == nil {
return []*file{f}
}
return append(list, f)
}
// Pipe attaches the files to the email, user pipes it in from stdin.
func (m *Message) Pipe(filename string, settings ...FileSetting) {
m.attachments = m.pipeFile(m.attachments, filename)
}
The text was updated successfully, but these errors were encountered:
Added the following code to message.go. This adds the ability for the user to send email from the command line of a server using a pipe. This is very useful when sending yourself and / or others a chunk from a log file.
tail -100 SomeLogfile.log | goemailprog -t [email protected] -s "logfile" -m "last 100 from SomeLogfile" -p "SomeLogfile.log"
---- code to add to messages.go ---
func (m *Message) pipeFile(list []*file, name string) []*file {
f := &file{
Name: name,
Header: make(map[string][]string),
CopyFunc: func(w io.Writer) error {
h := bufio.NewReader(os.Stdin)
if _, err := io.Copy(w, h); err != nil {
return err
}
return nil
},
}
}
// Pipe attaches the files to the email, user pipes it in from stdin.
func (m *Message) Pipe(filename string, settings ...FileSetting) {
m.attachments = m.pipeFile(m.attachments, filename)
}
The text was updated successfully, but these errors were encountered: