This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use Net::IMAP::Client; | |
use Data::Dumper; | |
use strict; | |
use warnings; | |
# 引数チェック | |
if (@ARGV != 4){ | |
print "Usage: file.pl <Server> <User> <Pass> <InputMail> \n"; | |
die; | |
} | |
my $imap = Net::IMAP::Client->new( | |
server => $ARGV[0], | |
user => $ARGV[1], | |
pass => $ARGV[2], | |
ssl => 1, | |
port => 993 | |
) or die "Could not connect to IMAP server"; | |
# ログイン | |
$imap->login or die($imap->last_error); | |
# メールをAppend | |
my $eml = readEml($ARGV[3]); | |
$imap->append('INBOX', \$eml); | |
# 終了 | |
$imap->quit; | |
print "Append end.\n"; | |
# emlファイル読み込み | |
sub readEml { | |
my $path = shift; | |
open(IN, "<", $path); | |
read (IN, $eml, (-s $path)); | |
close IN; | |
return $eml; | |
} |
0 件のコメント:
コメントを投稿