pulb / mailnag

An extensible mail notification daemon
GNU General Public License v2.0
250 stars 32 forks source link

mailnag can't connect after resuming from suspend #233

Closed cipman closed 1 year ago

cipman commented 2 years ago

$ lsb_release -d

$ dpkg -l | grep mailnag

 ii  mailnag                                     2.2.0-0~ubuntu20.04.1 
 ii  mailnag-goa-plugin                          2.0.0-1~ubuntu20.04.1 

I have only one gmail account set up through gnome online accouns.

$ cat ~/.config/mailnag/mailnag.cfg

[core]
poll_interval = 10
imap_idle_timeout = 10
mailbox_seen_flags = 1
autostart = 1
connectivity_test = auto
enabled_plugins = goaplugin, libnotifyplugin, soundplugin
[libnotifyplugin]
notification_mode = 3
max_visible_mails = 10
[soundplugin]
soundfile = mailnag.ogg
[spamfilterplugin]
filter_text = newsletter, viagra
[userscriptplugin]
script_file =

After resuming from suspend: $ journalctl -e -b _COMM=mailnag

iun 10 08:06:51 i5 mailnag[2053]: ERROR (2022-06-10 08:06:51): Idle callback for account 'myaccount' returned an error (<class 'Mailnag.common.imaplib2.IMAP4.abort'> - socket error: <class 'ConnectionResetError'> - [E>
iun 10 08:06:51 i5 mailnag[2053]: INFO (2022-06-10 08:06:51): Resetting connection for account 'myaccount'
iun 10 08:06:51 i5 mailnag[2053]: INFO (2022-06-10 08:06:51): Idler thread for account 'myaccount' has been disconnected
iun 10 08:06:51 i5 mailnag[2053]: INFO (2022-06-10 08:06:51): Trying to reconnect Idler thread for account 'myaccount'.
iun 10 08:06:52 i5 mailnag[2053]: ERROR (2022-06-10 08:06:52): Failed to reconnect Idler thread for account 'myaccount' (b'[AUTHENTICATIONFAILED] Invalid credentials (Failure)').
iun 10 08:06:52 i5 mailnag[2053]: INFO (2022-06-10 08:06:52): Trying to reconnect Idler thread for account 'myaccount' in 5 minutes
iun 10 08:11:52 i5 mailnag[2053]: INFO (2022-06-10 08:11:52): Trying to reconnect Idler thread for account 'myaccount'.
iun 10 08:11:54 i5 mailnag[2053]: ERROR (2022-06-10 08:11:54): Failed to reconnect Idler thread for account 'myaccount' (b'[AUTHENTICATIONFAILED] Invalid credentials (Failure)').
iun 10 08:11:54 i5 mailnag[2053]: INFO (2022-06-10 08:11:54): Trying to reconnect Idler thread for account 'myaccount' in 5 minutes
iun 10 08:16:54 i5 mailnag[2053]: INFO (2022-06-10 08:16:54): Trying to reconnect Idler thread for account 'myaccount'.
iun 10 08:16:56 i5 mailnag[2053]: ERROR (2022-06-10 08:16:56): Failed to reconnect Idler thread for account 'myaccount' (b'[AUTHENTICATIONFAILED] Invalid credentials (Failure)').
iun 10 08:16:56 i5 mailnag[2053]: INFO (2022-06-10 08:16:56): Trying to reconnect Idler thread for account 'myaccount' in 5 minutes
etc.

After 'Configure Mailnag' (nothing altered) seems to run ok till next resume from suspend: $ journalctl -e -b _COMM=mailnag

iun 10 09:42:52 i5 mailnag[2053]: INFO (2022-06-10 09:42:52): Shutting down...
iun 10 09:42:52 i5 mailnag[2053]: INFO (2022-06-10 09:42:52): Idler closed
iun 10 09:42:52 i5 mailnag[2053]: INFO (2022-06-10 09:42:52): Plugins disabled successfully.
iun 10 09:42:54 i5 mailnag[137748]: INFO (2022-06-10 09:42:54): Successfully enabled plugin 'libnotifyplugin'.
iun 10 09:42:54 i5 mailnag[137748]: INFO (2022-06-10 09:42:54): Successfully enabled plugin 'soundplugin'.
iun 10 09:42:54 i5 mailnag[137748]: INFO (2022-06-10 09:42:54): Successfully enabled plugin 'goaplugin'.
iun 10 09:42:54 i5 mailnag[137748]: INFO (2022-06-10 09:42:54): Checking 1 email account(s).
iun 10 09:44:19 i5 mailnag[137748]: INFO (2022-06-10 09:44:19): Checking 1 email account(s).
Matthew-Wai commented 1 year ago

After resuming, if you restart Mailnag without "Configure Mailnag", will it work properly?

cipman commented 1 year ago

In the meantime I found out that mailnag stops working after a day (or maybe less?) even when the system is working 24/7, so I'm not sure it has something to do with suspending. If I restart mailnag it works fine ... for a while.

Matthew-Wai commented 1 year ago

Next time when it does not work, run the following command to restart it:

killall mailnag && mailnag

See whether it will work fine. If it does, you may use Crontab to restart it automatically at intervals. Mailnag has never stopped working at my end

cipman commented 1 year ago

mailnag can't be started through crontab (user or root). Tried that some time ago. There are some old scripts on here (some other issues) to restart, no luck either.

I think "killall mailnag && mailnag" should be "killall mailnag; mailnag" - we don't need killall to be succesfull, not to mention mailnag kills the old instances upon restart (unless doesn't always succeed).

This project seems abandoned by the owner/creator, so I'll move away as soon as I'll find a good replacement - my phone seems to do the job for now.

Thank you for your input

SFBB commented 1 year ago

According to your log, it seems it is Gmail's configuration problem. It said your credentials are invalid.

Just google this message, and you will be guided to this link: https://stackoverflow.com/questions/33119667/reading-gmail-is-failing-with-imap

By the way, currently, as far as I know, mailnag doesn't support to use Gmail's API to retire mails which provides a more secure way. So enabling IMAP access to Gmail is a necessary step if you want to use mailnag.

P.S. And I guess that this project has not been actively maintained for a while is because its functions have been mature. I used it around 2018 last time and it really cannot handle VPN or suspend edge cases very well since request of python's freezing issue. And by following that issue, I find the maintainer has solved it very well. As a mail notification applet, I don't think it needs to extend so much. And for sure, supporting mainstream mail providers' API will be a surprising bonus!

cipman commented 1 year ago

Closed

cipman commented 1 year ago

Closed as I'm not interested in this project no more

Matthew-Wai commented 1 year ago

@SFBB You wrote "So enabling IMAP access to Gmail is a necessary step if you want to use mailnag."

In my Gmail settings, the option "Enable IMAP" has long since been selected. However, The option "Less secure app access" has been absent since May 30, 2022 as per the following page: https://support.google.com/accounts/answer/6010255?hl=en

Therefore, I cannot in any way use Mailnag to access Gmail. Do you have a solution? Can you access Gmail via Mailnag?

SFBB commented 1 year ago

Sorry for my out-of-date information. That is really bad news. No, I cannot.

Then in technical, you cannot use mailnag to access Gmail, you can request a feature of Gmail API support. I really want to contribute to this feature if I have time, but currently, I cannot help.

But if you are eager to do something, here is a starting point: https://developers.google.com/gmail/api/guides

And you can also use a mail client like thunderbird(with birdtray), mailspring et al. Currently, I use webmail, and nowadays, email with a browser works very well.

Matthew-Wai commented 1 year ago

@SFBB I just found the feature "Sign in with App Passwords" in the following page: https://support.google.com/accounts/answer/185833?hl=en

Perhaps that feature will allow Mailnag access to Gmail. I have used the same feature in my Yahoo Mail, which Mailnag can access.