Skip to content

Commit

Permalink
smtp-check: Add flag to specify local name
Browse files Browse the repository at this point in the history
Some MTAs reject client connections unless the local name (used in the
HELO/EHLO command) looks like an FQDN. Currently, smtp-check always uses
`localhost`, which does not look like an FQDN.

This patch adds a command line flag to smtp-check to specify the
local name to be used.

Fixes #37.

Amended-by: Alberto Bertogli <[email protected]>
  Minor edits to the commit message, adjust flag name, go fmt.
  • Loading branch information
znerol authored and albertito committed Jul 16, 2023
1 parent 9e84525 commit ad0dbb9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
6 changes: 6 additions & 0 deletions cmd/smtp-check/smtp-check.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
var (
port = flag.String("port", "smtp",
"port to use for connecting to the MX servers")
localName = flag.String("localname", "localhost",
"specify the local name for the EHLO command")
skipTLSCheck = flag.Bool("skip_tls_check", false,
"skip TLS check (useful if connections are blocked)")
)
Expand Down Expand Up @@ -91,6 +93,10 @@ func main() {
if err != nil {
log.Fatal(err)
}
err = c.Hello(*localName)
if err != nil {
log.Fatal(err)
}

config := &tls.Config{
// Expect the server to have a certificate valid for the MX
Expand Down
9 changes: 6 additions & 3 deletions docs/man/smtp-check.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35)
.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43)
.\"
.\" Standard preamble:
.\" ========================================================================
Expand Down Expand Up @@ -133,7 +133,7 @@
.\" ========================================================================
.\"
.IX Title "smtp-check 1"
.TH smtp-check 1 "2018-04-02" "" ""
.TH smtp-check 1 "2023-07-16" "" ""
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
Expand All @@ -142,7 +142,7 @@
smtp\-check \- SMTP setup checker
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
\&\fBsmtp-check\fR [\-port \fIport\fR] [\-skip_tls_check] \fIdomain\fR
\&\fBsmtp-check\fR [\-port \fIport\fR] [\-localname \fIdomain\fR] [\-skip_tls_check] \fIdomain\fR
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
smtp-check is a command-line too for checking \s-1SMTP\s0 setups (\s-1DNS\s0 records, \s-1TLS\s0
Expand All @@ -152,6 +152,9 @@ certificates, \s-1SPF,\s0 etc.).
.IP "\fB\-port\fR \fIport\fR:" 8
.IX Item "-port port:"
Port to use for connecting to the \s-1MX\s0 servers.
.IP "\fB\-localname\fR \fIdomain\fR:" 8
.IX Item "-localname domain:"
Local name to use for the \s-1EHLO\s0 command.
.IP "\fB\-skip_tls_check\fR:" 8
.IX Item "-skip_tls_check:"
Skip \s-1TLS\s0 check (useful if connections are blocked).
Expand Down
6 changes: 5 additions & 1 deletion docs/man/smtp-check.1.pod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ smtp-check - SMTP setup checker

=head1 SYNOPSIS

B<smtp-check> [-port I<port>] [-skip_tls_check] I<domain>
B<smtp-check> [-port I<port>] [-localname I<domain>] [-skip_tls_check] I<domain>

=head1 DESCRIPTION

Expand All @@ -19,6 +19,10 @@ certificates, SPF, etc.).

Port to use for connecting to the MX servers.

=item B<-localname> I<domain>:

Local name to use for the EHLO command.

=item B<-skip_tls_check>:

Skip TLS check (useful if connections are blocked).
Expand Down

0 comments on commit ad0dbb9

Please sign in to comment.