1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #!/usr/bin/perl # 将要使用 sendmail 来发送邮件 my $mailprog = "/usr/sbin/sendmail"; # 发送者的邮件地址 my $ senderemail = "sender\@cn.ibm.com"; # 发送者的名字 my $sender = "sender"; # 发送时的时间 my $datestring=`date +%m.%d.%Y`; # 接收者的 email 地址 my $email = "receiver\@cn.ibm.com"; # Send file to user in email open(MAIL, "|$mailprog -f $sender -t $senderemail") or die; # 创建发送邮件的头 print MAIL "From: $sender\n"; print MAIL "To: $email\n"; # 主题 print MAIL "Subject: Automation test on SELS $datestring\n"; #email 的信件内容 print MAIL "Hi All\nthis is the automation test result on $datestring. Please check the attached files.\n"; # 第一个附件 $file = "/tmp/28279.txt"; open(FILE, "uuencode $file $file |") or die; print MAIL <FILE>; close(FILE); # 第二个附件 $file="/tmp/28280.txt"; open(FILE, "uuencode $file $file |") or die; while( <FILE>) { print MAIL; }; close(FILE); # 完成邮件发送 close(MAIL); |
1 | startsrc -s sendmail |
1 | stopsrc -s sendmail |
1 2 | # "Smart" relay host (may be null) DS[SMTP 的主机 IP] |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #!/usr/bin/perl # 接受者的邮件系统 my $email = "receiver\@cn.ibm.com"; # 将作为附件发送出去的两个文件 my $file1="/tmp/1.txt"; my $file2="/tmp/2.txt"; # 将要使用的邮件发送程序 my $mailprog = "/usr/bin/mail"; # 记录发送时间 my $datestring=`date +%m\/%d\/%Y`; chomp($datestring); #email 的主题 my $subject= "\"Subject: Test on AIX $datestring with attachment\""; # 产生发送邮件命令 my $cmd_sendmail = "uuencode $file1 \"1.txt\" $file2 \"2.txt\" |"; $cmd_sendmail .= "$mailprog -s $subject $email "; # 执行发送命令 system($cmd_sendmail); |
1 2 3 4 5 6 7 8 9 10 11 12 13 | #!/usr/bin/perl # 接受者的邮件系统 my $email = "receiver\@cn.ibm.com"; # 记录发送时间 my $datestring=`date +%m\/%d\/%Y`; chomp($datestring); #email 的主题 my $subject= "\"Subject: Test on AIX $datestring \""; # 产生发送邮件命令 my $cmd_sendmail = "echo $message |"; $cmd_sendmail .= "$mailprog -s $subject $email"; # 执行发送命令 `$cmd_sendmail`; |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |