-# Deliver a message with emacs and add it to the database
-#
-# Uses emacs to generate and deliver a message to the mail store.
-# Accepts arbitrary extra emacs/elisp functions to modify the message
-# before sending, which is useful to doing things like attaching files
-# to the message and encrypting/signing.
-emacs_deliver_message ()
-{
- local subject body smtp_dummy_pid smtp_dummy_port
- subject="$1"
- body="$2"
- shift 2
- # before we can send a message, we have to prepare the FCC maildir
- mkdir -p "$MAIL_DIR"/sent/{cur,new,tmp}
- # eval'ing smtp-dummy --background will set smtp_dummy_pid and -_port
- smtp_dummy_pid= smtp_dummy_port=
- eval `$TEST_DIRECTORY/smtp-dummy --background sent_message`
- test -n "$smtp_dummy_pid" || return 1
- test -n "$smtp_dummy_port" || return 1
-
- test_emacs \
- "(let ((message-send-mail-function 'message-smtpmail-send-it)
- (mail-host-address \"example.com\")
- (smtpmail-smtp-server \"localhost\")
- (smtpmail-smtp-service \"${smtp_dummy_port}\"))
- (notmuch-mua-mail)
- (message-goto-to)
- (insert \"test_suite@notmuchmail.org\nDate: 01 Jan 2000 12:00:00 -0000\")
- (message-goto-subject)
- (insert \"${subject}\")
- (message-goto-body)
- (insert \"${body}\")
- $*
- (notmuch-mua-send-and-exit))"
-
- # In case message was sent properly, client waits for confirmation
- # before exiting and resuming control here; therefore making sure
- # that server exits by sending (KILL) signal to it is safe.
- kill -9 $smtp_dummy_pid
- notmuch new >/dev/null
-}
-
-# Pretend to deliver a message with emacs. Really save it to a file
-# and add it to the database
-#
-# Uses emacs to generate and deliver a message to the mail store.
-# Accepts arbitrary extra emacs/elisp functions to modify the message
-# before sending, which is useful to doing things like attaching files
-# to the message and encrypting/signing.
-#
-# If any GNU-style long-arguments (like --quiet or --decrypt=true) are
-# at the head of the argument list, they are sent directly to "notmuch
-# new" after message delivery
-emacs_fcc_message ()
-{
- local nmn_args subject body
- nmn_args=''
- while [[ "$1" =~ ^-- ]]; do
- nmn_args="$nmn_args $1"
- shift
- done
- subject="$1"
- body="$2"
- shift 2
- # before we can send a message, we have to prepare the FCC maildir
- mkdir -p "$MAIL_DIR"/sent/{cur,new,tmp}
-
- test_emacs \
- "(let ((message-send-mail-function (lambda () t))
- (mail-host-address \"example.com\"))
- (notmuch-mua-mail)
- (message-goto-to)
- (insert \"test_suite@notmuchmail.org\nDate: 01 Jan 2000 12:00:00 -0000\")
- (message-goto-subject)
- (insert \"${subject}\")
- (message-goto-body)
- (insert \"${body}\")
- $*
- (let ((mml-secure-smime-sign-with-sender t)
- (mml-secure-openpgp-sign-with-sender t))
- (notmuch-mua-send-and-exit)))" || return 1
- notmuch new $nmn_args >/dev/null
-}
-