Re: What's the best way to auto-sign some emails but not all?
Bjørn Mork <[email protected]> Sat, 30 Nov 2024 20:28:41 +0100
| Newsgroups | gmane.emacs.gnus.general |
|---|---|
| Organization | m |
| Message-ID | <[email protected]> |
Trevor Arjeski <[email protected]> writes: > Bjørn Mork <[email protected]> writes: > >> Is there a nice way to always sign emails based on e.g. the current From >> address? I don't want to sign everything, but I would like to sign all >> emails I send from one specific address. > > Hi Bjørn, > > For me, I am signing all messages and just removing the "secure" tag > when I am writing on a mailing list or something. Yes, that's a possibilty. But do hate manual procedures for anything that can be automated. And knowing myself, I am going to forget this 47% of the time. I'll remember it if the passphrase box shows up. But I don't want to disable caching, and I am sure that will result in some emails going out with an unwanted gpg signature. Not a big problem, maybe. But we're looking for the perfect solution here :-) > I do this by adding a hook on `message-setup-hook' that calls > `mml-secure-message-encrypt'. > > Therefore, you can add a similar hook with the help of a function (or > just lambda), for example: > > #+BEGIN_SRC emacs-lisp > (defun my/mml-secure-message-encrypt () > "Encrypt all messages when we are sending as [email protected]. Do nothing > for all other From addresses." > (when (string= message-sendmail-envelope-from > "[email protected]") > (mml-secure-message-encrypt))) > > (add-hook 'message-setup-hook #'my/mml-secure-message-encrypt) > #+END_SRC > > Let me know if that is what you want or helps at all. Thanks a lot! It does not work any better, but at least it shows me how easy adding a hook would be. And it also made me look at how the gnus posting styles are implemented. I tried your suggestion with message-sendmail-envelope-from replaced by user-mail-address, since SPF prevents me from changing the envelope along with the from address. Unfortunately, this works exacly like using "body" or "eval" in a posting style. It's fine with an empty buffer, but not when replying with quoted text. Which isn't surprising after having looked at gnus-configure-posting-styles in gnus-msg.el. What gnus-configure-posting-styles does under the hood is (add-hook 'message-setup-hook (cond ((eq 'eval (car result)) #'ignore) ((eq 'body (car result)) (let ((txt (cdr result))) (lambda () (save-excursion (message-goto-body) (insert txt))))) etc. Not exactly sure how all this works, but it looks like the yanked text must be inserted into the buffer at a later stage. Bjørn