You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
closes#13585fixes#9067fixes#2386
ref #6226
ref #6219fixes#745
This PR adds support to process incoming emails to perform actions.
Currently I added handling of replies and unsubscribing from
issues/pulls. In contrast to #13585 the IMAP IDLE command is used
instead of polling which results (in my opinion 😉) in cleaner code.
Procedure:
- When sending an issue/pull reply email, a token is generated which is
present in the Reply-To and References header.
- IMAP IDLE waits until a new email arrives
- The token tells which action should be performed
A possible signature and/or reply gets stripped from the content.
I added a new service to the drone pipeline to test the receiving of
incoming mails. If we keep this in, we may test our outgoing emails too
in future.
Co-authored-by: silverwind <[email protected]>
Co-authored-by: Lunny Xiao <[email protected]>
Copy file name to clipboardExpand all lines: docs/content/doc/advanced/config-cheat-sheet.en-us.md
+14
Original file line number
Diff line number
Diff line change
@@ -750,6 +750,20 @@ and
750
750
-`SEND_BUFFER_LEN`: **100**: Buffer length of mailing queue. **DEPRECATED** use `LENGTH` in `[queue.mailer]`
751
751
-`SEND_AS_PLAIN_TEXT`: **false**: Send mails only in plain text, without HTML alternative.
752
752
753
+
## Incoming Email (`email.incoming`)
754
+
755
+
-`ENABLED`: **false**: Enable handling of incoming emails.
756
+
-`REPLY_TO_ADDRESS`: **\<empty\>**: The email address including the `%{token}` placeholder that will be replaced per user/action. Example: `incoming+%{token}@example.com`. The placeholder must appear in the user part of the address (before the `@`).
757
+
-`HOST`: **\<empty\>**: IMAP server host.
758
+
-`PORT`: **\<empty\>**: IMAP server port.
759
+
-`USERNAME`: **\<empty\>**: Username of the receiving account.
760
+
-`PASSWORD`: **\<empty\>**: Password of the receiving account.
761
+
-`USE_TLS`: **false**: Whether the IMAP server uses TLS.
762
+
-`SKIP_TLS_VERIFY`: **false**: If set to `true`, completely ignores server certificate validation errors. This option is unsafe.
763
+
-`MAILBOX`: **INBOX**: The mailbox name where incoming mail will end up.
764
+
-`DELETE_HANDLED_MESSAGE`: **true**: Whether handled messages should be deleted from the mailbox.
765
+
-`MAXIMUM_MESSAGE_SIZE`: **10485760**: Maximum size of a message to handle. Bigger messages are ignored. Set to 0 to allow every size.
Gitea supports the execution of several actions through incoming mails. This page describes how to set this up.
18
+
19
+
**Table of Contents**
20
+
21
+
{{< toc >}}
22
+
23
+
## Requirements
24
+
25
+
Handling incoming email messages requires an IMAP-enabled email account.
26
+
The recommended strategy is to use [email sub-addressing](https://en.wikipedia.org/wiki/Email_address#Sub-addressing) but a catch-all mailbox does work too.
27
+
The receiving email address contains a user/action specific token which tells Gitea which action should be performed.
28
+
This token is expected in the `To` and `Delivered-To` header fields.
29
+
30
+
Gitea tries to detect automatic responses to skip and the email server should be configured to reduce the incoming noise too (spam, newsletter).
31
+
32
+
## Configuration
33
+
34
+
To activate the handling of incoming email messages you have to configure the `email.incoming` section in the configuration file.
35
+
36
+
The `REPLY_TO_ADDRESS` contains the address an email client will respond to.
37
+
This address needs to contain the `%{token}` placeholder which will be replaced with a token describing the user/action.
38
+
This placeholder must only appear once in the address and must be in the user part of the address (before the `@`).
39
+
40
+
An example using email sub-addressing may look like this: `incoming+%{token}@example.com`
41
+
42
+
If a catch-all mailbox is used, the placeholder may be used anywhere in the user part of the address: `incoming+%{token}@example.com`, `incoming_%{token}@example.com`, `%{token}@example.com`
43
+
44
+
## Security
45
+
46
+
Be careful when choosing the domain used for receiving incoming email.
47
+
It's recommended receiving incoming email on a subdomain, such as `incoming.example.com` to prevent potential security problems with other services running on `example.com`.
0 commit comments