Commit Graph

120 Commits

Author SHA1 Message Date
Rodolfo García Peñas (kix) 3d925b006a Changed wrong comparison equal
Backported from:
e84e932df4

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2020-08-29 22:54:15 +02:00
Chris Coleman 84efb45270 Handle [ALREADYEXISTS] and Mailbox already exists!
Make compatible with IMAP servers that give the reason code "[ALREADYEXISTS]"
and IMAP servers that give natural language reason "Mailbox already exists!" by
searching for the two words "already" and "exists" in the exception reason
string.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2020-02-06 19:10:33 +01:00
Nicolas Sebrecht 0d865c2e36 repository/IMAP: update copyright header date
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-02-27 08:48:59 +01:00
Kyle Altendorf 57a43f5bba mkdir -p alike folder creation
When creating a folder in one command on Gmail you end up with
one tag such as 'x/y/z' instead of three nested tags such as 'z'
inside of 'y' inside of 'x'.  Creating each layer individually
results in the desired nested label structure.

This was tested in a personal transfer of email from a remote
IMAP server to Gmail.

OfflineIMAP/offlineimap#335
OfflineIMAP/offlineimap#598

Signed-off-by: Kyle Altendorf <sda@fstab.net>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2019-02-27 08:45:57 +01:00
velleto c126b4286d Allow users to keep colons between each hex pair of server certificate fingerprint in configuration file.
Signed-off-by: velleto <rr@velleto.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2018-05-15 00:39:59 +02:00
Nicolas Sebrecht 5836970d51 utf8foldernames: fix missing decode argument
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/502
Tested-by: https://github.com/pprw
Reviewed-by: Ilias Tsitsimpis <i.tsitsimpis@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-10-29 00:45:32 +02:00
Nicolas Sebrecht a79263bb31 utf8foldernames: support --delete-folder with UTF-8 folder name
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/505
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-10-29 00:44:39 +02:00
Urs Liska 36d726763d utf8: implement utf8foldernames option
If utf8foldernames is enabled on account level all folder names read
from the IMAP server will immediately be reencoded to UTF-8. Names
will be treated as UTF-8 as long as the IMAP server isn't contacted again,
for which they are reencoded to IMAP4-UTF-7.

This means that any further processing such as nametrans, folderfilter
etc. will act upon the UTF-8 names, which will have to be documented
carefully.

NOTE 1:
GMail repositories and folders inherit from the IMAP... classes, so I don't
know yet if these changes have ugly side-effects. But web research suggests
that GMail IMAP folders are equally encoded in UTF-7 so that should work
identically here and incorporate the same improvements.

NOTE 2:
I could not test the behaviour with idlefolders as I didn't get this option
to work at all, not even with the latest stable version.

NOTE 3:
I *did* test to sync an IMAP repository against another IMAP repository.

Signed-off-by: Urs Liska <git@ursliska.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-10-02 21:09:43 +02:00
Urs Liska 14d83dbf48 utf8: avoid dequoting IMAP folder names twice
Signed-off-by: Urs Liska <git@ursliska.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-10-02 21:09:43 +02:00
Stéphane Graber e3bbf75feb Fix ipv6 configuration handling
According to documentation and the code, the following behavior is expected:

ipv6 = no
    AF_INET is used

ipv6 = yes
    AF_INET6 is used

ipv6 undefined
    AF_UNDEF is used

Unfortunately the code parsing the "ipv6" configuration option was
returning "False" rather than "None" when failing to locate the option,
making it impossible to detect whether "ipv6" isn't set or if it was set
to "false" and leading offlineimap to use AF_INET for the connection.

This fixes the use of offlineimap on hosts that occasionaly are
connected to IPv6-only networks.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-02-03 18:43:02 +01:00
Nicolas Sebrecht 11655cb613 repository: IMAP: correctly check the response while listing remote folders
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/423
Reported-by: Periklis Tsirakidis <periklis.tsirakidis@mayflower.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2017-01-22 19:20:32 +01:00
Nicolas Sebrecht bd4b968f1d repository: IMAP: cache the idle folders in memory
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-09-20 02:36:56 +02:00
Nicolas Sebrecht 9c386154bb XOAUTH2: correctly strip values for evaluated credentials
Don't use lambda anymore as default value.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-14 23:33:37 +02:00
Nicolas Sebrecht 13043b5877 XOAUTH2: strip newlines of the returned values for the eval configuration options
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-14 23:17:09 +02:00
Nicolas Sebrecht 00e6627299 XOAUTH2: function was changed to not have argument
Fix the default lambda.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-14 23:13:25 +02:00
Nicolas Sebrecht b4fe69028b XOAUTH2: let the user call the evaluated functions in the configuration
Don't pass the account name to the function returned by eval. This allows the
user to define his own arguments.

