묻고답하기
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
폼메일 소스인데 메일을 보내면 메일이 안날라와요..도와주세요..
2004.09.16 17:58
http://www.tsinter.com/estimail/estiqa_mail_ok.htmlhttp://www.tsinter.com/estimail/estiqa_mail.html도와주세요.
좀 수정을해서 사용할라고하는데 메일이 안날라고요..
=============================estiqa_mail.html=================================================
<body>
<table width="906" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="87" valign="top" bgcolor="#f9f9f9" class="black">
</td>
<td width="2" class="dot"><img src="../image/tran_sp.gif" width="2" height="10"></td>
<td width="8"><img src="../image/tran_sp.gif" width="8" height="10"></td>
<td valign="top" align="center" width="738"> <br>
<table cellPadding="0" cellSpacing="1" width="710" bordercolorlight="#FFFFFF" border="1" bordercolordark="#008080">
<form name="estiqa_mail" action="estiqa_mail_ok.html" method="post">
<script language="javascript">
<!--
function qa_mail(){
var form = document.estiqa_mail;
if(!form.name.value){
alert("작성 하시는 분의 성명을 입력하여 주십시오.");
form.name.focus();
return; }
if (!validEmail(form.email.value)){
alert("보내는 이-메일주소가 올바르지 않습니다. !!!")
form.email.focus();
return;}
if(!form.title.value){
alert("제목을 입력하여 주십시오.");
form.title.focus();
return; }
if(!form.comment.value){
alert("내용을 입력하여 주십시오.");
form.comment.focus();
return; }
url="estiqa_mail_ok.html?name=" + form.name.value + "&email=" + form.email.value
+ "&title=" + form.title.value + "&comment=" + form.comment.value;
window.open(url,'','toolbar=1,status=1,menubar=1,resizable=1,copyhistory=1,directories=1,location=1,scrollbars=1,width=400,height=300,top=10,left=10');
}
function validEmail(email){
invalidChars="/:,;"
for (i=0; i<invalidChars.length; i++){
badChar=invalidChars.charAt(i)
if(email.indexOf(badChar,0)>-1){
return false;}
}
atPos=email.indexOf("@",1)
if(atPos==-1){return false;}
if(email.indexOf("@",atPos+1)>-1){return false;}
periodPos=email.indexOf(".",atPos)
if(periodPos==-1){return false;}
if(periodPos+3>email.length){return false;}
return true;
}
//-->
</script>
<tr>
<td align="right" height="26" width="99" bgcolor=#EFEFEF><font color="blue"><b>인적사항</b></font></td>
<td height="26" width="613"> < 인적사항은 반드시 입력해 주셔야 전송 및 답변메일이
가능합니다. ></td>
</tr>
<tr>
<td align="center" height="25" width="99" bgcolor=#EFEFEF> 성 명</td>
<td height="25" width="613">
<input name="name" size="19">
님</td>
</tr>
<tr>
<td align="center" width="99" bgcolor=#EFEFEF> E-mail</td>
<td width="613">
<input name="email" size="35">
</td>
</tr>
<tr>
<td align="center" width="99" bgcolor=#EFEFEF>제 목</td>
<td width="613">
<input name="title" size="60">
</td>
</tr>
<tr>
<td align="center" width="99" bgcolor=#EFEFEF>내 용</td>
<td width="613" align="center">
<textarea cols="80" name="comment" rows="15"></textarea>
</td>
</tr>
<tr>
<td align="center" bgColor="#FFFFFF" colSpan="2">
<input type="button" value=" 메일 보내기 " onclick="javascript:qa_mail()">
</td>
</tr>
</form>
</table>
<br>
</td>
<td width="67" valign="top" bgcolor="#f9f9f9" class="black">
</td>
<td valign="top" align="center" width="10"> </td>
</tr>
</table>
</body>
</html>
===================================estiqa_mail_ok.html===================================
<?
// Body의 경계에 사용할 데이터 구하기
$boundary = '=_'.md5(uniqid(time()));
$from = $name;
$from_email = $email;
// base64방식으로 엔코딩한다
$from = base64_encode($from);
$from = "From: =?ks_c_5601-1987?B?$from?= <$from_email>";
// 받는 사람
$re_name = "러브PC";
$emailto = "tscmail@kornet.net";
$to = base64_encode($re_name);
$to = "To: =?ks_c_5601-1987?B?$to?= <$emailto>";
$subject = "";
$subject = base64_encode($title);
$subject = "Subject: =?ks_c_5601-1987?B?$subject?= ";
// 해더 작성 ----------------------------------------------------
$headers = "$fromrn$torn$subjectrn";
$headers.= "MIME-Version: 1.0rn";
$headers.= "Content-Type: multipart/mixed;".
chr(13).chr(10).chr(9)."boundary="$boundary"rnrn";
// 바디 작성 ----------------------------------------------------
$body = "--".$boundary."rn";
$body.= "Content-Type: text/html;charset=EUC-KRrn";
$comment = stripslashes($comment);
$body.= "Content-Transfer-Encoding: base64rnrn";
$body.= chunk_split(base64_encode($comment))."rnrn";
$body.= '--'.$boundary."--rnrn";
// 작성된 메일 전송하기 //sendmail 경로 및 시행옵션
$MAILER="/usr/lib/sendmail -t -ba";
// sendmail 프로세스 열기
$fp =popen($MAILER,"w");
// 프로세스로 데이터 보내기
fputs($fp,$headers);
fputs($fp,$body);
// 프로세스 종료
pclose($fp);
if($headers){echo"<p align=center> $re_email 메일로 전달했습니다. <input type=button value=" 확 인 " onclick="javascript:self.close();"></p>";
}else{echo"<p align=center>메일 전달에 실패했습니다' <input type=button value=" 확 인 " onclick="javascript:self.close();"></p>"; }
echo "<br>";
?>
좀 수정을해서 사용할라고하는데 메일이 안날라고요..
=============================estiqa_mail.html=================================================
<body>
<table width="906" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="87" valign="top" bgcolor="#f9f9f9" class="black">
</td>
<td width="2" class="dot"><img src="../image/tran_sp.gif" width="2" height="10"></td>
<td width="8"><img src="../image/tran_sp.gif" width="8" height="10"></td>
<td valign="top" align="center" width="738"> <br>
<table cellPadding="0" cellSpacing="1" width="710" bordercolorlight="#FFFFFF" border="1" bordercolordark="#008080">
<form name="estiqa_mail" action="estiqa_mail_ok.html" method="post">
<script language="javascript">
<!--
function qa_mail(){
var form = document.estiqa_mail;
if(!form.name.value){
alert("작성 하시는 분의 성명을 입력하여 주십시오.");
form.name.focus();
return; }
if (!validEmail(form.email.value)){
alert("보내는 이-메일주소가 올바르지 않습니다. !!!")
form.email.focus();
return;}
if(!form.title.value){
alert("제목을 입력하여 주십시오.");
form.title.focus();
return; }
if(!form.comment.value){
alert("내용을 입력하여 주십시오.");
form.comment.focus();
return; }
url="estiqa_mail_ok.html?name=" + form.name.value + "&email=" + form.email.value
+ "&title=" + form.title.value + "&comment=" + form.comment.value;
window.open(url,'','toolbar=1,status=1,menubar=1,resizable=1,copyhistory=1,directories=1,location=1,scrollbars=1,width=400,height=300,top=10,left=10');
}
function validEmail(email){
invalidChars="/:,;"
for (i=0; i<invalidChars.length; i++){
badChar=invalidChars.charAt(i)
if(email.indexOf(badChar,0)>-1){
return false;}
}
atPos=email.indexOf("@",1)
if(atPos==-1){return false;}
if(email.indexOf("@",atPos+1)>-1){return false;}
periodPos=email.indexOf(".",atPos)
if(periodPos==-1){return false;}
if(periodPos+3>email.length){return false;}
return true;
}
//-->
</script>
<tr>
<td align="right" height="26" width="99" bgcolor=#EFEFEF><font color="blue"><b>인적사항</b></font></td>
<td height="26" width="613"> < 인적사항은 반드시 입력해 주셔야 전송 및 답변메일이
가능합니다. ></td>
</tr>
<tr>
<td align="center" height="25" width="99" bgcolor=#EFEFEF> 성 명</td>
<td height="25" width="613">
<input name="name" size="19">
님</td>
</tr>
<tr>
<td align="center" width="99" bgcolor=#EFEFEF> E-mail</td>
<td width="613">
<input name="email" size="35">
</td>
</tr>
<tr>
<td align="center" width="99" bgcolor=#EFEFEF>제 목</td>
<td width="613">
<input name="title" size="60">
</td>
</tr>
<tr>
<td align="center" width="99" bgcolor=#EFEFEF>내 용</td>
<td width="613" align="center">
<textarea cols="80" name="comment" rows="15"></textarea>
</td>
</tr>
<tr>
<td align="center" bgColor="#FFFFFF" colSpan="2">
<input type="button" value=" 메일 보내기 " onclick="javascript:qa_mail()">
</td>
</tr>
</form>
</table>
<br>
</td>
<td width="67" valign="top" bgcolor="#f9f9f9" class="black">
</td>
<td valign="top" align="center" width="10"> </td>
</tr>
</table>
</body>
</html>
===================================estiqa_mail_ok.html===================================
<?
// Body의 경계에 사용할 데이터 구하기
$boundary = '=_'.md5(uniqid(time()));
$from = $name;
$from_email = $email;
// base64방식으로 엔코딩한다
$from = base64_encode($from);
$from = "From: =?ks_c_5601-1987?B?$from?= <$from_email>";
// 받는 사람
$re_name = "러브PC";
$emailto = "tscmail@kornet.net";
$to = base64_encode($re_name);
$to = "To: =?ks_c_5601-1987?B?$to?= <$emailto>";
$subject = "";
$subject = base64_encode($title);
$subject = "Subject: =?ks_c_5601-1987?B?$subject?= ";
// 해더 작성 ----------------------------------------------------
$headers = "$fromrn$torn$subjectrn";
$headers.= "MIME-Version: 1.0rn";
$headers.= "Content-Type: multipart/mixed;".
chr(13).chr(10).chr(9)."boundary="$boundary"rnrn";
// 바디 작성 ----------------------------------------------------
$body = "--".$boundary."rn";
$body.= "Content-Type: text/html;charset=EUC-KRrn";
$comment = stripslashes($comment);
$body.= "Content-Transfer-Encoding: base64rnrn";
$body.= chunk_split(base64_encode($comment))."rnrn";
$body.= '--'.$boundary."--rnrn";
// 작성된 메일 전송하기 //sendmail 경로 및 시행옵션
$MAILER="/usr/lib/sendmail -t -ba";
// sendmail 프로세스 열기
$fp =popen($MAILER,"w");
// 프로세스로 데이터 보내기
fputs($fp,$headers);
fputs($fp,$body);
// 프로세스 종료
pclose($fp);
if($headers){echo"<p align=center> $re_email 메일로 전달했습니다. <input type=button value=" 확 인 " onclick="javascript:self.close();"></p>";
}else{echo"<p align=center>메일 전달에 실패했습니다' <input type=button value=" 확 인 " onclick="javascript:self.close();"></p>"; }
echo "<br>";
?>
그리고 위 소스를 보니, 기본적인 이해없이 무조건 Copy & Paste 해 놓은것 같은데..
boundary, base64_encode등은 님이 보내시려는 메일에서는 필요 없습니다.
의미없는 코드도 많이 있고요..