NAME

Mojo::Email::Checker::SMTP - Email checking by smtp with Mojo enviroment. (IDN supported)

SYNOPSIS

use strict;
use Mojolicious::Lite;
use Mojo::IOLoop::Delay;
use Mojo::Email::Checker::SMTP;

my $checker     = Mojo::Email::Checker::SMTP->new;

post '/' => sub {
	my $self    = shift;
	my $request = $self->req->json;

	my @emails;
	my $delay = Mojo::IOLoop::Delay->new;
	$delay->on(finish => sub {
			$self->render(json => \@emails);
	});

	my $cb = $delay->begin();

	for (@{$request}) {
		my $cb = $delay->begin(0);
		$checker->check($_, sub { push @emails, $_[0] if ($_[0]); $cb->(); });
	}

	$cb->();

};

app->start;

DESCRIPTION

Check for email existence by emulation smtp session to mail server (mx or direct domain, cycling for multiple ip) and get response. Mechanism description http://en.wikipedia.org/wiki/Callback_verification

METHODS

new

This is Checker object constructor. Available parameters are:

timeout

Timeout (seconds) for all I/O operations like to connect, wait for server response and NS Lookup. (15 sec. is default).

helo

HELO value for smtp session ("ya.ru" :) is default). Use your own domain name for this value.

cache

Enable caching for nslookup operation. In value, cache records timeout (in seconds). For example (cache => 3600) for one hour. Cache disabled if 0 value or undefined.

check(STR, CALLBACK(EMAIL, ERROR))

Main function for checking.

STR

String with email address ("foo@foobox.foo")

CALLBACK

Reference to callback function (see SYNOPSIS for example). Pass to CALLBACK two parameters, 1. valid (see comment) EMAIL (STR), 2. ERROR (STR) message.

Comment: If EMAIL and ERROR is defined, it's mean that reject from smtp server recieved before RCPT command. In other cases only one parameter is defined.

COPYRIGHT

Copyright Anatoly Y. <snelius@cpan.org>.
 
 This library is free software; you can redistribute it and/or
 modify it under the same terms as Perl itself.