Skip to content

Instantly share code, notes, and snippets.

@loicnestler
Created February 7, 2021 19:11
Show Gist options
  • Save loicnestler/446afd844ed67dcfb94364eadbc9ba40 to your computer and use it in GitHub Desktop.
Save loicnestler/446afd844ed67dcfb94364eadbc9ba40 to your computer and use it in GitHub Desktop.
Check mail server for OpenRelay
# Stolen from https://github.com/Mailu/Mailu/issues/1370#issuecomment-592447023
# $YOUR_PUBLIC_SERVER_IP = your mail server IP
# $YOUR_PUBLIC_SERVER_DOMAIN = your mail server domain (mail.example.org)
# $A_MAIL_NOT_MANAGED_BY_YOUR_SERVER = some mail address that is not managed by your mail server (for example a @gmail address)
$ nc -v $YOUR_PUBLIC_SERVER_IP
Ncat: Version 7.80 ( https://nmap.org/ncat )
Ncat: Connected to $YOUR_PUBLIC_SERVER_IP:25.
220 $YOUR_MAIL_SERVER_DOMAIN ESMTP ready
HELO $YOUR_MAIL_SERVER_DOMAIN
250 $YOUR_MAIL_SERVER_DOMAIN
MAIL FROM: $A_MAIL_NOT_MANAGED_BY_YOUR_SERVER
250 2.0.0 OK
RCPT TO: $ANOTHER_MAIL_NOT_MANAGED_BY_YOUR_SERVER
554 5.7.1 <$ANOTHER_MAIL_NOT_MANAGED_BY_YOUR_SERVER>: Relay access denied
# The output of line 14 is the important one. If it says "Relay access denied" than your server does not support OpenRelay (which is good for most purposes).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment