outgoing-cred-cmd: delay execution until an email needs to be sent

This can be useful in cases when:

1. outgoing-cred-cmd requires a user action or confirmation (e.g. when
   using pass with a Yubikey or similar smart card that requires a user
   to enter a pin or touch the device when decrypting the password)

2. A user starts aerc frequently, but not all the sessions end up with
   sending emails

3. So the user only wants to execute outgoing-cred-cmd when the password
   is really used, so the user doesn't have to enter pin or touch their
   Yubikey each time aerc starts

Signed-off-by: Stas Rudakou <stas@garage22.net>
Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
Stas Rudakou 2022-07-30 22:42:49 +02:00 committed by Robin Jarry
commit ca90343850
3 changed files with 60 additions and 45 deletions
commands/compose

View file

@ -51,7 +51,11 @@ func (Send) Execute(aerc *widgets.Aerc, args []string) error {
tabName := tab.Name
config := composer.Config()
if config.Outgoing == "" {
outgoing, err := config.Outgoing.ConnectionString()
if err != nil {
return errors.Wrap(err, "ReadCredentials(outgoing)")
}
if outgoing == "" {
return errors.New(
"No outgoing mail transport configured for this account")
}
@ -74,7 +78,7 @@ func (Send) Execute(aerc *widgets.Aerc, args []string) error {
return errors.Wrap(err, "ParseAddress(config.From)")
}
uri, err := url.Parse(config.Outgoing)
uri, err := url.Parse(outgoing)
if err != nil {
return errors.Wrap(err, "url.Parse(outgoing)")
}