This fix the code according to the documentation provided in offlineimap.conf.

Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/372
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-08-14 22:35:09 +02:00
Nicolas Sebrecht 9aa5afa951 XOAUTH2: fix the *_eval configuration options
They introduce a regression not allowing to discard the XOAUTH2 method when
expected.

The default lambda did not take the "account_name" argument.

Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/362
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-29 16:38:58 +02:00
Nicolas Sebrecht b4e33eeac4 XOAUTH2: use one "public" attribute everywhere for self.oauth2_request_url
Improve documentation.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-28 18:35:33 +02:00
Nicolas Sebrecht 0b824bdc49 offlineimap.conf: allow non-spaces in the account list
Commit c992f58530 pretends to fix this bug it doesn't.

Regression introduced in v7.0.0.

Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/355
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-28 04:06:52 +02:00
Nicolas Sebrecht 88e8a4895e minor code enhancements
- More class inherit from object.
- Initialize all attributes.
- Code style.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-28 00:42:35 +02:00
Nicolas Sebrecht b521b98d99 offlineimap.conf: learn to evaluate oauth2 related options
Introduce:
- oauth2_client_id_eval
- oauth2_client_secret_eval
- oauth2_access_token_eval
- oauth2_refresh_token_eval

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/307
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-27 04:25:18 +02:00
Nicolas Sebrecht 1a96d588d5 fix: configparser does not know about python types like u""
Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/347
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-13 14:02:25 +02:00
Nicolas Sebrecht 2e81331a3c learn --delete-folder CLI option
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-08 21:34:25 +02:00
Nicolas Sebrecht 29e06a60f9 learn to not download UIDs defined by the user
Allow users to workaround offending emails that offlineimap can't download.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-03 20:02:45 +02:00
Nicolas Sebrecht 7945e10a76 correctly reraise errors with six
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-07-03 19:56:14 +02:00
Nicolas Sebrecht cf5698b6a6 repository: IMAP: minor improvements
Make it clear what value is the default.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-26 17:02:28 +02:00
Nicolas Sebrecht ac2a547ec4 learn to disable STARTTLS
Some servers might have this feature broken.

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/207
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-26 17:01:01 +02:00
Nicolas Sebrecht 08e17de7e2 require usernames and passwords to be UTF-8 encoded
- Learn to support UTF-8 characters where it was not supported for usernames and
  passwords (but for netrc).
- Fix the types in the code for both py2 and py3: we now expect unicode for
  usernames and passwords.

Unicode (UTF-8) is required only for variables with non-ASCII characters.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-26 16:57:22 +02:00
Nicolas Sebrecht 8c9f63a9b5 repository/IMAP: add minor comment
Some minor cleanups on whitespaces.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-06-08 16:01:58 +02:00
Nicolas Sebrecht a2a8a908ca threading: fix variable names about namespaces
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-19 08:36:23 +02:00
Łukasz Żarnowiecki 0addcbabf0 py3: raise exceptions using six module
There is no other way to make Python2 and Python3 happy, because syntax
raise E, V, T is incompatible with the latter.

Signed-off-by: Łukasz Żarnowiecki <dolohow@outlook.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-18 01:49:09 +02:00
Łukasz Żarnowiecki 4fbb5640ac Convert basestring to str
Signed-off-by: Łukasz Żarnowiecki <dolohow@outlook.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-05-10 02:53:09 +02:00
Nicolas Sebrecht 2fb2f840dc XOAUTH2: don't force oauth2_request_url to be defined
Not all users want XOAUTH2.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-04-25 18:38:31 +02:00
Nicolas Sebrecht 2fc5d2a814 XOAUTH2: raise error when oauth_request_url is missing for IMAP type
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-04-25 17:38:42 +02:00
Nicolas Sebrecht 9486a0dab3 IMAP: don't try to create empty folders
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-04-09 17:35:15 +02:00
Ebben Aries 9bfd610230 change hard coding of AF_UNSPEC to user-defined address-families per repository
Some environments that return AAAA records for their IMAP servers can pose
problems for clients that do not have end-to-end IPv6 connectivity for a number
of reasons (e.g. policy, lack of full routing, security, etc..)

