++ed by:

1 non-PAUSE user.

azuma, kuniyuki
and 12 contributors

NAME

Sisimai::Address - Email address object

SYNOPSIS

    use Sisimai::Address;

    my $v = Sisimai::Address->new('neko@example.org');
    print $v->user;     # neko
    print $v->host;     # example.org
    print $v->address;  # neko@example.org

DESCRIPTION

Sisimai::Address provide methods for dealing email address.

CLASS METHODS

new(email address)

new() is a constructor of Sisimai::Address

    my $v = Sisimai::Address->new('neko@example.org');

find(String)

find() is a new parser for getting only email address from text including email addresses.

    my $r = 'Stray cat <cat@example.org>, nyaa@example.org (White Cat)',
    my $v = Sisimai::Address->find($r);

    warn Dumper $v;
    $VAR1 = [
              {
                'name' => 'Stray cat',
                'address' => 'cat@example.org',
                'comment' => ''
              },
              {
                'name' => '',
                'address' => 'nyaa@example.jp',
                'comment' => '(White Cat)'
              }
    ];

s3s4(email address)

s3s4() works Ruleset 3, and 4 of sendmail.cf.

    my $r = [
        'Stray cat <cat@example.org>',
        'nyaa@example.org (White Cat)',
    ];

    for my $e ( @$r ) {
        print Sisimai::Address->s3s4($e);   # cat@example.org
                                            # nyaa@example.org
    }

expand_verp(email address)

expand_verp() gets the original email address from VERP

    my $r = 'nyaa+neko=example.org@example.org';
    print Sisimai::Address->expand_verp($r); # neko@example.org

expand_alias(email address)

expand_alias() gets the original email address from alias

    my $r = 'nyaa+neko@example.org';
    print Sisimai::Address->expand_alias($r); # nyaa@example.org

INSTANCE METHODS

user()

user() returns a local part of the email address.

    my $v = Sisimai::Address->new('neko@example.org');
    print $v->user;     # neko

host()

host() returns a domain part of the email address.

    my $v = Sisimai::Address->new('neko@example.org');
    print $v->host;     # example.org

address()

address() returns an email address

    my $v = Sisimai::Address->new('neko@example.org');
    print $v->address;     # neko@example.org

verp()

verp() returns a VERP email address

    my $v = Sisimai::Address->new('neko+nyaan=example.org@example.org');
    print $v->verp;     # neko+nyaan=example.org@example.org
    print $v->address;  # nyaan@example.org

alias()

alias() returns an email address (alias)

    my $v = Sisimai::Address->new('neko+nyaan@example.org');
    print $v->alias;    # neko+nyaan@example.org
    print $v->address;  # neko@example.org

name()

name() returns a display name

    my $e = '"Neko, Nyaan" <neko@example.org>';
    my $r = Sisimai::Address->find($e);
    my $v = Sisimai::Address->make($r->[0]);
    print $v->address;  # neko@example.org
    print $v->name;     # Neko, Nyaan

comment()

name() returns a comment

    my $e = '"Neko, Nyaan" <neko(nyaan)@example.org>';
    my $v = Sisimai::Address->make(shift @{ Sisimai::Address->find($e) });
    print $v->address;  # neko@example.org
    print $v->comment;  # nyaan

AUTHOR

azumakuniyuki

COPYRIGHT

Copyright (C) 2014-2019 azumakuniyuki, All rights reserved.

LICENSE

This software is distributed under The BSD 2-Clause License.