Perl脚本发送带附件的邮件脚本安全(锦集4篇)由网友“岭南ZZ”投稿提供,下面是小编整理过的Perl脚本发送带附件的邮件脚本安全,欢迎您阅读,希望对您有所帮助。
篇1:Perl脚本发送带附件的邮件脚本安全
#!/usr/bin/perl
use strict;
use warnings;
use Net::SMTP;
use MIME::Lite;
use Term::ReadKey;
use Encode qw/decode encode/;
print “From : ”;
chomp(my $from = );
my $server;
#这里我只用到了163和qq的SMTP服务器,。。
$server = “smtp.163.com” if $from =~ /@163.com/;
$server = “smtp.qq.com” if $from =~ /@qq.com/;
print “Password : ”;
#输入密码时不显示。。。
ReadMode(“noecho”);
chomp(my $pass = );
ReadMode(“restore”);
print “nTo : ”;
chomp(my $to = );
print “Subject : ”;
chomp(my $subject = );
print “Content : n”;
chomp(my $content = );
print “Attachment : ”;
chomp(my $file = );
my $smtp = Net::SMTP->new($server, Timeout => 30);
my $msg = MIME::Lite->new(
From=>$from,
To=>$to,
Subject=>$subject,
Type=>“TEXT”,
Data=>$content,
);
if($file) {
#输入流UTF-8编码,视环境的编码而定,
。。
$file = decode(“utf8”, $file);
my $filename = $file;
#输出流转成gbk编码,应对附件的中文乱码问题。。。
$filename = encode(“gbk”, $filename);
#去除路径名,只保留文件名。。。
$filename =~ s/.*/|.*\//;
$msg->attach(
Type=>“AUTO”,
Path=>$file,
Filename=>$filename,
);
}
#将邮件全部内容以字符串的形式传递。。。
my $content_string = $msg->as_string or die “$!”;
#使用Net::SMTP发送邮件。。。
$smtp->auth($from, $pass);
$smtp->mail($from);
$smtp->to($to);
$smtp->data();
$smtp->datasend(“$content_stringnn”);
$smtp->dataend();
$smtp->quit;
#如果发送不成功,显示错误信息。。。
unless($smtp->code() == 221) {
print $smtp->message();
}
#发送成功的状态。。。
else {
print “Successfully sent to <$to>!n”;
}
#Perl
篇2:Perl文件搜索脚本脚本安全
好久没有写些东西了,。。最近一直在用PERL写一些有趣的程序,几乎每天都有新的程序产生,实在是太有趣了!今天又写了一个用来搜索文件的小程序,虽然我以前也写过类似的,但是方法很繁琐,这次用到了一个很方便的模块:File::Find!代码明显变得简短多了,其中还加了一些自己的想法进去,可以自动修改Windows当中输入的错误,举个简单的例子,比如:程序提示输入一个查找路径,假设输入“C”,程序会自动把它改成“C:”,这样方便查找。还有,在Windows系统中,输入“/”和“”是都支持的,这样会导致打印出的结果显得很凌乱,如:C:\Perl//searchMyFile.pl,程序都会统一将其改成类似Unix系统中的“/”的形式,如:C:/Perl/searchMyFile.pl。还有很多自动修改的功能,都是用到了PERL强大的正则表达式,不多说了,我把我的代码复制上来,如果大家有兴趣可以帮忙纠正:-)
#!/usr/bin/perl
use strict;
use warnings;
use Cwd;
use File::Find;
####################################################################
File name : searchMyFile.pl
Written by : B.S.F
Last modified : 05/18/
Description : Easy way to search some file(s) with a keyword!
####################################################################
# Input a path to search...
print “Enter a path: ”;
chomp(my $path = );
# Change “~” or “~/” to your home directory on Linux/FreeBSD platform.
if(($^O eq “linux”) || ($^O eq “freebsd”)) {$path =~ s/~|~//$ENV{'HOME'}/;
}
# Deal with some format of path on Windows NT platform.
else {
# Change “C” to “C:”, etc.
$path .= “:” if $path =~ /^w$/;
# Change “C:\” to “C:”, etc.
$path =~ s/W+/:/ if $path =~ /^wW+$/;
# Change “C:\Perl” to “C:\Perl”, etc.
$path =~ s/W+$// if $path =~ /^wW+w+/;
# Change “C:\Perl” to “C:/Perl”, etc.
$path =~ s/W+/:// if $path =~ /^wW+w+/;
}
# Test if can enter into the path or not, if not, terminated!
chdir($path) or die “Couldn't get into $path: $!”;
# Input some keyword...
print “Enter a keyword: ”;
chomp(my $key = );
# Change the “.” character to the actually meanings, matching some postfix.
# Such as “.jpg”, “.txt”, “.doc”, etc.
$key =~ s/./\./;
# Print some information...
print “Searching under ”“, getcwd, ”“...n”;
#
# Searching...
#
sub search {
# Get rid of the directory matches “System Volume Information”(some boring stuff on Windows...).
$File::Find::prune = 1 if /System Volume Information/;
# Open the “i” switch to mach more, such as “.JPG” or “.jpg”...
if (/$key/i) {
# “
my $target = (-d) ? “
# A neat layout for Windows...
$target =~ s/:/:// if $target !~ ///;
print “$targetn”;
}
}
# Begin to search...
find(&search, $path);
篇3:Codeigniter实现发送带附件的邮件
作者:work24 字体:[增加 减小] 类型:
这篇文章主要介绍了Codeigniter实现发送带附件的邮件的方法,涉及Codeigniter中attach方法的使用技巧,非常具有实用价值,需要的朋友可以参考下
本文实例讲述了Codeigniter实现发送带附件的邮件的方法,分享给大家供大家参考。具体分析如下:
attach 方法允许你的发邮件时带上附件,下面是演示代码
代码如下:
$this->load->library(‘email‘);
$this->email->from(‘w3@w3mentor.com‘, ‘W3M‘);
$this->email->subject(‘Email Test with attachment‘);
$this->email->message(‘Testing the email class IN CODEIGNITER with attachment.‘);
$this->email->attach(‘/path/to/attachment1.jpg‘);
$this->email->send();
希望本文所述对大家基于Codeigniter的php程序设计有所帮助,
篇4:写的一个perl脚本,用于发送远程MySQL命令
想写一些简化管理操作的脚本,下面是基础脚本之一,
对于一个从来没使用过perl脚本的我来说还是有些难度的,直接上代码。
此脚本用于发送远程MySQL命令并且接收结果,功能比较简单,后面会渐渐完善。
#!/usr/bin/perl use Getopt::Long;use DBI; Getopt::Long::GetOptions( ‘host|h=s‘ => $host,‘user|u=s‘ => $user, ‘password|pw=s‘ => $password,‘port|p=s‘ => $port,‘command|c=s‘ => $command, ‘groupfile|f=s‘ => $groupfile, ‘help‘ => $help ); #print help info my $printh=q{usage : mysqlcon -h 192.168.0.33 -u root -pw ‘xiaojun‘ -p 3306 -c ‘show global status‘ or mysqlcon -g 2.txt -c ‘select user();‘cat 2.txt:192.168.0.33 root xiaojun 3306192.168.0.34 root xiaojun 3306options:-h database server *-u account name *-pw password for account *-p port for mysqld *-c command to execute *-help print help};=podif(!defined($host)){ print “page flag set to $page ”}if(defined($user)){ print “user flag set to $usern ”;}if(defined($password)){ print “onoff flag set to $password n”;}if(defined($command)){ print “help flag set to $command n”;}if(defined($help)){ print $printh}=cutsub execute_sql{my $dsn = “DBI:mysql:database=mysql;host=$_[0]:$_[1]”;my ($dbh,$sth,@ary);$dbh = DBI->connect($dsn,$_[2],$_[3],{‘RaiseError‘ => 1});$sth = $dbh->prepare(“$_[4]”);$sth->execute(); while(@ary = $sth->fetchrow_array()){print join(“t”,@ary),“n”;}$sth->finish; $dbh->disconnect; }#&execute_sql($host,$port,$user,$password,$command) ;unless (!defined($help)) { die “$printh” };if(defined($groupfile)){ unless (defined($command)) { die “Wrong usage : No command input .n $printh” }; open(IN,$groupfile); while($line= 使用方法 [root@centos511 ~]# ./6.perl -h 192.168.0.33 -u root -pw ‘xiaojun‘ -p 3306 -c ‘select user()‘ ;root@192.168.0.33[root@centos511 ~]# ./6.perl -g 2.txt -c ‘select user()‘ host:192.168.0.33command:select user()******BEGINroot@192.168.0.33******END *****************************************************host:192.168.0.33command:select user()******BEGINroot@192.168.0.33******END *****************************************************[root@centos511 ~]# cat 2.txt 192.168.0.33 root xiaojun 3306192.168.0.33 root xiaojun 3306[root@centos511 ~]# ./6.perl -helpusage : mysqlcon -h 192.168.0.33 -u root -pw ‘xiaojun‘ -p 3306 -c ‘show global status‘ or mysqlcon -g 2.txt -c ‘select user();‘cat 2.txt:192.168.0.33 root xiaojun 3306192.168.0.34 root xiaojun 3306options:-h database server *-u account name *-pw password for account *-p port for mysqld *-c command to execute *-help print help ★ html学习总结 【Perl脚本发送带附件的邮件脚本安全(锦集4篇)】相关文章: php实习报告2022-10-05 确保PHP应用程序的安全[2]WEB安全2022-04-30 Windows 配置POP3服务服务器教程2022-12-04 python开发的小球完全弹性碰撞游戏代码2022-12-05 面试题及答案2023-04-15 社区面试题及答案2022-06-16 九大技巧教你如何去除电子邮件类病毒2022-10-17 hr面试题及答案2022-10-01 教你几招关于手机病毒防范及解决的策略2022-05-06 Discuz XSS得webshell脚本安全2022-05-08