0537. [Perl] (SMTP) Net::SMTP perl 메일보내기
#cpan Net::SMTP
perl Net::SMTP module 설치하기
#!/usr/bin/perl
my ($mail, $subject, $message);
sub sendmail{
print "\@_ : @_\n";
my( $mail, $subject, $message ) = @_;
print "$mail\n $subject\n $message\n SMTP... end...\n";
use Net::SMTP;
my $content = <<ENDOFCONTENT;
To: <$mail>
From: "mabook system" <no-reply@mabook.com>
Subject: $subject
Content-type: text/plain; charset=EUC-KR
Content-Transfer-Encoding: 8bit
$message
ENDOFCONTENT
# $smtp = Net::SMTP->new('localhost');
$smtp = Net::SMTP->new('10.7.9.4'); #사내
메일서버 nslookup mail.art.com
$smtp->mail($mail);
$smtp->to($mail);
$smtp->data();
$smtp->datasend($content);
$smtp->dataend();
$smtp->quit;
print "$content\n";
}
print "SMTP... testing...\n";
print "\@\_ : @_\n";
print "\@ARGV : @ARGV\n";
sendmail(@ARGV);
print "$mail\n $subject\n $message\n SMTP... end...\n";
[root@linuxtest kim]# ./smtp.pl test@daum.net perl.mail.test DOOSAN.DOOSAN
SMTP... testing...
@_ :
@ARGV : test@daum.net perl.mail.test DOOSAN.DOOSAN
@_ : test@daum.net perl.mail.test DOOSAN.DOOSAN
test@daum.net
perl.mail.test
DOOSAN.DOOSAN
SMTP... end...
To: <test@daum.net>
From: "mabook system" <no-reply.com>
Subject: perl.mail.test
Content-type: text/plain; charset=EUC-KR
Content-Transfer-Encoding: 8bit
DOOSAN.DOOSAN
SMTP... end...
'IT' 카테고리의 다른 글
0539. [LINUX] (ping) icmp_echo_ignore_all 변경으로 ping 막기 (0) | 2016.03.08 |
---|---|
0538. [LINUX] (chkconfig service) iptables 방화벽 중지하기 (0) | 2016.03.08 |
0536. [Perl] (-w) /usr/bin/perl -w 와 /usr/bin/perl 의 차이 (0) | 2016.03.07 |
0535. [gnuplot] (apache ab) apache ab 데이타 gnuplot 이용 그래프 출력하기 (0) | 2016.03.07 |
0534. [apache] (ab) apache stress testing 벤치마크 툴 ab (0) | 2016.03.07 |