Created
June 9, 2023 15:36
-
-
Save HalCanary/7685ffd89a0096d2d4348b806e39e7f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"os/exec" | |
"strings" | |
) | |
func MuttSendFile(dstEmail, filePath string) error { | |
st, err := os.Stat(filePath) | |
if err != nil { | |
return err | |
} | |
subject := fmt.Sprintf("[%d bytes] %s", st.Size(), filePath) | |
mutt := exec.Command("mutt", "-a", filePath, "-s", subject, "--", dstEmail) | |
mutt.Stdin = strings.NewReader("(file attached)") | |
mutt.Stdout, mutt.Stderr = os.Stdout, os.Stderr | |
return mutt.Run() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment