Skip to content

Email alerter port: default to 587? #1621

@cpina

Description

@cpina

Simplemonitor uses port 25 when sending email. Should it default to port 587?

Usually outgoing email is to port 587 instead of 25.

The exception logged into the logs when simplemonitor cannot reach the SMTP could include the port:

Feb 26 05:45:05 trixie simplemonitor[26712]: Traceback (most recent call last):
Feb 26 05:45:05 trixie simplemonitor[26712]:   File "/usr/lib/python3/dist-packages/simplemonitor/simplemonitor.py", line 646, in do_alert
Feb 26 05:45:05 trixie simplemonitor[26712]:     alerter.send_alert(name, this_monitor)
Feb 26 05:45:05 trixie simplemonitor[26712]:     ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
Feb 26 05:45:05 trixie simplemonitor[26712]:   File "/usr/lib/python3/dist-packages/simplemonitor/Alerters/mail.py", line 70, in send_alert
Feb 26 05:45:05 trixie simplemonitor[26712]:     server = smtplib.SMTP(self.mail_host, self.mail_port)
Feb 26 05:45:05 trixie simplemonitor[26712]:   File "/usr/lib/python3.13/smtplib.py", line 255, in __init__
Feb 26 05:45:05 trixie simplemonitor[26712]:     (code, msg) = self.connect(host, port)
Feb 26 05:45:05 trixie simplemonitor[26712]:                   ~~~~~~~~~~~~^^^^^^^^^^^^
Feb 26 05:45:05 trixie simplemonitor[26712]:   File "/usr/lib/python3.13/smtplib.py", line 341, in connect
Feb 26 05:45:05 trixie simplemonitor[26712]:     self.sock = self._get_socket(host, port, self.timeout)
Feb 26 05:45:05 trixie simplemonitor[26712]:                 ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
Feb 26 05:45:05 trixie simplemonitor[26712]:   File "/usr/lib/python3.13/smtplib.py", line 312, in _get_socket
Feb 26 05:45:05 trixie simplemonitor[26712]:     return socket.create_connection((host, port), timeout,
Feb 26 05:45:05 trixie simplemonitor[26712]:            ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
Feb 26 05:45:05 trixie simplemonitor[26712]:                                     self.source_address)
Feb 26 05:45:05 trixie simplemonitor[26712]:                                     ^^^^^^^^^^^^^^^^^^^^
Feb 26 05:45:05 trixie simplemonitor[26712]:   File "/usr/lib/python3.13/socket.py", line 864, in create_connection
Feb 26 05:45:05 trixie simplemonitor[26712]:     raise exceptions[0]
Feb 26 05:45:05 trixie simplemonitor[26712]:   File "/usr/lib/python3.13/socket.py", line 849, in create_connection
Feb 26 05:45:05 trixie simplemonitor[26712]:     sock.connect(sa)
Feb 26 05:45:05 trixie simplemonitor[26712]:     ~~~~~~~~~~~~^^^^
Feb 26 05:45:05 trixie simplemonitor[26712]: ConnectionRefusedError: [Errno 111] Connection refused

This happened in a VPS where the provider blocks the port 25 by default (but 587 not blocked). I expected that simplemonitor would use the port 587 for submission.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions