From 7e860132d0c4ba0567fa93c49f69309aa10a1763 Mon Sep 17 00:00:00 2001 From: dakkar Date: Thu, 27 Jun 2013 21:45:51 +0100 Subject: new Mail role, thanks corion --- lib/Feed/Role/Mail.pm | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 lib/Feed/Role/Mail.pm diff --git a/lib/Feed/Role/Mail.pm b/lib/Feed/Role/Mail.pm new file mode 100644 index 0000000..d50447f --- /dev/null +++ b/lib/Feed/Role/Mail.pm @@ -0,0 +1,37 @@ +package Feed::Role::Mail; +use Moose::Role; +use 5.012; +use namespace::autoclean; + +with 'Feed::HelperRole::Mail'; + +requires 'extract_entries'; + +has mail_address => ( + is => 'ro', + isa => 'Str', + required => 1, +); + +has mail_host => ( + is => 'ro', + isa => 'Str', + required => 0, +); + +sub process_entry { + my ($self,$entry) = @_; + + my ($msg) = $self->entry_to_mime($entry); + $msg->replace( To => $self->mail_address ); + + my @mail_args; + if( $self->mail_host ) { + @mail_args = (smtp => $self->mail_host); + }; + $msg->send( @mail_args ); + + return; +} + +1; -- cgit v1.2.3