louislam / uptime-kuma

A fancy self-hosted monitoring tool
https://uptime.kuma.pet
MIT License
56.72k stars 5.11k forks source link

`SMTP` - Email server uptime checking monitor #3023

Open ChrisThePCGeek opened 1 year ago

ChrisThePCGeek commented 1 year ago

⚠️ Please verify that this feature request has NOT been suggested before.

🏷️ Feature Request Type

New Monitor

🔖 Feature description

✔️ Solution

noted in description

❓ Alternatives

No response

📝 Additional Context

No response

stefanux commented 1 year ago

so you basically want a email-sent and receive loop and have a notification if no mail show up in interval x, right?

ChrisThePCGeek commented 1 year ago

Yeah that's the idea I had, I think it would work to verify an email server was up and working. could even trigger a fail if the send doesn't work since sometimes send works but receive doesn't.

solracsf commented 1 year ago

Something similar to these options would also be great, if email send is a heavy option. https://www.wormly.com/test-smtp-server

flaviomeyer commented 1 year ago

@ChrisThePCGeek Interested to develop together a new monitor for mail server's?

ediazrod commented 1 year ago

I love to have this feature, at least to test if the e-mail works and on the other end if the mail is received... I love to follow up this capability, I not a programmer on node maybe create some doc about how to install with a no-root user, and Patrion the project. :-P

CommanderStorm commented 12 months ago

@ediazrod @erseco Issues are for discussing what needs to be done how by whom. We use 👍🏻 on issues to prioritise work, as always: Pull Requests welcome.

hujiko commented 10 months ago

I think the sending and receiving actual Mail might be quite complex.

I would already be fine with something more simple. A check, that

Something like:

const { SMTPClient } = require('smtp-client');

module.exports = function(smtpConfig) {
  return {
    async check() {
      const client = new SMTPClient({
        host: smtpConfig.host,
        port: smtpConfig.port,
        secure: false,
        useSecureTransport: false,
        ignoreTLS: true,
        requireTLS: false,
        timeout: 5000,
      });

      try {
        await client.connect();

        const response = await client.sendCommand('EHLO localhost');
        if (response.code !== 250) {
          throw new Error('EHLO command failed');
        }

        const starttlsResponse = await client.sendCommand('STARTTLS');
        if (starttlsResponse.code !== 220) {
          throw new Error('STARTTLS command failed');
        }

        await client.secure({
          rejectUnauthorized: smtpConfig.rejectUnauthorized,
        });

        const mailFromResponse = await client.sendCommand(`MAIL FROM:<${smtpConfig.from}>`);
        if (mailFromResponse.code !== 250) {
          throw new Error('MAIL FROM command failed');
        }

        const rcptToResponse = await client.sendCommand(`RCPT TO:<${smtpConfig.to}>`);
        if (rcptToResponse.code !== 250) {
          throw new Error('RCPT TO command failed');
        }

        return true; // SMTP server is reachable
      } catch (error) {
        throw new Error(`SMTP server check failed: ${error.message}`);
      } finally {
        client.close();
      }
    },
  };
};

Whats missing there is the ability to make StartTLS optional and to actually validate the Certificate.

CommanderStorm commented 10 months ago

Note that our contribution guide is here https://github.com/louislam/uptime-kuma/blob/1550a5f79270f39007086d8d23c180ba9f63096b/CONTRIBUTING.md ^^

mkarg commented 6 months ago

I think it would be enough to be able to connect and receive an initial positive status (i. e. the full roundtrip should be optional to configure).

arthef commented 5 months ago

I am willing to sponsor implementation of this feature. If someone is interested in doing this please let me know.