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

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

  공개 자료실 

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

리눅스(Linux) 서버

[re] mail.php3

2004.11.14 09:08

문학 조회 수:2651

<?
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
  

번호 제목 글쓴이 날짜 조회 수
30 홈페이지를 구성하려면...비용은 얼마나 들까?( 리눅스 7) file 문학 2007.04.15 1992
29 홈페이지를 구성의 종류 ( 리눅스 8) file 문학 2007.04.15 2071
28 FTP 연결에 대하여... ( 리눅스 9) file 문학 2007.04.15 2381
27 센드메일에 대하여... ( 리눅스 10) file 문학 2007.04.15 2247
26 FTP 연결에 대하여... (2) ( 리눅스 11) file 문학 2007.04.15 2131
25 홈페이지 무료 계정과 유료 계정의 차이 ( 리눅스 12) file 문학 2007.04.15 2749
24 한컴 리눅스 메인 화면 ( 리눅스 13) file 문학 2007.04.15 3434
23 한컴 리눅스 메인 화면 2 ( 리눅스 14) file 문학 2007.04.15 2298
22 한컴 리눅스 아파치 화면( 리눅스 15) file 문학 2007.04.15 3543
21 메가패스 "공유기 리셋(재부팅)/펌웨어 업그레이드 요청"1( 리눅스 16) file 문학 2007.04.15 3577
20 메가패스 "공유기 리셋(재부팅)/펌웨어 업그레이드 요청"2( 리눅스 17) file 문학 2007.04.15 3261
19 한컴 리눅스 센드메일( 리눅스 18) file 문학 2007.04.15 3215
18 한컴 리눅스 센드메일( 리눅스 19) file 문학 2007.04.15 2903
17 한컴 리눅스 센드메일( 리눅스 20) file 문학 2007.04.15 2844
16 한컴 리눅스 센드메일( 리눅스 21) file 문학 2007.04.15 2806
15 웹호스팅 신청과 연관하여...( 리눅스 21) file 문학 2007.04.15 2954
14 웹호스팅 신청과 연관하여...( 리눅스 22) file 문학 2007.04.15 3027
13 제로보드에 대하여...( 리눅스 23) file 문학 2007.04.15 2897
12 제로보드에 대하여...( 리눅스 24) file 문학 2007.04.15 2830
11 제로보드에 대하여... (2) ( 리눅스 25) file 문학 2007.04.15 2854