CalmPerl has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I have no knowledge of Perl. I have to install a e-mail forwarding program. However when I try to send an e-mail I get an error: Attribute (email) does not pass the type constraint because 'validemail@validdomain.com" is not a valid address at contructor Mail:Builder:Address::new I have no idea how to fix this I have looked at the Address.pm file but I cannot really understand it. Sincerely, CalmPerl

Replies are listed 'Best First'.
Re: Data Validation
by Corion (Patriarch) on Jun 01, 2017 at 20:49 UTC

    Looking at Mail::Builder::Address, it uses Mail::Builder::TypeConstraints, which in turn uses Email::Valid, which does (online) alidation of an email address and its MX records.

    Maybe your machine is not connected to a DNS server or something else is bad with that email address.

    Maybe try using Email::Valid directly to see if Email::Valid thinks your mail address is valid.

    I think the check in Mail::Builder::TypeConstraints is a bit wonky:

    lc $_ eq lc (Email::Valid->address( %params, -address => $_, )

    I think that Email::Valid strips the name and optional comment parts from the mail so that check might fail even though the email address is valid.

      Hi thanks for the reply, is there a way to skip the validation altogether?
        You could try to override "Email::Valid::address" in your code, by adding this line early in your code:
        sub Email::Valid::address{return {@_}->{-address}};

                        Once it hits the fan, the only rational choice is to sweep it up, package it, and sell it as fertilizer.