#!/usr/bin/perl
use strict;
use warnings;

=head1 NAME

smarkmail - send email, converting plain text to multipart/alternative + HTML

=head1 USAGE

 smarkmail [ -f sender ] <recipient ... >

 -f  - envelope recipient; otherwise taken from email From header

=cut

use App::Smarkmail;
use Email::Sender::Transport::Sendmail;
use Getopt::Long::Descriptive;

my ($opt, $usage) = describe_options(
  'smarkmail %o <recipient>',
  [ 'from|f=s', 'envelope sender' ],
);

die $usage->text unless @ARGV;

my $text = do { local $/; <STDIN> };

my $email = App::Smarkmail->markdown_email($text);

my $sender = Email::Sender::Transport::Sendmail->new;

$sender->send($email,
  {
    to   => [ @ARGV ],
    ($opt->{from} ? (from => $opt->{from}) : ()),
  },
);

=head1 BUGS

Please report any bugs or feature requests through the web interface at
L<http://rt.cpan.org>. I will be notified, and then you'll automatically be
notified of progress on your bug as I make changes.

=head1 COPYRIGHT

Copyright 2008, Ricardo SIGNES.  This program is free software;  you can
redistribute it and/or modify it under the same terms as Perl itself.

=cut

