Email::Send::IO - Send messages using IO operations


Email-Send-IO documentation Contained in the Email-Send-IO distribution.

Index


Code Index:

NAME

Top

Email::Send::IO - Send messages using IO operations

SYNOPSIS

Top

  use Email::Send;

  my $mailer = Email::Send->new({mailer => 'IO'});

  $mailer->send($message); # To STDERR

  $mailer->mailer_args('filename.txt');
  $mailer->send($message); # write file

DESCRIPTION

Top

This is a mailer for Email::Send that will send a message using IO operations. By default it sends mail to STDERR, very useful for debugging. The IO functionality is built upon IO::All. Any additional arguments passed to send will be used as arguments to IO::All::io.

You can globally change where IO is sent by modifying the @Email::Send::IO::IO package variable.

  @Email::Send::IO::IO = ('-'); # always append to STDOUT.

Examples

Sending to STDOUT.

  send IO => $message, '-';

Send to a socket.

  send IO => $message, 'server:1337';

SEE ALSO

Top

Email::Send, IO::All, perl.

AUTHOR

Top

Current maintainer: Ricardo SIGNES, <rjbs@cpan.org>.

Original author: Casey West, <casey@geeknest.com>.

COPYRIGHT

Top


Email-Send-IO documentation Contained in the Email-Send-IO distribution.

package Email::Send::IO;
use strict;

use Return::Value;

use vars qw[$VERSION];
$VERSION = '2.200';

use vars qw[@IO];
@IO = ('=') unless @IO;

sub is_available {
    return   eval { require IO::All }
           ? success
           : failure "is_available: Loading IO::All failed: $@";
}

sub send {
    my ($class, $message, @args) = @_;
    eval { require IO::All; IO::All->import };
    return failure "send: Loading IO::All failed: $@" if $@;
    @args = (@IO) unless @args;
    eval { io(@args)->append($message->as_string) };
    return failure $@ if $@;
    return success;
}

1;

__END__