Created
May 30, 2013 07:50
-
-
Save ysasaki/5676334 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use utf8; | |
use strict; | |
use warnings; | |
use Test::More; | |
use Test::Name::FromLine; | |
use Test::TCP; | |
use Net::SMTP; | |
use Net::SMTP::Server; | |
use Net::SMTP::Server::Client; | |
my $server = Test::TCP->new( | |
code => sub { | |
my $port = shift; | |
my $smtp = Net::SMTP::Server->new('localhost', $port); | |
while ( my $conn = $smtp->accept() ) { | |
my $client = Net::SMTP::Server::Client->new($conn); | |
$client->process || next; | |
like $client->{MSG}, qr{http://example\.com/clickme\?s=abcdefg}; | |
} | |
} | |
); | |
my $smtp = Net::SMTP->new( | |
'localhost', | |
Port => $server->port, | |
Timeout => 10, | |
); | |
my $data = <<'EOM'; | |
From: [email protected] | |
To: [email protected] | |
http://example.com/clickme?s=abcdefg | |
EOM | |
$smtp->mail('[email protected]'); | |
$smtp->to('[email protected]'); | |
$smtp->data; | |
$smtp->datasend($data); | |
$smtp->dataend; | |
$smtp->quit; | |
done_testing; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment