How to disable MX validation for FORMS email validation

Infos:

  • Used Zammad version: 5.2.x
  • Used Zammad installation type: Sources
  • Operating system: CentOS 7
  • Browser + version: Firefox 102.0.1, MS Edge Version 101.0.1210.32 (Official build) (64-bit)

Expected behavior:

  • When submitting a form, any valid email address is allowed.

Actual behavior:

  • Only public service email addresses work (gmail.com, outlook.com, etc…). When using my own web-hosting services email address it will fail the email validation due to an MX check which can’t be properly performed in this scenario. This makes it so my clients can’t start a new ticket when they are using an email address hosted by our web-host-server. It’s worth noting that this worked without any issues on Zammad 5.1.x

Steps to reproduce the behavior:

  • Scenario:
      1. Web-Host-server is behind NAT (Provides:email, dns, web-site hosting services)
      1. Zammad 5.2.x Server is behind NAT and also reverse proxied to by the web-host-server
      1. MX specified by domain in DNS is the Public IP of the system (NOT the local IP of the Web-Host-Server).

Create a form in Zammad 5.2.x and host it at a domain on web-host-server. When filling out the form from the domain by using that domain’s email (also hosted on the same server) and clicking submit button the form will place a red box around the email field.

When checking the Console of the browser under “network” you can see in the response header that Zammad 5.2.x has deemed the email address as invalid. After checking on some code I found, this is is due to a recent change in email address validation for Zammad using MX as part of it’s validation.

I really need to know how to disable the MX part of the validation only. I’m not interested in validating MX records for a form anyway. This approach can cause too many issues down the road when changing MX records or with DNS poisoning. Instead it would make more sense to do this check against Zammad’s database of known domains according what’s in it’s Organizations lists.

Anyway, I need to disable this MX check Only so that form tickets can flow again. As of now, no one can submit any tickets and I have been forced to revert back to an older version of Zammad.

For those interested or that are having the same problem I was able to fix this myself by changing 1 line of code. The changes are in the file /…/zammad/lib/email_address_validation.rb

Before code change:

# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/

# Validation for email addresses

class EmailAddressValidation

  attr_reader :email_address

  # @param [String] email_address Email address to be validated
  def initialize(email_address)
    @email_address = email_address
  end

  def to_s
    email_address
  end

  # Checks if the email address has a valid format.
  # Reports email addresses without dot in domain as valid (zammad@localhost).
  #
  # @param mx [Boolean] check only syntax or MX as well
  #
  # @return [true]  if email address has valid format
  # @return [false] if email address has no valid format
  def valid?(check_mx: false)
    host_validation_type = check_mx ? :mx : :syntax

    EmailAddressValidator.valid? email_address, host_validation: host_validation_type
  end
end

After code Change:


# Validation for email addresses

class EmailAddressValidation

  attr_reader :email_address

  # @param [String] email_address Email address to be validated
  def initialize(email_address)
    @email_address = email_address
  end

  def to_s
    email_address
  end

  # Checks if the email address has a valid format.
  # Reports email addresses without dot in domain as valid (zammad@localhost).
  #
  # @param mx [Boolean] check only syntax or MX as well
  #
  # @return [true]  if email address has valid format
  # @return [false] if email address has no valid format
  def valid?(check_mx: false)
    host_validation_type = :syntax #<-----here is the change

    EmailAddressValidator.valid? email_address, host_validation: host_validation_type
  end
end

Hope this helps someone else out. Spent 3 days looking at code to find this.