email 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!emacs --script
  2. (require 'message)
  3. (require 'smtpmail)
  4. (setq
  5. message-sent-message-via '(mail mail)
  6. message-send-mail-function 'smtpmail-send-it)
  7. (unless (file-exists-p "~/.emailrc")
  8. (error "Missing ~/.emailrc. Need the following:
  9. (setq
  10. smtpmail-smtp-server \"smtp.example.org\"
  11. user-mail-address \"john.doe@example.org\"
  12. user-full-name \"John Doe\")"))
  13. (load "~/.emailrc" nil)
  14. (unless (file-exists-p "~/.authinfo.gpg")
  15. (error (format "Missing ~/.authinfo.gpg. Need the following:
  16. machine %s login MYLOGIN port 25 password MYPASSWORD" smtpmail-smtp-server)))
  17. (when (< (length command-line-args-left) 2)
  18. (error (format "Usage: %s SUBJECT TO...
  19. The e-mail body is read from the standard input (stdin)."
  20. (file-name-nondirectory (nth 2 command-line-args)))))
  21. (with-temp-buffer
  22. (insert (format "
  23. From: %s <%s>
  24. To: %s
  25. Subject: %s
  26. --text follows this line--
  27. "
  28. user-full-name user-mail-address
  29. (mapconcat 'identity (cdr command-line-args-left) ", ")
  30. (nth 0 command-line-args-left)))
  31. (insert (read-from-minibuffer ""))
  32. (message-send))