2022-07-29 13:23:08 +02:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
2023-06-03 00:57:13 +02:00
|
|
|
"os"
|
|
|
|
|
2022-07-29 13:23:08 +02:00
|
|
|
sendmail "github.com/axllent/mailpit/sendmail/cmd"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
// sendmailCmd represents the sendmail command
|
|
|
|
var sendmailCmd = &cobra.Command{
|
2023-04-15 01:34:31 +02:00
|
|
|
Use: "sendmail [flags] [recipients]",
|
|
|
|
Short: "A sendmail command replacement for Mailpit",
|
2022-07-29 13:23:08 +02:00
|
|
|
Run: func(_ *cobra.Command, _ []string) {
|
2023-06-03 00:57:13 +02:00
|
|
|
|
2022-07-29 13:23:08 +02:00
|
|
|
sendmail.Run()
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
rootCmd.AddCommand(sendmailCmd)
|
|
|
|
|
2023-06-03 00:57:13 +02:00
|
|
|
// print out manual help screen
|
2023-06-14 23:50:11 +02:00
|
|
|
sendmailCmd.SetHelpTemplate(sendmail.HelpTemplate([]string{os.Args[0], "sendmail"}))
|
2023-06-03 00:57:13 +02:00
|
|
|
|
|
|
|
// these are simply repeated for cli consistency as cobra/viper does not allow
|
|
|
|
// multi-letter single-dash variables (-bs)
|
|
|
|
sendmailCmd.Flags().StringVarP(&sendmail.FromAddr, "from", "f", sendmail.FromAddr, "SMTP sender")
|
|
|
|
sendmailCmd.Flags().StringVarP(&sendmail.SMTPAddr, "smtp-addr", "S", sendmail.SMTPAddr, "SMTP server address")
|
|
|
|
sendmailCmd.Flags().BoolVarP(&sendmail.UseB, "long-b", "b", false, "Handle SMTP commands on standard input (use as -bs)")
|
|
|
|
sendmailCmd.Flags().BoolVarP(&sendmail.UseS, "long-s", "s", false, "Handle SMTP commands on standard input (use as -bs)")
|
|
|
|
sendmailCmd.Flags().BoolP("verbose", "v", false, "Verbose mode (sends debug output to stderr)")
|
2023-06-06 21:35:34 +02:00
|
|
|
sendmailCmd.Flags().BoolP("long-i", "i", false, "Ignored")
|
|
|
|
sendmailCmd.Flags().BoolP("long-o", "o", false, "Ignored")
|
|
|
|
sendmailCmd.Flags().BoolP("long-t", "t", false, "Ignored")
|
2022-07-29 13:23:08 +02:00
|
|
|
}
|