2017-12-05 15:15:00 +01:00
|
|
|
#!emacs --script
|
|
|
|
|
|
|
|
(require 'message)
|
|
|
|
(require 'smtpmail)
|
|
|
|
|
|
|
|
(setq
|
|
|
|
message-sent-message-via '(mail mail)
|
|
|
|
message-send-mail-function 'smtpmail-send-it)
|
|
|
|
|
|
|
|
(unless (file-exists-p "~/.emailrc")
|
|
|
|
(error "Missing ~/.emailrc. Need the following:
|
|
|
|
(setq
|
|
|
|
smtpmail-smtp-server \"smtp.example.org\"
|
|
|
|
user-mail-address \"john.doe@example.org\"
|
|
|
|
user-full-name \"John Doe\")"))
|
|
|
|
(load "~/.emailrc" nil)
|
|
|
|
|
|
|
|
(unless (file-exists-p "~/.authinfo.gpg")
|
|
|
|
(error (format "Missing ~/.authinfo.gpg. Need the following:
|
|
|
|
machine %s login MYLOGIN port 25 password MYPASSWORD" smtpmail-smtp-server)))
|
|
|
|
|
2017-12-05 15:33:15 +01:00
|
|
|
(when (< (length command-line-args-left) 2)
|
|
|
|
(error (format "Usage: %s SUBJECT TO...
|
|
|
|
|
|
|
|
The e-mail body is read from the standard input (stdin)."
|
|
|
|
(file-name-nondirectory (nth 2 command-line-args)))))
|
2017-12-05 15:15:00 +01:00
|
|
|
|
|
|
|
(with-temp-buffer
|
|
|
|
(insert (format "
|
|
|
|
From: %s <%s>
|
|
|
|
To: %s
|
|
|
|
Subject: %s
|
|
|
|
--text follows this line--
|
|
|
|
|
|
|
|
"
|
|
|
|
user-full-name user-mail-address
|
2017-12-05 15:33:15 +01:00
|
|
|
(mapconcat 'identity (cdr command-line-args-left) ", ")
|
2017-12-05 15:15:00 +01:00
|
|
|
(nth 0 command-line-args-left)))
|
2017-12-05 15:33:15 +01:00
|
|
|
(insert (read-from-minibuffer ""))
|
2017-12-05 15:15:00 +01:00
|
|
|
(message-send))
|