这代码太乱。要use 5.012;整改eexpress 写了:for perler only
重拾此脚本。 家里和单位,互相发邮件的。根据主机名,自动判断。需要安装gpg-agent,避免重复输入密码,并在.bashrc里面添加支持剪贴板,主要是为了鼠标选择一段文字,当作正文。方便点。代码: 全选
4:#-------for gpg-agent------------------------------- 5:GPG_TTY=$(tty) 6:export GPG_TTY
需要修改的地方:
1,2边的邮件地址和主机名的判断。2,gpg的邮件密码文件名,以及手动生成此文件。代码: 全选
$d=/desktop/?1:2; my $to="eexp0$d\@gmail.com";
3,发送的帐号代码: 全选
#● echo password|gpg -aer eexp>~/bin/resources/gpg-163-password my $pw=`gpg -d $ENV{HOME}/bin/resources/gpg-163-password`; chomp $pw;
估计不会perl的,用不了。因为还需要自己修改,和安装 libmail-sender-perl。代码: 全选
smtp => 'smtp.163.com', from => '[email protected]',
代码: 全选
● cat maileexp.pl #!/usr/bin/perl -w #支持文件,信息/剪贴板混杂输入,必须有附件。 if($#ARGV<0){die "没有选择附件文件。\n"} # -------------------------------------------- $_=`hostname`; chomp; #$d=/desktop/?2:1; $d=/desktop/?1:2; my $to="eexp0$d\@gmail.com"; # -------------------------------------------- my $file; my $text; foreach(@ARGV){ if (-f){$file.=",$_";}else{$text.="$_\n";} } $file=~s/^,//; $text=`xsel -o` if ! $text; $text=`see attach files.` if ! $text; #print "attach:\t$file\n--------\nmsg:\t$text\n"; exit; my $info="发送文件: $file 到邮箱: $to"; #● echo password|gpg -aer eexp>~/bin/resources/gpg-163-password my $pw=`gpg -d $ENV{HOME}/bin/resources/gpg-163-password`; chomp $pw; print "$info\n"; `$ENV{HOME}/bin/msg mail.png "发送邮件附件" "$info"`; # -------------------------------------------- use Mail::Sender; my $sender = new Mail::Sender; if ($sender->MailFile({ smtp => 'smtp.163.com', from => '[email protected]', to =>$to, charset=>'utf-8', subject => '同步', charset => 'utf-8', msg => $text, auth => 'LOGIN', authid => 'eexpress', authpwd => $pw, file => $file, })<0){$info="失败。错误:$Mail::Sender::Error";} else {$info="完成";} print "$info\n"; `$ENV{HOME}/bin/msg mail.png "发送邮件附件" "$info"`; # --------------------------------------------
