Commit Graph

92 Commits

Author SHA1 Message Date
Jason Cox 7647dfb8b4 compose: warn before sending without attachment
Prevent the embarrassing forgotten attachment scenario by warning the
user before sending a message that may need an attachment but does not
have one. Whether a message needs an attachment is determined by testing
a configurable regex against the message body.

Signed-off-by: Jason Cox <dev@jasoncarloscox.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-10-17 22:41:00 +02:00
Julian Pidancet 9217dbeea4 imap,smtp: add XOAUTH2 support
Add XOAUTH2 authentication support for IMAP and SMTP. Although XOAUTH2
is now deprecated in favor of OAuthBearer, it is the only way to connect
to Office365 since Basic Auth is now completely removed.

Since XOAUTH2 is very similar to OAuthBearer and uses the same
configuration parameters, this is basically a copy-paste of the existing
OAuthBearer code.

However, XOAUTH2 support was removed from go-sasl library, so this
change reimports the code that was removed from go-sasl and offers it
a new home in lib/xoauth2.go. Hopefully it shouldn't be too hard to
maintain, being less than 50 SLOC.

Link: https://github.com/emersion/go-sasl/commit/7bfe0ed36a21
Implements: https://todo.sr.ht/~rjarry/aerc/78
Signed-off-by: Julian Pidancet <julian.pidancet@oracle.com>
Tested-by: Inwit <inwit@sindominio.net>
Acked-by: Tim Culverhouse <tim@timculverhouse.com>
2022-10-01 15:47:33 +02:00
Koni Marti 044519e1dc switch: update status line
Update status line when switching accounts in the composer.

Fixes: 371c1a ("commands: add switch-account command for composer")
Reported-by: Bence Ferdinandy <bence@ferdinandy.com>
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-09-20 21:05:15 +02:00
Robin Jarry bb9ac43e13 switch: add -n and -p flags for relative switch
Allow switching to next or previous account with switch-account -n and
switch-account -p, respectively. By default, these are bound to Alt-n
and Alt-p.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Koni Marti <koni.marti@gmail.com>
2022-09-20 20:55:29 +02:00
Koni Marti d371c1ac8d commands: add switch-account command for composer
Switch accounts when in the composer mode. When switching accounts, the
From header, the crypto status and the address completer will be
updated.

Accounts can be switched with :switch-account <account-name>. The
completions for the switch-account command will list the available
accounts. If switch-account is run without arguments, the current
account name with the correct usage is displayed.

Fixes: https://todo.sr.ht/~rjarry/aerc/72
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-09-19 21:26:34 +02:00
Moritz Poldrack af9390d38b attach: enable path globbing
Enable path globbing using Go's standard library globbing capabilities,
which allows for attaching multiple files at once.

Suggested-by: Anderson John Njahi <johnjahi55@gmail.com>
Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-30 22:23:24 +02:00
Moritz Poldrack 978d35d356 lint: homogenize operations and minor fixes (gocritic)
Apply GoDoc comment policy (comments for humans should have a space
after the //; machine-readable comments shouldn't)

Use strings.ReplaceAll instead of strings.Replace when appropriate

Remove if/else chains by replacing them with switches

Use short assignment/increment notation

Replace single case switches with if statements

Combine else and if when appropriate

Signed-off-by: Moritz Poldrack <moritz@poldrack.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-04 21:58:01 +02:00
Moritz Poldrack aaf0a0c656 lint: apply new formatting rules
Run `make fmt`.

Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-01 10:44:52 +02:00
Stas Rudakou ca90343850 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>
2022-07-31 19:53:13 +02:00
Robin Jarry cd19995557 logging: use level-based logger functions
Do not pass logger objects around anymore. Shuffle some messages to make
them consistent with the new logging API. Avoid using %v when a more
specific verb exists for the argument types.

The loggers are completely disabled (i.e. Sprintf is not even called)
by default. They are only enabled when redirecting stdout to a file.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
2022-07-23 22:52:15 +02:00
Robin Jarry 171fefd209 tabs: make fields private
The Tabs object exposes an array of Tab objects and the current selected
index in that array. The these two fields are sometimes modified in
goroutines, which can lead to data races causing fatal out of bounds
accesses on the tab array.

Hide these fields as private API. Expose only what needs to be seen from
the outside. This will prepare for protecting concurrent access with
a lock in the next commit.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Koni Marti <koni.marti@gmail.com>
2022-07-23 22:00:25 +02:00
Robin Jarry c841f36513 tabs: rename SelectedTab to SelectedTabContent
This function returns an ui.Drawable. Use a more explicit name. This
prepares for adding a new SelectedTab function which will return
an ui.Tab.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Koni Marti <koni.marti@gmail.com>
2022-07-23 22:00:21 +02:00
Koni Marti 76b39311dc send: enter no-quit mode until message is sent
Protect the sending of a message by entering the no-quit mode. This
prevents aerc from exiting with the :quit command until the operation is
done or the exit is forced.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-14 23:15:13 +02:00
Koni Marti 99b74dbcc9 postpone: avoid calling WriteMessage twice
Postpone will currently call composer.WriteMessage twice: once for
counting the bytes and another time for appending the message.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-10 20:36:24 +02:00
Koni Marti 9d90b70b4e compose: refactor attachment handling
Refactor the attachment handling process in the composer. The composer
can currently only handle attachments that are stored as files (or pgp
keys). This patch removes this limitation so that any message part can
be handled as an attachment. With this we can treat files, pgp keys and
message parts on an equal footing and it will enable us also to easily
forward attachments.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Tim Culverhouse <tim@timculverhouse.com>
2022-07-02 17:52:49 +02:00
Tim Culverhouse b57fceaad4 pgp: add attach key command
Add compose command ("attach-key") to attach the public key associated
with the sending account. Public key is attached in ascii armor format,
with the mimetype set according to RFC 3156 ("application/pgp-keys").

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Tested-by: Koni Marti <koni.marti@gmail.com>
2022-05-06 11:02:55 +02:00
Tim Culverhouse 32a16dcd8d pgp: check encryption keys before sending message
Add check for public keys of all message recipients (to, cc, and bcc)
before sending the message. Adds an OnFocusLost callback to header
editors to facilitate a callback for checking keys whenever a new
recipient is added (OnChange results in too many keyring checks).

Once encryption is initially set, the callbacks are registered. If a
public key is not available for any recipient, encryption is turned off.
However, notably, the callbacks are still registered meaning as s soon
as the user removes the recipients with missing keys, encryption is
turned back on.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Tested-by: Koni Marti <koni.marti@gmail.com>
2022-05-06 11:02:50 +02:00
Tim Culverhouse dbf52bb4b4 pgp: check for signing key before signing time
Check that the signing key exists when the user issues the :sign
command. The signing key ID will be displayed in the security status
also, allowing the user to see what key will be used to sign the
message.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Tested-by: Jens Grassel <jens@wegtam.com>
2022-05-04 14:07:15 +02:00
Moritz Poldrack 4dbdf58688 fix: out-of-bounds error in command header
This commit fixes an out-of-bound error that happened while parsing
commands.

Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-04-06 15:37:13 +02:00
Moritz Poldrack 3c08b8e6a9 header: remove trailing colon in header field
With this commit trailing colons in the :header command's field are
removed to prevent double-colon-headers from being sent.

Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-04-06 15:37:13 +02:00
Moritz Poldrack ae83373fa6 logging: added a log on panic
Since panics still regularly "destroy" the terminal, it is hard to get a
stack trace for panics you do not anticipate. This commit adds a panic
handler that automatically creates a logfile inside the current working
directory.

It has to be added to every goroutine that is started and will repair
the terminal on a panic.

Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-03-23 20:56:09 +01:00
Moritz Poldrack 4bc43d2741 all: fix minor issues found by staticcheck
Signed-off-by: Moritz Poldrack <git@moritz.sh>
2022-03-12 21:00:23 +01:00
kt programs cc172970a0 commands: implement fuzzy completion for commands and options
Change the option to enable fuzzy completion to be fuzzy-complete, since
it's no longer only used for folders

Signed-off-by: Kt Programs <ktprograms@gmail.com>
Acked-by: Koni Marti <koni.marti@gmail.com>
2022-03-07 10:18:50 +01:00
Robin Jarry c26d08103b aerc: always check SelectedAccount return value
aerc.SelectedAccount() is used in lots of places. Most of them without
checking the return value.

In some cases, the currently selected tab is not related to any account
(widget.Terminal for example). This can lead to unexpected crashes when
accessing account specific configuration.

When possible, return an error when no account is currently selected.
If no error can be returned, fallback to non-account specific
configuration.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Reviewed-by: Koni Marti <koni.marti@gmail.com>
2022-02-25 13:56:53 +01:00
Koni Marti 4bd4f4664a postpone: re-open review mode on error
re-opens the review UI when the postpone operation fails. Before, the
composer would close, even on error, and we would lose the email draft.
Now, the user can decide on how to proceed when postponing fails.

References: https://lists.sr.ht/~rjarry/aerc-devel/patches/28824
Signed-off-by: Koni Marti <koni.marti@gmail.com>
2022-02-06 17:06:20 +01:00
Koni Marti b19b844a63 pgp: PGP/MIME encryption for outgoing emails
implements PGP/MIME encryption with go-pgpmail. The Encrypt() function of
go-pgpmail requires a list of public keys which are taken from the
keystore. The keystore is searched for the email addresses of all
recipients (to, cc, and bcc).
If you want to be able to read the encrypted email afterwards, add
yourself as a recipient in either to, cc, or bcc as well.

Public keys can be exported from gpg into aerc as follows:
$ gpg --export  >> ~/.local/share/aerc/keyring.asc

When composing a message, the encryption is enabled with the
":encrypt" command. This sets a bool flag in the Composer struct.
A reapted application of this command will toggle the flag.
The encrypted message can also be signed by using the ":sign"
command before or after ":encrypt".

References: https://todo.sr.ht/~rjarry/aerc/6
Signed-off-by: Koni Marti <koni.marti@gmail.com>
2022-01-07 13:45:34 +01:00
Koni Marti 69d4e3895f pgp: PGP/MIME signing for outgoing emails
implements PGP/MIME signing with go-pgpmail. The Sign() function of
go-pgpmail requires a private (signing) key. The signing key which matches
the senders email address (from field in email header) is looked up
in aerc's copy of the keyring.

Private keys can be exported from gpg into aerc as follows:
$ gpg --export-secret-keys  >> ~/.local/share/aerc/keyring.asc

A message is signed with the ":sign" command. The sign command sets
a bool flag in the Composer struct. Using the command repeatedly will
toggle the flag.

References: https://todo.sr.ht/~rjarry/aerc/6
Signed-off-by: Koni Marti <koni.marti@gmail.com>
2022-01-07 13:45:34 +01:00
Robin Jarry 0d645bcebd go.mod: change base git url
I'm not sure what are the implications but it seems required.

Link: https://github.com/golang/go/issues/20883
Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-11-05 10:21:45 +01:00
Reto Brunner 8cd2485170 send: fix missing error return 2021-02-28 02:05:12 +01:00
Reto Brunner 2d2010fd42 send: fix crash if invalid password is given 2021-02-05 21:20:17 +01:00
Reto Brunner 8ea86cea41 Get rid of the aerc.PushError(" " + $string) idiom
The individual callers should not be responsible for padding
2021-01-30 14:04:23 +01:00
Reto Brunner 9385827cae send: don't block the UI thread during the sending 2021-01-24 18:00:23 +01:00
Reto Brunner 67923707ff Refactor send command 2020-11-21 15:40:50 +01:00
Reto Brunner 256af6322b allow the loading of existing headers 2020-11-14 15:40:13 +01:00
Reto Brunner 24f1c575ae format: remove parse methods, use the one from go-message 2020-11-14 15:40:13 +01:00
Reto Brunner 20ec2c8eeb compose: use a proper header instead of a string map
Prior to this commit, the composer was based on a map[string]string.
While this approach was very versatile, it lead to a constant encoding / decoding
of addresses and other headers.

This commit switches to a different model, where the composer is based on a header.
Commands which want to interact with it can simply set some defaults they would
like to have. Users can overwrite them however they like.

In order to get access to the functions generating / getting the msgid go-message
was upgraded.
2020-11-14 15:40:13 +01:00
y0ast 42ce6b41ff propagate error from sendmail 2020-09-22 08:12:38 +02:00
R Chowdhury f4dc7e1f74 Add `oauthbearer` support for SMTP
This piggybacks on the existing IMAP support, and uses the same
configuration format (my local testing example has the IMAP and SMTP
lines almost copy-pasted from one another).

It's a little clumsy in that a new token is negotiated for every
`Send()` command, but it's a start...
2020-08-13 07:44:43 +02:00
Kalyan Sriram 905cb9dfd3 Implement style configuration.
Introduce the ability to configure stylesets, allowing customization of
aerc's look (color scheme, font weight, etc). Default styleset is
installed to /path/to/aerc/stylesets/default.
2020-08-06 21:42:06 +02:00
Reto Brunner 3d784c5d8c Revert "Implement style configuration."
This reverts commit 1ff687ca2b.
2020-07-30 23:22:32 +02:00
Kalyan Sriram 1ff687ca2b Implement style configuration.
Introduce the ability to configure stylesets, allowing customization of
aerc's look (color scheme, font weight, etc). Default styleset is
installed to /path/to/aerc/stylesets/default.
2020-07-30 19:35:59 +02:00
Heiko Carrasco 749dbb93a4 Use PushStatus instead of SetStatus where it makes sense 2020-07-09 08:37:01 +02:00
Drew DeVault caad1b2c06 Revert "Add Style configuration"
This reverts commit 0f78f06610.
2020-05-28 10:32:42 -04:00
Drew DeVault 76a91813d8 Revert "Remove duration from the status methods"
This reverts commit f06d683688.
2020-05-28 10:32:32 -04:00
Reto Brunner f06d683688 Remove duration from the status methods
We always set 10 seconds anyhow, might as well do that without repeating ourselfs.
2020-05-27 08:11:40 +02:00
Reto Brunner 0f78f06610 Add Style configuration
The following functionalities are added to configure aerc ui styles.
- Read stylesets from file with very basic fnmatch wildcard matching
- Add default styleset
- Support different stylesets as part of UiConfig allowing contextual
  styles.
- Move widgets/ui elements to use the stylesets.
- Add configuration manual for the styleset
2020-05-27 07:57:10 +02:00
Srivathsan Murali b1eb7ad18d Set AnsweredFlag on successful reply 2020-05-25 11:29:53 -04:00
Drew DeVault 3ba836003a gofmt 2020-05-19 12:11:43 -04:00
elumbella d8533e897a Show 'Message sent' only for ten seconds instead of permanently 2020-05-11 09:46:57 -04:00
Ray Ganardi b650bb30a2 Implement :header command
Usage: *header* [-f] <field> [value]
	Add a new email header. If the header already exists, -f must be
	specified to replace the given value.
2020-05-01 11:01:28 -04:00