File: smtp.t

package info (click to toggle)
libemail-sender-perl 1.300030-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 476 kB
  • ctags: 119
  • sloc: perl: 2,261; makefile: 2
file content (40 lines) | stat: -rw-r--r-- 778 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use strict;
use warnings;

use Data::Dumper;
use Email::Sender::Transport::SMTP;
use Email::Sender::Transport::SMTP_X;

for my $suffix ('', '_X') {
  my $class = "Email::Sender::Transport::SMTP$suffix";
  my $smtp  = $class->new({
    host => 'mx-all.pobox.com',
    allow_partial_success => 1,
  });

  my $message = <<'END';
From: RJ <rjbs+hdrF@pobox.com>
To: Rico <rjbs+hdr2@pobox.com>
Subject: test message

This is a test.

-- 
rjbs
END

  my $result = eval {
    $smtp->send(
      $message,
      {
        to   => [ 'rjbs+rcpt@pobox.com', 'rsignes@pobox.com' ],
        from => 'rjbs+from@pobox.com',
      },
    );
  };

  # my $error = $@;
  # print "\n\n$class - " . Dumper($result || $error) . "\n\n";

  printf "fail: %s\n", $_ for $result->failure->recipients;
}