dgtlmoon / changedetection.io

The best and simplest free open source web page change detection, website watcher, restock monitor and notification service. Restock Monitor, change detection. Designed for simplicity - Simply monitor which websites had a text change for free. Free Open source web page change detection, Website defacement monitoring, Price change notification
https://changedetection.io
Apache License 2.0
15.84k stars 884 forks source link

[Bug]: (apprise) E-mail notifications broken to email servers by IP address #2324

Closed kroese closed 1 month ago

kroese commented 2 months ago

Since very recently the e-mail (SMTP) notifications do not function anymore. I think this was introduced somewhere between v0.45.18 and v0.45.20.

Also I do not see any button anymore to send a test notification, making the problem harder to debug (but that might be a separate bug).

The error I get is:

SENDING - null
smtplib.SMTPServerDisconnected: please run connect() first
raise SMTPServerDisconnected('please run connect() first')
File "/usr/local/lib/python3.10/smtplib.py", line 365, in send
self.send(f'{s}{CRLF}')
File "/usr/local/lib/python3.10/smtplib.py", line 378, in putcmd
self.putcmd(cmd, args)
File "/usr/local/lib/python3.10/smtplib.py", line 431, in docmd
res = self.docmd("quit")
File "/usr/local/lib/python3.10/smtplib.py", line 1004, in quit
socket.quit()
File "/usr/local/apprise/plugins/NotifyEmail.py", line 921, in submit
return self.submit(messages)
File "/usr/local/apprise/plugins/NotifyEmail.py", line 855, in send
the_calls = [self.send(**kwargs2) for kwargs2 in send_calls]
File "/usr/local/apprise/plugins/NotifyBase.py", line 382, in <listcomp>
the_calls = [self.send(**kwargs2) for kwargs2 in send_calls]
File "/usr/local/apprise/plugins/NotifyBase.py", line 382, in notify
result = server.notify(**kwargs)
File "/usr/local/apprise/Apprise.py", line 582, in _notify_sequential
Traceback (most recent call last):
2024-04-19 15:44:13,815 - ERROR - Unhandled Notification Exception
2024-04-19 15:44:13,815 - WARNING - Sending email to "alerts@example.com" failed. Reason: please run connect() first
2024-04-19 15:44:13,814 - DEBUG - Connecting to remote SMTP server...
2024-04-19 15:44:13,811 - DEBUG - Delivery: :2225
2024-04-19 15:44:13,811 - DEBUG - Login ID: None
2024-04-19 15:44:13,811 - DEBUG - Email To: alerts@example.com
2024-04-19 15:44:13,811 - DEBUG - Email From: sender@example.com
2024-04-19 15:44:13,811 - DEBUG - Loaded E-Mail URL: mailto://:2225/alerts%40example.com?format=html&overflow=upstream&rto=4.0&cto=15&verify=yes&from=sender%40example.com

The notification URL is:

mailto://10.0.0.195:2225/?to=alerts@example.com&from=sender@example.com

This a local postfix server without any authentication, and it doesnt even receive any incoming request.

This configuration has always worked and I didnt make any changes (except for updating the container) when it stopped working.

From the log this looks suspicous:

E-Mail URL: mailto://:2225/alerts%40example.com?format=html&overflow=upstream&rto=4.0&cto=15&verify=yes&from=sender%40example.com

It seems like it stripped the hostname from the URL, which would explain why it cannot connect.

Version v0.45.20

To Reproduce

Create a notification URL like this:

mailto://10.0.0.195:2225/?to=alerts@example.com&from=sender@example.com

It fails to send any mail and it also doesnt show any test button.

Expected behavior

Emails that get delivered

dgtlmoon commented 2 months ago

please try it first from the command line

echo hello|apprise mailto://10.0.0.195:2225/?to=alerts@example.com&from=sender@example.com

it is not a bug with changedetection but rather with apprise, does it work from the CLI?

and tell me the version of apprise installed pip3 list

kroese commented 2 months ago

Its version 1.7.6 and when I execute that command I get:

ERROR: There are no service(s) to notify

but the Loaded E-Mail URL contains the IP like expected, while in the Change Notification log the IP is stripped from that line.

dgtlmoon commented 2 months ago

So its a problem in 1.7.6 of apprise then...

pip3 install apprise==1.7.5

$ ls|apprise "mailto://10.0.0.195:2225/?to=alerts@example.com&from=sender@example.com" -v
2024-04-20 00:05:05,126 - WARNING - Connection error while submitting email to 10.0.0.195. Reason: [Errno 111] Connection refused

pip3 install apprise==1.7.6

$ ls|apprise "mailto://10.0.0.195:2225/?to=alerts@example.com&from=sender@example.com" -v
2024-04-20 00:05:57,440 - WARNING - Sending email to "alerts@example.com" failed. Reason: please run connect() first
2024-04-20 00:05:57,440 - ERROR - Unhandled Notification Exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/apprise/Apprise.py", line 582, in _notify_sequential
    result = server.notify(**kwargs)
  File "/usr/local/lib/python3.10/dist-packages/apprise/plugins/NotifyBase.py", line 382, in notify
    the_calls = [self.send(**kwargs2) for kwargs2 in send_calls]
  File "/usr/local/lib/python3.10/dist-packages/apprise/plugins/NotifyBase.py", line 382, in <listcomp>
    the_calls = [self.send(**kwargs2) for kwargs2 in send_calls]
  File "/usr/local/lib/python3.10/dist-packages/apprise/plugins/NotifyEmail.py", line 855, in send
    return self.submit(messages)
  File "/usr/local/lib/python3.10/dist-packages/apprise/plugins/NotifyEmail.py", line 921, in submit
    socket.quit()
  File "/usr/lib/python3.10/smtplib.py", line 1004, in quit
    res = self.docmd("quit")
  File "/usr/lib/python3.10/smtplib.py", line 431, in docmd
    self.putcmd(cmd, args)
  File "/usr/lib/python3.10/smtplib.py", line 378, in putcmd
    self.send(f'{s}{CRLF}')
  File "/usr/lib/python3.10/smtplib.py", line 365, in send
    raise SMTPServerDisconnected('please run connect() first')
smtplib.SMTPServerDisconnected: please run connect() first

@kroese please can you make an issue over at caronc/apprise? this is not our fault here

dgtlmoon commented 2 months ago

@kroese please make an issue at https://github.com/caronc/apprise and link this issue in the issue comment

kroese commented 2 months ago

Okay, thanks! I reported it and will take it further with them.

On a sidenote, do you have any idea why I dont see the button to test notifications in v0.45.20? I know you recently changed something in that area of the code, but I cant find it anywhere.

dgtlmoon commented 2 months ago

On a sidenote, do you have any idea why I dont see the button to test notifications in v0.45.20? I know you recently changed something in that area of the code, but I cant find it anywhere.

hmm please open a new issue and include some screenshots and which browser/platform/browser version etc