묻고답하기
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
첨부파일 폼메일에서...
2002.08.23 16:36
첨부파일 폼메일을 수정해서 신청서 등을 메일로 보내려는데요,
첨부파일을 넣지 않을때는 필드값들이 메일로 모두 들어오는데,
첨부파일을 첨부해서 메일을 보내면 필드값들이 메일로 들어오지 않거든요.
누구 아시는 분 있으면 도와주세요.
꼭이요~~
---------------------------------------------------------------
소스 1 (메일보내는 폼)
---------------------------------------------------------------
<html>
<head>
<title>Untitled Document</title>
<link href="css.css" rel="stylesheet" type="text/css">
</head>
<script language="javascript">
<!--
function checkIt(form) {
if(!form.sender.value) {
alert('need your name.'+ '+ ');
form.sender.focus();
return;
}
if(!form.position.value) {
alert('need position.');
form.position.focus();
return;
}
if(!form.sender_email.value) {
alert('input yoour email please.');
form.sender_email.focus();
return;
}
form.submit();
}
//-->
</script>
<body leftmargin="2" topmargin="0" marginwidth="2" marginheight="0">
<b>All fields are required.</b><br><br>
<table width=450 border=0 cellpadding=3 cellspacing=0 bgcolor=white>
<form method="post" enctype="multipart/form-data" action="employ_send.php">
<tr bgcolor=#f7f7f7><td width=240>Name :</td><td width=210><input type="text" name="sender" size="32"></td></tr>
<tr><td width=240>Company :</td><td width=210><input type=text size=32 name="company"></td></tr>
<tr bgcolor=#f7f7f7><td width=240>Your Position :</td><td width=210><input type=text size=32 name="position"></td></tr>
<tr><td width=240>Telephone :</td><td width=210><input type=text size=32 name="tel"></td></tr>
<tr bgcolor=#f7f7f7><td width=240>Fax :</td><td width=210><input type=text size=32 name="fax"></td></tr>
<tr><td width=240>Email :</td><td width=210><input type="text" name="sender_email" size="35"></td></tr>
<tr bgcolor=#f7f7f7><td width=240>Upload vacancy details document :</td><td width=210><input type=file name="userfile" size=20 value=''></td></tr>
<tr><td colspan=2 align="center"><input type="button" value="SEND"onClick="checkIt(this.form)"> <input type=reset VALUE=RESET size=35></td></tr>
</form>
</table>
<br>
</body>
</html>
---------------------------------------------------------------
소스 2 (메일처리 php)
---------------------------------------------------------------
<?
$receiver = "ASIArecruit administrator";
$receiver_email = "woog@donow.co.kr";
$subject = "new employers resruit";
$current_time = time();
$signdate = date("Y/m/d, H:i:s", $current_time);
//메일 header
$add_header .= "Return-Path: $senderrn";
$add_header .= "From: $sender_emailrn";
$add_header .= "X-Mailer: webmailrn";
$boundary = "----".uniqid("part");
if($userfile && $userfile_size) {
$filename = basename($userfile_name);
$fp = fopen($userfile, "r");
$file = fread($fp, $userfile_size);
fclose($fp);
if($userfile_type == "") {
$userfile_type = "application/octet-stream";
}
// header part
// Multipart/mixed 일경우 첨부파일이 있다는 것을 의미한다.
$add_header .= "MIME-Version: 1.0rn";
$add_header .= "Content-Type: Multipart/mixed; boundary = "$boundary"";
// 본문파트
$mailbody = "This is a multi-part message in MIME format.rnrn";
$mailbody .= "--$boundaryrn";
$mailbody .= "Content-Type: text/html; charset="ks_c_5601-1987"rn";
$mailbody .= "Content-Transfer-Encoding: base64rnrn";
$mailbody .= base64_encode($sender)."rnrn";
$mailbody .= base64_encode($company)."rnrn";
$mailbody .= base64_encode($position)."rnrn";
$mailbody .= base64_encode($tel)."rnrn";
$mailbody .= base64_encode($fax)."rnrn";
// 파일첨부파트
$mailbody .= "--$boundaryrn";
$mailbody .= "Content-Type: $userfile_type; name="$filename"rn";
$mailbody .= "Content-Transfer-Encoding: base64rn";
$mailbody .= "Content-Disposition: attachment; filename="$filename"rnrn";
$mailbody .= base64_encode($file)."rnrn";
// 멀티파트 종료
$mailbody .= "--$boundary--";
}
else {
$current_time = time();
$signdate = date("Y/m/d, H:i:s", $current_time);
$messages_temp01 = nl2br("$sender");
$messages_temp02 = nl2br("$position");
$messages_temp03 = nl2br("$tel");
$messages_temp04 = nl2br("$fax");
$mailbody = "To : $receiver";
$mailbody .= "<p>";
$mailbody .= "Subject : $subject";
$mailbody .= "<p>";
$mailbody .= "======================= 내용 ==================== <p>";
$mailbody .= "NAME : $messages_temp01";
$mailbody .= "<br>";
$mailbody .= "POSITION : $messages_temp02";
$mailbody .= "<br>";
$mailbody .= "TEL : $messages_temp03";
$mailbody .= "<br>";
$mailbody .= "FAX : $messages_temp04";
$mailbody .= "<p>";
$mailbody .= "================================================= <p>";
$mailbody .= "from: $sender($sender_email)";
$mailbody .= "<p>";
$mailbody .= "$signdaten";
$add_header = "From: $sender_emailn";
$add_header .= "Reply-To: $sender_emailn";
$add_header .= "Content-Type: text/html;charset=EUC-KR";
}
mail($receiver_email, $subject, $mailbody, $add_header);
// 되돌아 가기
echo("
<script>
window.alert('Success... thanks. ');
location = 'employ.html';
</script>
")
?>
첨부파일을 넣지 않을때는 필드값들이 메일로 모두 들어오는데,
첨부파일을 첨부해서 메일을 보내면 필드값들이 메일로 들어오지 않거든요.
누구 아시는 분 있으면 도와주세요.
꼭이요~~
---------------------------------------------------------------
소스 1 (메일보내는 폼)
---------------------------------------------------------------
<html>
<head>
<title>Untitled Document</title>
<link href="css.css" rel="stylesheet" type="text/css">
</head>
<script language="javascript">
<!--
function checkIt(form) {
if(!form.sender.value) {
alert('need your name.'+ '+ ');
form.sender.focus();
return;
}
if(!form.position.value) {
alert('need position.');
form.position.focus();
return;
}
if(!form.sender_email.value) {
alert('input yoour email please.');
form.sender_email.focus();
return;
}
form.submit();
}
//-->
</script>
<body leftmargin="2" topmargin="0" marginwidth="2" marginheight="0">
<b>All fields are required.</b><br><br>
<table width=450 border=0 cellpadding=3 cellspacing=0 bgcolor=white>
<form method="post" enctype="multipart/form-data" action="employ_send.php">
<tr bgcolor=#f7f7f7><td width=240>Name :</td><td width=210><input type="text" name="sender" size="32"></td></tr>
<tr><td width=240>Company :</td><td width=210><input type=text size=32 name="company"></td></tr>
<tr bgcolor=#f7f7f7><td width=240>Your Position :</td><td width=210><input type=text size=32 name="position"></td></tr>
<tr><td width=240>Telephone :</td><td width=210><input type=text size=32 name="tel"></td></tr>
<tr bgcolor=#f7f7f7><td width=240>Fax :</td><td width=210><input type=text size=32 name="fax"></td></tr>
<tr><td width=240>Email :</td><td width=210><input type="text" name="sender_email" size="35"></td></tr>
<tr bgcolor=#f7f7f7><td width=240>Upload vacancy details document :</td><td width=210><input type=file name="userfile" size=20 value=''></td></tr>
<tr><td colspan=2 align="center"><input type="button" value="SEND"onClick="checkIt(this.form)"> <input type=reset VALUE=RESET size=35></td></tr>
</form>
</table>
<br>
</body>
</html>
---------------------------------------------------------------
소스 2 (메일처리 php)
---------------------------------------------------------------
<?
$receiver = "ASIArecruit administrator";
$receiver_email = "woog@donow.co.kr";
$subject = "new employers resruit";
$current_time = time();
$signdate = date("Y/m/d, H:i:s", $current_time);
//메일 header
$add_header .= "Return-Path: $senderrn";
$add_header .= "From: $sender_emailrn";
$add_header .= "X-Mailer: webmailrn";
$boundary = "----".uniqid("part");
if($userfile && $userfile_size) {
$filename = basename($userfile_name);
$fp = fopen($userfile, "r");
$file = fread($fp, $userfile_size);
fclose($fp);
if($userfile_type == "") {
$userfile_type = "application/octet-stream";
}
// header part
// Multipart/mixed 일경우 첨부파일이 있다는 것을 의미한다.
$add_header .= "MIME-Version: 1.0rn";
$add_header .= "Content-Type: Multipart/mixed; boundary = "$boundary"";
// 본문파트
$mailbody = "This is a multi-part message in MIME format.rnrn";
$mailbody .= "--$boundaryrn";
$mailbody .= "Content-Type: text/html; charset="ks_c_5601-1987"rn";
$mailbody .= "Content-Transfer-Encoding: base64rnrn";
$mailbody .= base64_encode($sender)."rnrn";
$mailbody .= base64_encode($company)."rnrn";
$mailbody .= base64_encode($position)."rnrn";
$mailbody .= base64_encode($tel)."rnrn";
$mailbody .= base64_encode($fax)."rnrn";
// 파일첨부파트
$mailbody .= "--$boundaryrn";
$mailbody .= "Content-Type: $userfile_type; name="$filename"rn";
$mailbody .= "Content-Transfer-Encoding: base64rn";
$mailbody .= "Content-Disposition: attachment; filename="$filename"rnrn";
$mailbody .= base64_encode($file)."rnrn";
// 멀티파트 종료
$mailbody .= "--$boundary--";
}
else {
$current_time = time();
$signdate = date("Y/m/d, H:i:s", $current_time);
$messages_temp01 = nl2br("$sender");
$messages_temp02 = nl2br("$position");
$messages_temp03 = nl2br("$tel");
$messages_temp04 = nl2br("$fax");
$mailbody = "To : $receiver";
$mailbody .= "<p>";
$mailbody .= "Subject : $subject";
$mailbody .= "<p>";
$mailbody .= "======================= 내용 ==================== <p>";
$mailbody .= "NAME : $messages_temp01";
$mailbody .= "<br>";
$mailbody .= "POSITION : $messages_temp02";
$mailbody .= "<br>";
$mailbody .= "TEL : $messages_temp03";
$mailbody .= "<br>";
$mailbody .= "FAX : $messages_temp04";
$mailbody .= "<p>";
$mailbody .= "================================================= <p>";
$mailbody .= "from: $sender($sender_email)";
$mailbody .= "<p>";
$mailbody .= "$signdaten";
$add_header = "From: $sender_emailn";
$add_header .= "Reply-To: $sender_emailn";
$add_header .= "Content-Type: text/html;charset=EUC-KR";
}
mail($receiver_email, $subject, $mailbody, $add_header);
// 되돌아 가기
echo("
<script>
window.alert('Success... thanks. ');
location = 'employ.html';
</script>
")
?>