How to validate an email address with perl

I need to validate several email addresses in my perl template, on sme server I use to validate them by esmith::util::isValidEmail but on nethserver it has been removed

I can use perl-Email-Valid from epel for this purpose but I prefer to use a solution already installed.

For those who want to know why I didn’t validate it in Nethgui, I use a ‘textArea’ because I want to save several addresses (one address per line) and the available validators cannot work with this type of box. I suppose that kind of validator are workable for the ‘textInput’.

I have had the same validation issues with a textArea for IP also, but I used for validating in my perl template.

The default installation already has perl-Mail-RFC822-Address package.

From the official doc (tested, it works with single quotes)

use Mail::RFC822::Address qw(valid validlist);

if (valid("")) {
  print "That's a valid address\n";

if (validlist(",")) {
  print "That's a valid list of addresses\n";


@davidep any other hint?

I had to recompile that package on ns7. I don’t know why nethserver-base requires it, but I’d like getting rid of it :smile:

We should investigate that dependency… Perhaps perl-Email-Valid from EPEL could be a good substitute.

I did some doc on the wiki in the developer area