--- 디지털 인쇄로 책을...

     ---리룩스서버컴퓨터 백업

  공개 자료실 

 文學위의 文學 출판사입니다. PDF로 전환하여 복사기로 책을 만듭니다. 자세한 내용은, '디지털 인쇄'에서 확인해 보세요!

리눅스(Linux) 서버

[re] mail.php3

2004.11.14 09:08

문학 조회 수:2639

<?
function Error($msg) {
echo("
<html>
<head>
<title>에러...!</title>
<link rel=StyleSheet href=cucky.css type=text/css>
</head>
<body bgcolor='white' text='black' link='blue' vlink='purple' alink='red' leftmargin='0' marginwidth='0' topmargin='0' marginheight='0'>
<table border='0' cellpadding='0' cellspacing='0' width='300' height='400'>
<tr>
<td>
<p align='center'>
<font color=004080>$msg</font><br><br><br>
<input type=button value=' Back ' onclick=history.back() style=border-color:#004080;background-color:#004080;color:#ffffff;font-si ze:8pt;font-family:Tahoma;>
</td>
</tr>
</table>
</body>
</html>
");
exit;
}
## 수신 확인결과 출력
if ($mode == reply) {
$add = "From : $tomail\r\n"; //수신자
$add .= "X-Mailer: iteach4u Mailer. by dikafryo\r\n"; //헤더 정보
$add .= "MIME-Version: 1.0\r\n"; // Type
$add .= "content-Type: text/html; charset=euc-kr\r\n"; // 캐릭터셋 한글로 변환
$rdate = date("Y년m월d일 H:i"); // 확인한 현재 시간
$subject = "ITEACH4U.NET 수신확인 메일입니다."; // 메일 제목
$cont = " // 내용
수신확인 : $tomail
메일제목 : $subject
읽은시간 : $rdate
<br>
<a href='http://www.munhag.com' target='_blank'>文學 위의 文學</a>";
mail($frommail, $subject, $cont, $add); // 멜 보내기~!
}

## 수신 확인이 아닐때.. (발신이란 뜻)
else {

## 내용이 빠지면 에러메시지 출력~~!
if(!$tomail) Error('받는사람의 메일주소가 없습니다.');
if(!$from) Error('보내는 사람 이름은 필수입니다.');
if(!$frommail) Error('보내사람 메일주소는 필수입니다.');
if(!$subject) Error('제목을 쓰셔야죠.');
if(!$content) Error('내용이 없네요.');

####################
## 메일보내기 형식##
####################

######### 설치하려는 도메인을 적으세요..
$url = "http://www.munhag.com/mail/";
#######################################

## 요기서부터가 진짜루 메일 보낼때 쓰이는 코드입니다...
## 저두 하나하나의 확실한 내용은 잘 모르지만... 웬만하면 다 쓰세요....
## 여러 문서를 참고하시다보면... 아실 수 있을겁니다..
## 지금 시점에서... 잊어버린게 많아서 확실한 주석을 달지 못하겠네요... 죄송..-_-++

$add = "Return-Path: $frommail\r\n"; // 메일이 안 보내졌을때 돌아오는 건가..? 불확실...
$add .= "From: $from <$frommail>\r\n"; // 아시겠져... 보내는 사람입니다..
$add .= "Reply-To: $frommail\r\n"; // 답변받는 메일주소입니다... 위의 3개가 대부분 같아야 겠죠....
$add .= "X-Mailer: iteach4u Mailer. by dikafryo\r\n"; // 그냥 쓴 겁니다.. 멋있어 보일라구...

######################
### 파일이 첨부되었을때...###
######################

if ($file && $file_size) {
$filename=basename($file_name); // 파일첨부에 관한 내용은 다른 분의 소스를 참고로 하였기에
$file_result=fopen($file,"r"); // 저두 확실히 모르는 점이 많습니다..
$file=fread($file_result,$file_size); // 물론 베낀건 아니구 제 나름대로 수정작업을 거쳤죠...
// 물론...-_-;; 거의 베낀거나 다름없지만... 이 바닥이 다 그런거죠.. 뭐~~ 흠.....^^
fclose($file_result);

##파일타입이 없으면 다음 출력
if ($file_type == "") {
$file_type = "application/octet-stream";
}

$boundary = "--------" . uniqid("part"); // 파일첨부에 관한 코드는 되도록이면 그대로 사용하시기 바랍니다..
// 엄청난 수정 끝에 정리된 겁니다..... 휴~~ 더 제대로 된거 없나... -_-;;
$add .= "MIME-Version: 1.0\r\n";
$add .= "content-Type: multipart/mixed; boundary=\"$boundary\"";
$body = "This is a multi-part message in MIME format.\r\n\r\n";
$body .= "--$boundary\r\n";

### 수신확인을 위한 I프레임 삽입!!! 말그대로.. 내용 밑에 수신확인메일을 보낼 I프레임을 넣었죠... 가로, 세로 빵으로... 안보이죠...^^
$content_html .="
$content
<br><a href='http://www.munhag.com' target='_blank'>文學 위의 文學
<IFRAME width='0' height='0' marginwidth='0' marginheight='0' hspace='0' vspace='0' frameborder='0' src='".$url."mail.php3?mode=reply&tomail=$frommail&subject=$subject&frommail=$tomail'></iframe>";

$content_text .="
<br><a href=http://www.munhag.com target=_blank>文學 위의 文學</a>
<IFRAME width='0' height='0' marginwidth='0' marginheight='0' hspace='0' vspace='0' frameborder='0' src='".$url."mail.php3?mode=reply&tomail=$frommail&subject=$subject&frommail=$tomail'></iframe>";

### 메일형식 html or text
if ($html) {
$body .= "content-Type: text/html; charset=euc-kr\r\n";
$body .= "content-Transfer-Encoding: 8bit\r\n\r\n";
$body .= nl2br(stripslashes($content_html)) . "\r\n\r\n";
}
else {

$body .= "content-Type: text/html; charset=euc-kr\r\n";
$body .= "content-Transfer-Encoding: 8bit\r\n\r\n";
$body .= nl2br(htmlspecialchars(stripslashes($content))) . "\r\n\r\n";
$body .= nl2br(stripslashes($content_text)) . "\r\n\r\n";
}

### 공통형식 html이든 text든 공통으로 가지는 코드입니다.....
$body .= "--$boundary\r\n";
$body .= "content-Type: $file_type; name=\"$filename\"\r\n";
$body .= "content-Transfer-Encoding: base64\r\n\r\n";
$body .= ereg_replace("(.{80})","\\1\r\n",base64_encode($file));
$body .= "\r\n--$boundary" . "\r\n";

}

########################
### 파일이 첨부되지 않으면...###
########################

else {
if ($html) { // html 형식일때..
$add .= "MIME-Version: 1.0\r\n";
$add .= "content-Type: text/html; charset=euc-kr\r\n";
$body = nl2br(stripslashes($content)) . "\r\n\r\n";
}
else { // text 형식일때...
$add .= "MIME-Version: 1.0\r\n";
$add .= "content-Type: text/html; charset=euc-kr\r\n";
$body = nl2br(htmlspecialchars(stripslashes($content))) . "\r\n\r\n";
}

### 수신확인을 위한 I프레임 삽입!!! 말그대로.. 내용 밑에 수신확인메일을 보낼 I프레임을 넣었죠... 가로, 세로 빵으로... 안보이죠...^^
$body .="
<br><a href=http://www.munhag.com target=_blank>文學 위의 文學</a>
<IFRAME width='0' height='0' marginwidth='0' marginheight='0' hspace='0' vspace='0' frameborder='0' src='".$url."mail.php3?mode=reply&tomail=$frommail&subject=$subject&frommail=$tomail'></iframe>";
}

$result=mail( $tomail , $subject , $body , $add );

####################
## 결과 출력 ##
####################

if($result) {
?>
<script>
alert("메일을 정상적으로 보냈습니다.");
history.go(-2);
</script>
<?
} else {
?>
<script>
alert("메일 발송이 실패했습니다.");
history.go(-1);
</script>
<?
}
}
?> 2004-10-28
20:26:18