Skip to content

Commit 617c123

Browse files
committed
Refine POP support; switch to true line-by-line parsing
Also add login_hint to OAuth permission URL and improve debug log messaging
1 parent ef46726 commit 617c123

File tree

2 files changed

+338
-252
lines changed

2 files changed

+338
-252
lines changed

emailproxy.config

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ documentation = This is a sample Email OAuth 2.0 Proxy configuration file. Confi
66

77
[Server setup]
88
documentation = Local servers are specified as demonstrated below where, for example, the section heading [IMAP-1993]
9-
gives the type (which can be IMAP or SMTP) and the local port to listen on (i.e., 1993, etc). The local port number
10-
must be above 1023 (unless the proxy script is run via sudo), below 65536, and unique across local servers. Multiple
11-
accounts can share the same server, however. Each server section must specify the `server_address` and `server_port`
12-
of the remote server that it will be proxying - you can obtain these values from your email provider, or use the
13-
details below for Office 365 and/or Gmail.
9+
gives the type (which can be IMAP, POP or SMTP) and the local port number to listen on (i.e., 1993, etc). The local
10+
port must be above 1023 (unless the proxy script is run via sudo), below 65536, and unique across local servers.
11+
Multiple accounts can share the same server, however. Each server section must specify the `server_address` and
12+
`server_port` of the remote server that it will be proxying - you can obtain these values from your email provider,
13+
or use the details below for Office 365 and/or Gmail.
1414

15-
To allow the proxy to operate, your email client must be set up to use an unencrypted connection for both SMTP and
16-
IMAP (i.e., no STARTTLS or SSL/TLS, just plain login credentials). The proxy will create a secure connection on your
15+
To allow the proxy to operate, your email client must be set up to use an unencrypted connection for IMAP/SMTP/POP
16+
(i.e., no STARTTLS or SSL/TLS, just plain login credentials). The proxy will create a secure connection on your
1717
behalf to the remote server from the outset by default (i.e., implicit SSL/TLS); see below if STARTTLS is required.
1818

1919
Server customisation:
2020
- If your SMTP server uses the STARTTLS approach, add `starttls = True`, as shown in the [SMTP-1587] example below
2121
(assumed to be False otherwise). With this parameter set, STARTTLS negotiation will be handled by the proxy on your
22-
behalf (i.e., do not enable STARTTLS in your client). IMAP STARTTLS is not currently supported.
22+
behalf (i.e., do not enable STARTTLS in your client). IMAP STARTTLS and POP STARTTLS are not currently supported.
2323

2424
- If the property `local_address` is not specified, its value is assumed to be `localhost`. If required, this
2525
parameter can be used to set an IP address or hostname for the proxy to listen on.
@@ -36,29 +36,37 @@ local_address = localhost
3636
server_address = outlook.office365.com
3737
server_port = 993
3838

39+
[POP-1995]
40+
server_address = outlook.office365.com
41+
server_port = 995
42+
3943
[SMTP-1587]
4044
server_address = smtp.office365.com
4145
server_port = 587
4246
starttls = True
4347

44-
[IMAP-1995]
48+
[IMAP-2993]
4549
server_address = imap.gmail.com
4650
server_port = 993
4751

48-
[SMTP-1465]
52+
[POP-2995]
53+
server_address = pop.gmail.com
54+
server_port = 995
55+
56+
[SMTP-2465]
4957
server_address = smtp.gmail.com
5058
server_port = 465
5159

5260

5361
[Account setup]
5462
documentation = Accounts are specified using your email address as the section heading (e.g., [[email protected]],
55-
below). Account usernames (i.e., email addresses) must be unique - only one entry per account is permitted. Each
56-
account section must provide values for `permission_url`, `token_url`, `oauth2_scope` and `redirect_uri`. If you
57-
are adding an account for a service other than Office 365 or Gmail then the provider's documentation should give
58-
these details. For Gmail and Office 365 you can simply copy the values from the examples below.
63+
etc, below). Account usernames (i.e., email addresses) must be unique - only one entry per account is permitted.
64+
Each account section must provide values for `permission_url`, `token_url`, `oauth2_scope` and `redirect_uri`. If
65+
you are adding an account for a service other than the examples shown below then the provider's documentation should
66+
provide these details.
5967

6068
You will also need to add your own `client_id` and `client_secret` values as indicated below. These can either be
61-
copied from an existing source (such as another email client that supports OAuth 2.0), or you can register and use
69+
reused from an existing source (such as another email client that supports OAuth 2.0), or you can register and use
6270
your own desktop app API client credentials. See https://developers.google.com/identity/protocols/oauth2/native-app
6371
and the Microsoft link below for details. Multiple accounts on the same server can use the same values for the
6472
`client_id` and `client_secret` properties; just duplicate these in each account's entry below. Note that there are
@@ -68,8 +76,9 @@ documentation = Accounts are specified using your email address as the section h
6876
Once the proxy is correctly configured, after the first successful use of an account its access token details will
6977
be cached in this configuration file, encrypted with the password you use in your email client. The password set in
7078
your email client is not used for authentication (which is done separately via a web browser), so it can be
71-
different to your real account password, which is helpful for debugging. See the proxy's readme for more information
72-
and further configuration options: https://github.com/simonrob/email-oauth2-proxy/blob/main/README.md.
79+
different to your real account password, which is helpful for debugging. Please note, though, that all clients that
80+
use a particular account via the proxy should use the same password to avoid repeated re-authentication requests.
81+
See the proxy's README.md file for more information and further configuration options.
7382

7483
Office 365 customisation:
7584
- If your Office 365 configuration requires a tenant ID, place it in both `permission_url` and `token_url` in place
@@ -88,7 +97,7 @@ documentation = Accounts are specified using your email address as the section h
8897
8998
permission_url = https://login.microsoftonline.com/common/oauth2/v2.0/authorize
9099
token_url = https://login.microsoftonline.com/common/oauth2/v2.0/token
91-
oauth2_scope = https://outlook.office365.com/IMAP.AccessAsUser.All https://outlook.office365.com/SMTP.Send offline_access
100+
oauth2_scope = https://outlook.office365.com/IMAP.AccessAsUser.All https://outlook.office365.com/POP.AccessAsUser.All https://outlook.office365.com/SMTP.Send offline_access
92101
redirect_uri = http://localhost
93102
client_id = *** your client id here ***
94103
client_secret = *** your client secret here ***

0 commit comments

Comments
 (0)