The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

OP::EmailAddr - Overloaded RFC 2822 email address object

SYNOPSIS

  use OP::EmailAddr;

  #
  # From address:
  #
  do {
    my $addr = OP::EmailAddr->new('root@example.com');
  }

  #
  # From name and address:
  #
  do {
    my $addr = OP::EmailAddr->new("Rewt", 'root@example.com');
  }

  #
  # From a formatted string:
  #
  do {
    my $addr = OP::EmailAddr->new("Rewt <root@example.com>');
  }

DESCRIPTION

Extends Email::Address, OP::Array. Uses Data::Validate::Email to verify input.

PUBLIC CLASS METHODS

  • assert(OP::Class $class: *@rules)

    Returns a new OP::Type::EmailAddr instance which encapsulates the received OP::Subtype rules.

      create "OP::Example" => {
        someAddr  => OP::EmailAddr->assert(
          subtype(
            optional => true
          )
        ),
    
        # ...
      };
  • new(OP::Class $class: Str $addr)

    Returns a new OP::EmailAddr instance which encapsulates the received value.

      my $object = OP::EmailAddr->new('root@example.com');

SEE ALSO

See Email::Address for RFC-related methods inherited by this class.

OP::Array, Data::Validate::Email

This file is part of OP.