Re: What's the best way to auto-sign some emails but not all?

Trevor Arjeski <[email protected]> Sat, 30 Nov 2024 23:17:23 +0300
Newsgroups gmane.emacs.gnus.general
Message-ID <[email protected]>
Bjørn Mork <[email protected]> writes:

> 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 :-)

Of course! I wasn't suggesting it for you, just leading up to the hook.

>
>> 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.

My mistake, I completely missed that you only want to sign certain parts
of the message. (also I wrote -encrypt instead of -sign in the function)

Ignore me!

Trevor