Even with a fallback mechanism in place, you can still arrive at IMAP
implementations that could prevent authentication from unknown IPv6 space. This
in itself is not enough to fallback to IPv4 since there is an actual connection
on that socket.

This change is for introducing a user-defined value:

  [Repository imap-remote]
  ipv6 = no

to create a preference per repository on which AF to connect to the remote
server on

ipv6 = yes (AF_INET6)
ipv6 = no (AF_INET)
unspecified = default

Signed-off-by: Ebben Aries <e@dscp.org>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2016-02-23 06:57:21 +01:00
ojab cfa704bbf2 Allow authorization via XOAUTH2 using access token
Signed-off-by: Slava Kardakov <ojab@ojab.ru>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-12-30 00:25:57 +01:00
Max Vilimpoc 1becbff786 enable SSL by default
Fix-github-issue: #263
Signed-off-by: Max Vilimpoc <github@vilimpoc.org>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-10-29 16:13:44 +01:00
Ben Boeckel f03afcd224 imapserver: add a tls_level option
Allow the user to block usage of known-bad versions of SSL and TLS.

Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-10-12 15:54:15 +02:00
Nicolas Sebrecht af640208e1 make XOAUTH2 configuration option optional
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-10-12 07:42:30 +02:00
Nicolas Sebrecht ebb2124dbb Merge branch 'Frizlab-gmail-oauth-2' into next 2015-10-06 14:25:15 +02:00
Christopher Corley f7efaa2093 learn XOAUTH2 authentication
Signed-off-by: François Lamboley <francois.lamboley@happn.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-10-06 14:24:42 +02:00
Nicolas Sebrecht 55ca922dd1 Merge branch 'krafczyk-new-mail-hook-2' into next 2015-09-11 21:04:52 +02:00
Matthew Krafczyk 48bb2f4113 Added the newmail_hook
When new mail arrives, this hook is triggered, allowing the user to
play a sound, or launch a popup.

Signed-off-by: Matthew Krafczyk <krafczyk.matthew@gmail.com>
2015-09-11 20:34:38 +02:00
Tommie Gannert a6e7b6627b Add decodefoldernames option to decode IMAP folder names using UTF-7.
Signed-off-by: Tommie Gannert <tommie@gannert.se>
2015-08-29 16:43:33 +01:00
Nicolas Sebrecht 6d72fd74af Merge branch 'holomorph-remoteuser' into next 2015-03-10 23:06:17 +01:00
Mark Oteiza a629b4e0e7 do not error if `remoteuser` is not configured
Signed-off-by: Mark Oteiza <mvoteiza@udel.edu>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-03-10 23:06:09 +01:00
Nicolas Sebrecht 461554b7b1 more style consistency
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-02-10 17:25:00 +01:00
Eygene Ryabinkin f69613965f Make OS-default CA certificate file to be requested explicitely
This simplifies logics for the user, especially if he uses both
fingerprint and certificate validation: it is hard to maintain
the compatibility with the prior behaviour and to avoid getting
default CA bundle to be disabled when fingerprint verification
is requested.

See
  http://thread.gmane.org/gmane.mail.imap.offlineimap.general/6695
for discussion about this change.

Default CA bundle is requested via 'sslcertfile = OS-DEFAULT'.

I had also enforced all cases where explicitely-requested CA bundles
are non-existent to be hard errors: when users asks us to use CA
bundle (and, thus, certificate validation), but we can't find one,
we must error out rather than happily continue and downgrade to
no validation.

Reported-By: Edd Barrett <edd@theunixzoo.co.uk>
Reviewed-By: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
2015-01-18 22:05:49 +03:00
Nicolas Sebrecht 41fa3ae4fc more style consistency
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-01-13 18:16:25 +01:00