Error 501 Syntax HELO hostname in postfix

Published on July 9, 2017 by Daniel Lanza

 opensuse  postfix

Certain SMTP servers require HELO servername in order to allow a request to proceed. Set a command filter to let it work without any arguments.

Source

Requirements

You will need the following:

In this tutorial, the machine has the following:

Steps

Create command filter

Create the following file: /etc/postfix/command_filter

dalanzg@mail:~> sudo vim /etc/postfix/command_filter
# Work around clients that send malformed HELO commands.
/^HELO\s*$/ HELO domain.invalid
# Work around clients that send empty lines.
/^\s*$/     NOOP
# Work around clients that send RCPT TO:<'user@domain'>.
# WARNING: do not lose the parameters that follow the address.
/^(RCPT\s+TO:\s*<)'([^[:space:]]+)'(>.*)/     $1$2$3
# Append XVERP to MAIL FROM commands to request VERP-style delivery.
# See VERP_README for more information on how to use Postfix VERP.
/^(MAIL FROM:\s*<listname@example\.com>.*)/   $1 XVERP
# Bounce-never mail sink. Use notify_classes=bounce,resource,software
# to send bounced mail to the postmaster (with message body removed).
/^(RCPT\s+TO:\s*<.*>.*)\s+NOTIFY=\S+(.*)/     $1 NOTIFY=NEVER$2
/^(RCPT\s+TO:.*)/                             $1 NOTIFY=NEVER

Add command filter in main.cf file

Add the following in main.cf

dalanzg@mail:~> sudo vim /etc/postfix/main.cf
smtpd_command_filter = pcre:/etc/postfix/command_filter

Restart postfix service

Restart Postfix service.

dalanz@mail:~> sudo service postfix restart

Test

Send an email with Telnet using only HELO or EHLO (without hostname argument)

dalanz@mail:~> telnet mail.dalanzg.com 25
Trying 10.0.2.15...
Connected to mail.dalanzg.com.
Escape character is '^]'.
220 mail.dalanzg.com ESMTP
ehlo
250-mail.dalanzg.com
250-PIPELINING
250-SIZE
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from: admin@dalanzg.com
250 2.1.0 Ok
rcpt to: {email}
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
Subject: My telnet test with Postfix

Hi,

This is an email sent by using telnet command. Mail service was set with Postfix.

Best regards,

Admin

.
250 2.0.0 Ok: queued as E57AA60775
quit
221 2.0.0 Bye
Connection closed by foreign host.
comments powered by Disqus

See also

Setting Postfix for outgoing mail in openSUSE

A tutorial to set Postfix to send mails in openSUSE. Requirements You will need the following: An openSUSE virtual machine with VirtualBox (Check this link Hostname and domain -> Setting Hostname and domain in openSUSE In this tutorial, the machine has the following: FQDN hostname: mail.dalanzg.com Ethernet IP address: 10.0.2.15 Steps Install Postfix Change main.cf file Send mail with telnet Install Postfix By openSUSE installation default, Postfix can be installed.

Read more

Setting hostname and domain in openSUSE

A tutorial to set hostname and domain in openSUSE (server.dalanzg.com): Hostname -> srvopensuse Domain -> dalanzg.com Requirements You will need the following: An openSUSE virtual machine with VirtualBox (Check this link Steps Modify hostname file Modify hosts file Verification Modify hostname file With root permissions, edit file /etc/hostname. dalanz@linux-geij:~> sudo vim /etc/hostname Write the hostname for the server. srvopensuse Modify hosts file Check your network interfaces to find out the IP address for your Ethernet network (eth1).

Read more

Setting SSL or https in Tomcat with openSUSE

A tutorial to configure Tomcat 8 to support SSL or https connection. Requirements You will need the following: An openSUSE virtual machine with VirtualBox (Check this link Java JDK to create Keystores -> Change Java OpenJDK to Oracle JDK Tomcat -> How to install tomcat in openSUSE This tutorial was created with: openSUSE Leap 42.2 Java Version -> jdk1.8.0_121 Tomcat version -> apache-tomcat-8.0.42 Steps Create a keystore using Java JDK Set keystore in Tomcat Check SSL or https connection Create a keystore using Java JDK Keystore file is a container for authorization certificates or public key certificates.

Read more