¾È³çÇϼ¼¿ä?
´Ù¸§ÀÌ ¾Æ´Ï¿À¶ó Çì¸Þ°í Çì¸Þ´Ù ¸øÇØ ¿©±â¿¡ ±ÛÀ»¿Ã¸³´Ï´Ù.
Áú¹®³»¿ëÀº Æû¸ÞÀÏ¿¡ °ü·ÃµÈ ³»¿ëÀε¥
¼Ò½º´Â °°ÀÌ Ã·ºÎÇß±¸¿ä..
¾Æ·¡³»¿ëÀº ¼Ò½ºÆÄÀÏÁß¿¡ formmail.cgiÀÇ ³»¿ëÀÔ´Ï´Ù.
#!/usr/bin/perl
##############################################################
# Formmail with attachment Beta Version
# Written by C.G.Kim on 98.06.01
#
# This is available only on the Unix/Linux platform
# & on the place Perl 5.xx version is installed.
##############################################################
$form_file = "./formmail.html";
require
cgi-lib.pl
;
use MIME::Lite;
# Call Subroutines
&ReadParse(*FORM);
&check_error;
&check_attach if ($FORM{
bin_File
});
$isSendFlag= &send_message;
&send_html($isSendFlag);
# End of Main
####### SubRoutines ##########################################
sub check_error {
&error(
Low Perl Version
,
ÆÞ ¹öÀüÀÌ ³·¾Æ¼ ½ÇÇàÇÒ ¼ö ¾ø½À´Ï´Ù.
)
if ($] < 5);
&error(
Field Empty
,
¼ö½ÅÀÚ EmailÁÖ¼Ò¶õÀÌ ºñ¾î ÀÖ½À´Ï´Ù
)
unless ($FORM{
rcv_email
});
&error(
Field Empty
,
³»¿ë¶õÀÌ ºñ¾î ÀÖ½À´Ï´Ù
)
unless ($FORM{
content
});
&error(
Field Empty
,
Á¦¸ñ¶õÀÌ ºñ¾î ÀÖ½À´Ï´Ù
)
unless ($FORM{
subject
});
&error(
Wrong Email Address
,
¼ö½ÅÀÚ Email ÁÖ¼Ò°¡ À߸øµÇ¾ú½À´Ï´Ù
)
if ($FORM{
rcv_email
} !~ /@/);
&error(
Wrong Email Address
,
¼Û½ÅÀÚ Email ÁÖ¼Ò°¡ À߸øµÇ¾ú½À´Ï´Ù
)
if ($FORM{
sender_email
} !~ /@/);
}
sub check_attach {
if ($filename =~ /(.*)(.*)$/ || $filename =~ /(.*)/(.*)$/
|| $filename =~ /(.*):(.*)$/) {
$filename = $2;
}
}
sub send_message {
# ($to_email, $cc_email) = split(/,/, $FORM{
rcv_email
}, 2);
my $msg = new MIME::Lite
From => $FORM{
sender_email
},
To => $FORM{
rcv_email
},
# To => $to_email,
Reply-To => $FORM{
sender_email
},
Subject => $FORM{
subject
},
Type => $FORM{
type
},
Data => "$FORM{
content
}
$FORM{
text_file
}";
# $msg->add("Cc" => [$cc_email]) if ($cc_email);
# Attach a part:
if ($FORM{
bin_File
}) {
attach $msg
Type =>
application/octet-stream
,
Encoding =>
base64
,
Data => $FORM{
bin_File
},
Filename => $filename;
}
my $isSendOK = $msg->send;
return($isSendOK);
}
sub send_html {
my $flag = shift;
# webify for HTML output
$FORM{
content
} =~ s/
$FORM{
content
} =~ s/
/
/g;
$FORM{
text_file
} =~ s/
$FORM{
text_file
} =~ s/
/
/g;
my $void_ment = "
¾øÀ½";
$FORM{
sender_email
} = $void_ment unless ($FORM{
sender_email
});
$filename = $void_ment unless ($FORM{
bin_File
});
$FORM{
text_file
} = $void_ment unless ($FORM{
text_file
});
if ($flag) {
print "Content-type: text/html
";
print <
ÀÛ¼ºÇϽŠ¸ÞÀÏÀÌ ¼º°øÀûÀ¸·Î Àü¼ÛµÇ¾ú½À´Ï´Ù.
Àü¼ÛµÈ ³»¿ëÀº ´ÙÀ½°ú °°½À´Ï´Ù.
|
#ffb037
width=100>
±¼¸²
color=
black
>
¹ß½ÅÀÚ Email
$FORM{
sender_email
} |
---|
±¼¸²
color=
black
>
¼ö½ÅÀÚ Email |
$FORM{
rcv_email
} |
---|
|
#ffb037
width=100>
±¼¸²
color=
black
>
Á¦ ¸ñ
$FORM{
subject
} |
---|
|
#ffb037
>
±¼¸²
color=
black
>
³» ¿ë
$FORM{
content
} |
---|
|
#ffb037
>
±¼¸²
color=
black
>
Textµ¡ºÙÀ̱â
$FORM{
text_file
} |
---|
|
#ffb037
>
±¼¸²
color=
black
>
ÆÄÀÏ÷ºÎ
$filename |
---|
Written by C.G.Kim
END_OF_SUCCEED
} else {
&error(
Mail ¼Û½Å ½ÇÆÐ
, "ÀÛ¼ºÇϽŠ¸ÞÀÏÀ» º¸³»´Â °ÍÀÌ ½ÇÆÐÇß½À´Ï´Ù");
}
}
sub error {
my ($title, $detail) = @_;
print "Content-type: text/html
";
print <
$detail
formmail.html·Î ½ÃµµÇØ º¸½Ã°Å³ª,
¾Æ·¡ÀÇ
µ¹¾Æ°¡±â
±Û´ÜÃ߸¦ ´·¯ ´Ù½Ã ½ÃµµÇØ º¸½Ê½Ã¿À.
END_OF_ERROR
exit;
}
¿©±â¸¦ Á¦°¡ ¾à°£ ¼öÁ¤Çؼ ¿î¿µÀÚ¿¡°Ô ¸ÞÀÏÀ» º¸³»´Â ÇÁ·Î±×·¥À»
¸¸µé°í ½Í°Åµç¿ä...
±×·¡¼ ¼öÁ¤Çߴµ¥...
ÀÚ²Ù 91¹ø° ¶óÀÎ ¿¡¼ ¿¡·¯°¡ ³³´Ï´Ù..
¹Ù·Î¿ä ºÎºÐ!!
if ($flag) {
print "Content-type: text/html
";
print <
¾Æ! ±×¸®°í ¾Æ·¡ Á¦°¡ ¼öÁ¤ÇÑ ³»¿ëÀÇ ¼Ò½º¸¦
°°ÀÌ ºÙ¿©³ÖÀ»Å×´Ï.. Á» ±ÍÂú´õ¶óµµ..(Á¤¸»Á˼Û)Á» ¹¹°¡ Ʋ¸°Áö
ºÁÁÖ¼¼¿ä ¤Ð.¤Ð (Á¦°¡ À̰Ŷ«¿¡ ¹Ý´ÞÀÌ»óÀ» ¸Ó¸®ÅÐ ¶âÀ½. ¤Ð.¤Ð)
#!/usr/bin/perl
##############################################################
# Formmail with attachment Beta Version
# Written by C.G.Kim on 98.06.01
#
# This is available only on the Unix/Linux platform
# & on the place Perl 5.xx version is installed.
##############################################################
$form_file = "./formmail.html";
require
cgi-lib.pl
;
use MIME::Lite;
# Call Subroutines
&ReadParse(*FORM);
&check_error;
$isSendFlag= &send_message;
&send_html($isSendFlag);
# End of Main
####### SubRoutines ##########################################
sub check_error {
&error(
Low Perl Version
,
ÆÞ ¹öÀüÀÌ ³·¾Æ¼ ½ÇÇàÇÒ ¼ö ¾ø½À´Ï´Ù.
)
if ($] < 5);
&error(
Field Empty
,
°í°´ Email ÁÖ¼Ò¶õÀÌ ºñ¾î ÀÖ½À´Ï´Ù
)
unless ($FORM{
sender_email
});
&error(
Field Empty
,
¼º¸í¶õÀÌ ºñ¾î ÀÖ½À´Ï´Ù
)
unless ($FORM{
content
});
&error(
Field Empty
,
ÀüȹøÈ£¶õÀÌ ºñ¾î ÀÖ½À´Ï´Ù
)
unless ($FORM{
content1
});
&error(
Field Empty
,
¿ìÆí¹øÈ£¶õÀÌ ºñ¾î ÀÖ½À´Ï´Ù
)
unless ($FORM{
content2
});
&error(
Field Empty
,
ÁÖ¼Ò¶õÀÌ ºñ¾î ÀÖ½À´Ï´Ù
)
unless ($FORM{
content3
});
&error(
Field Empty
,
Á¦¸ñ¶õÀÌ ºñ¾î ÀÖ½À´Ï´Ù
)
unless ($FORM{
subject
});
&error(
Wrong Email Address
,
¼Û½ÅÀÚ Email ÁÖ¼Ò°¡ À߸øµÇ¾ú½À´Ï´Ù
)
if ($FORM{
sender_email
} !~ /@/);
}
sub send_message {
# ($to_email, $cc_email) = split(/,/, champyc@hanmail.net, 2);
my $msg = new MIME::Lite
From => $FORM{
sender_email
},
To =>
champyc@hanmail.net
,
# To => $to_email,
Reply-To => $FORM{
sender_email
},
Subject => $FORM{
subject
},
Type => $FORM{
type
},
Data => "$FORM{
content
}
$FORM{
content1
}
$FORM{
content2
}
$FORM{
content3
}";
# $msg->add("Cc" => [$cc_email]) if ($cc_email);
# Attach a part:
if ($FORM{
bin_File
}) {
attach $msg
Type =>
application/octet-stream
,
Encoding =>
base64
,
Data => $FORM{
bin_File
},
Filename => $filename;
}
my $isSendOK = $msg->send;
return($isSendOK);
}
sub send_html {
my $flag = shift;
# webify for HTML output
$FORM{
content
} =~ s/
$FORM{
content
} =~ s/
/
/g;
$FORM{
text_file
} =~ s/
$FORM{
text_file
} =~ s/
/
/g;
my $void_ment = "¾øÀ½";
$FORM{
sender_email
} = $void_ment unless ($FORM{
sender_email
});
$filename = $void_ment unless ($FORM{
bin_File
});
$FORM{
text_file
} = $void_ment unless ($FORM{
text_file
});
if ($flag) {
print "Content-type: text/html
";
print <
ÀÛ¼ºÇϽŠ½Åû¼°¡ ¼º°øÀûÀ¸·Î Àü¼ÛµÇ¾ú½À´Ï´Ù.
Àü¼ÛµÈ ³»¿ëÀº ´ÙÀ½°ú °°½À´Ï´Ù.
|
#ffb037
width=100>
±¼¸²
color=
black
>
°í°´ Email
$FORM{
sender_email
} |
---|
±¼¸²
color=
black
>
½Åû ´ã´çÀÚ Email |
champyc@hanmail.net |
---|
|
#ffb037
width=100>
±¼¸²
color=
black
>
Á¦ ¸ñ
$FORM{
subject
} |
---|
|
#ffb037
>
±¼¸²
color=
black
>
³» ¿ë
$FORM{
content
} |
---|
|
#ffb037
>
±¼¸²
color=
black
>
Textµ¡ºÙÀ̱â
$FORM{
text_file
} |
---|
|
#ffb037
>
±¼¸²
color=
black
>
ÆÄÀÏ÷ºÎ
$filename |
---|
¹®ÀÇ»çÇ×Àº champyc@hanmail.net ÀÌ°÷À¸·Î ¿¬¶ôÁֽʽÿÀ
END_OF_SUCCEED
} else {
&error(
½Åû¿À·ù
, "ÀÛ¼ºÇϽŠ½Åû¼¸¦ º¸³»´Âµ¥ ½ÇÆÐÇß½À´Ï´Ù.");
}
}
sub error {
my ($title, $detail) = @_;
print "Content-type: text/html
";
print <
$detail
champyc@hanmail.net·Î ÀÌ ½Åû¼ ¾ç½Ä´ë·Î Àû¾î¼ º¸³»½Ã°Å³ª,
¾Æ·¡ÀÇ
µ¹¾Æ°¡±â
±Û´ÜÃ߸¦ ´·¯ ´Ù½Ã ½ÃµµÇØ º¸½Ê½Ã¿À.
END_OF_ERROR
exit;
}
³¡±îÁö ºÁÁּż °¨»ç.. Á¤¸» °í¸¿½À´Ï´Ù..
ÁÁÀºÇÏ·ç µÇ½Ã±¸¿ä ±×·³ ¾È³çÈ÷...