1
0
mirror of https://github.com/imapsync/imapsync.git synced 2024-11-17 08:12:48 +01:00
imapsync/W/paypal_reply/paypal_send

82 lines
1.5 KiB
Plaintext
Raw Normal View History

2011-07-11 23:24:12 +02:00
#!/usr/bin/perl
2012-04-17 00:28:48 +02:00
# $Id: paypal_send,v 1.7 2011/12/02 02:36:28 gilles Exp gilles $
2011-07-11 23:24:12 +02:00
use strict;
use warnings;
use Getopt::Long;
use MIME::Lite;
my (
$help,
$debug,
$send,
2012-04-17 00:28:48 +02:00
$subscribe,
2011-07-11 23:24:12 +02:00
);
my $numopt = scalar(@ARGV);
my $opt_ret = GetOptions(
"help" => \$help,
"debug!" => \$debug,
"send!" => \$send,
2012-04-17 00:28:48 +02:00
"subscribe!" => \$subscribe,
2011-07-11 23:24:12 +02:00
);
usage() and exit if ($help or ! $numopt or ! $opt_ret) ;
my @reply = <>;
my %header;
while (my $line = shift @reply) {
#print $line;
chomp($line);
last if ($line =~ /^$/) ;
my($blank, $key, $value) = split /^(.+?:)\s*/, $line;
#print "[$key] [$value]\n";
$header{$key} = $value;
}
my $data = join('', @reply);
#print "[", $data, "]\n";
my $message = MIME::Lite->new();
$message->attr("content-type" => "text/plain");
$message->attr("content-type.charset" => "UTF-8");
$message->build(%header);
$message->build(Data => $data);
$message->print(\*STDOUT);
2012-04-17 00:28:48 +02:00
my $dest = $header{ 'To:' } ;
2011-07-11 23:24:12 +02:00
2012-04-17 00:28:48 +02:00
if ( $send ) {
$message->send ;
print "\nSent to $dest\n" ;
}
if ( $subscribe ) {
print "\necho '$dest' | add_members --regular-members-file=- --welcome-msg=y imapsync_update\n" ;
my $out = `echo '$dest' | sudo add_members --regular-members-file=- --welcome-msg=y imapsync_update` ;
print $out ;
print "Subscribed $dest\n" ;
2011-07-11 23:24:12 +02:00
}
sub usage {
print <<EOF;
usage: $0 [options] file
--help : print this help message
--debug : verbose output
--send : send message
Examples:
$0 file
$0 --send file
EOF
}