From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/28773 Path: main.gmane.org!not-for-mail From: Florian Weimer Newsgroups: gmane.emacs.gnus.general Subject: Re: MML, message-send-hook and automatically GnuPG-signing messages. Date: 16 Jan 2000 09:14:50 +0100 Sender: owner-ding@hpc.uh.edu Message-ID: <87d7r25t6t.fsf@deneb.cygnus.argh.org> References: NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1035165560 31576 80.91.224.250 (21 Oct 2002 01:59:20 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 21 Oct 2002 01:59:20 +0000 (UTC) Return-Path: Original-Received: from bart.math.uh.edu (bart.math.uh.edu [129.7.128.48]) by mailhost.sclp.com (Postfix) with ESMTP id 9D860D051E for ; Sun, 16 Jan 2000 03:37:26 -0500 (EST) Original-Received: from sina.hpc.uh.edu (lists@Sina.HPC.UH.EDU [129.7.3.5]) by bart.math.uh.edu (8.9.1/8.9.1) with ESMTP id CAB08169; Sun, 16 Jan 2000 02:37:08 -0600 (CST) Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Sun, 16 Jan 2000 02:36:33 -0600 (CST) Original-Received: from mailhost.sclp.com (postfix@sclp3.sclp.com [204.252.123.139]) by sina.hpc.uh.edu (8.9.3/8.9.3) with ESMTP id CAA16802 for ; Sun, 16 Jan 2000 02:36:19 -0600 (CST) Original-Received: from mail.cid.net (cephyr.cid.net [212.172.21.2]) by mailhost.sclp.com (Postfix) with ESMTP id 56BCDD051E for ; Sun, 16 Jan 2000 03:34:48 -0500 (EST) Original-Received: from uucp by mail.cid.net (Exim 3.11) with local-bsmtp id 129l8v-0002fd-00; Sun, 16 Jan 2000 09:34:37 +0100 Original-Received: from deneb.cygnus.argh.org ([192.168.1.2] ident=exim) by cygnus.argh.org with esmtp (Exim 3.12 #1) id 129kpL-0003nX-00 for ding@gnus.org; Sun, 16 Jan 2000 09:14:23 +0100 Original-Received: from fw by deneb.cygnus.argh.org with local (Exim 3.12 #1) id 129kpm-0001Km-00 for ding@gnus.org; Sun, 16 Jan 2000 09:14:50 +0100 Original-To: ding@gnus.org Original-Lines: 94 User-Agent: Gnus/5.0804 (Gnus v5.8.4) Emacs/20.4 Precedence: list X-Majordomo: 1.94.jlt7 Xref: main.gmane.org gmane.emacs.gnus.general:28773 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:28773 Jonas Steverud writes: > I use mc-bbdb.el to automatically encrypt to some people (using > Mailcrypt and depening on what a special field in the BBDB is saying) > and this adds mc-bbdb-auto-encrypt-send to message-send-hook. I also > had until just recently > What is the best way of solving this? > > 1. Force evaluate MML before my encryption (either by hand or by > adding something to message-send-hook). Kludge? > > 2. Add the sign/encrypt parts *after* the MML evaluation, but how is > this done? I think this is preferred since encryption and signing > should go after all other mail processing is finished and right > before the mail actually goes away. 3. Use `mml-generate-multipart-alist'. Example (untested with current Gnus version): (setq mml-generate-multipart-alist '(("signed" . rfc2015-generate-signed-multipart) ("encrypted" . rfc2015-generate-encrypted-multipart))) (defun rfc2015-generate-enclosed-parts-and-funcall (cont func) "Generate the the parts in a temporary buffer and call FUNC. Returns the result of FUNC." ;; Descend one level. (setq cont (cddr cont)) (if (> (length cont) 1) ;; multipart/signed may not to contain more than one part. ;; Add an intermediate multipart/mixed if necessary. (setq cont (append '(multipart (type . "mixed")) cont)) ;; Descend to the contained part. (setq cont (car cont))) ;; Generate contained parts and signature. Do not include the ;; enclosing MIME boundaries in the signature. (with-temp-buffer ;; Generate subparts. (mml-generate-mime-1 cont) ;; Make sure that last line ends with . (goto-char (point-max)) (unless (bolp) (insert "\n")) (funcall func))) (defun rfc2015-generate-signed-multipart (cont) (let* ((mml-boundary (mml-compute-boundary cont)) ;; Make sure that the enclosed parts are encoded in the safest way. (quoted-printable-encode-from t) (mm-encode-no-7/8bit t) (parts-and-signature (rfc2015-generate-enclosed-parts-and-funcall cont (lambda () (cons (buffer-string) (rfc2015-gpg-sign (current-buffer)))))) (parts (car parts-and-signature)) (signature (cdr parts-and-signature))) (insert (format "Content-Type: multipart/signed; boundary=\"%s\";\n" mml-boundary) "\tmicalg=pgp-md5; protocol=\"application/pgp-signature\"\n" "\n" "\n--" mml-boundary "\n") ;; Insert generated parts and signature. (insert parts) (insert "\n--" mml-boundary "\n" "Content-Type: application/pgp-signature\n" "\n" signature "\n--" mml-boundary "--\n"))) (defun rfc2015-generate-encrypted-multipart (cont) (let* ((mml-boundary (mml-compute-boundary cont)) (encrypted-parts (rfc2015-generate-enclosed-parts-and-funcall cont (lambda () (rfc2015-gpg-encrypt) (buffer-string))))) (insert (format "Content-Type: multipart/encrypted; boundary=\"%s\";\n" mml-boundary) "\tprotocol=\"application/pgp-encrypted\"\n" "\n" "\n--" mml-boundary "\n" "Content-Type: application/pgp-encrypted\n" "\n" "Version: 1\n") (insert "\n--" mml-boundary "\n" "Content-Type: application/octet-stream\n" "\n" encrypted-parts "\n--" mml-boundary "\n")))