| 1 | package Net::Async::SMTP; | ||
| 2 | # ABSTRACT: SMTP support for IO::Async | ||
| 3 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 1 | our $VERSION = '0.004'; | |
| 7 | |||
| 8 | =head1 NAME | ||
| 9 | |||
| 10 | Net::Async::SMTP - email sending with IO::Async | ||
| 11 | |||
| 12 | =head1 SYNOPSIS | ||
| 13 | |||
| 14 | #!/usr/bin/env perl | ||
| 15 | use strict; | ||
| 16 | use warnings; | ||
| 17 | use IO::Async::Loop; | ||
| 18 | use Net::Async::SMTP::Client; | ||
| 19 | use Email::Simple; | ||
| 20 | my $email = Email::Simple->create( | ||
| 21 | header => [ | ||
| 22 | From => 'someone@example.com', | ||
| 23 | To => 'other@example.com', | ||
| 24 | Subject => 'NaSMTP test', | ||
| 25 | ], | ||
| 26 | attributes => { | ||
| 27 | encoding => "8bitmime", | ||
| 28 | charset => "UTF-8", | ||
| 29 | }, | ||
| 30 | body_str => '... text ...', | ||
| 31 | ); | ||
| 32 | my $loop = IO::Async::Loop->new; | ||
| 33 | $loop->add( | ||
| 34 | my $smtp = Net::Async::SMTP::Client->new( | ||
| 35 | domain => 'example.com', | ||
| 36 | ) | ||
| 37 | ); | ||
| 38 | $smtp->connected->then(sub { | ||
| 39 | $smtp->login( | ||
| 40 | user => '...', | ||
| 41 | pass => '...', | ||
| 42 | ) | ||
| 43 | })->then(sub { | ||
| 44 | $smtp->send( | ||
| 45 | to => 'someone@example.com', | ||
| 46 | from => 'other@example.com', | ||
| 47 | data => $email->as_string, | ||
| 48 | ) | ||
| 49 | })->get; | ||
| 50 | |||
| 51 | =head1 DESCRIPTION | ||
| 52 | |||
| 53 | Provides basic email sending capability for L<IO::Async>, using | ||
| 54 | the L<Protocol::SMTP> implementation. | ||
| 55 | |||
| 56 | See L<Protocol::SMTP/DESCRIPTION> for a list of supported features | ||
| 57 | and usage instructions. | ||
| 58 | |||
| 59 | This class does nothing - use L<Net::Async::SMTP::Client> for | ||
| 60 | sending email. | ||
| 61 | |||
| 62 | =cut | ||
| 63 | |||
| 64 | 1 | 1; | |
| 65 | |||
| 66 | __END__ | ||