/home/mjc1/public_html/emillennium/statement.email.send_old.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
$dir 
".";
include_once(
$dir."/_common.php");

if(
$eid==''){
    
alert('e천년경영 로그인 후에 이용가능합니다.',"index.php"); exit;
}

$sql "select * from user_config where menu_name = 'EmailOptionWindow' "// 메일설정의 내용을 가져온다.
$res mysql_query($sql,$connect_e1000y);
while(
$minfo mysql_fetch_array($res)){
    if(
$minfo['config_key']=='메일서버정보_SMTP'){ $uc_smtp $minfo['config_val']; }
    if(
$minfo['config_key']=='메일서버정보_포트번호'){ $uc_port $minfo['config_val']; }

    if(
$minfo['config_key']=='메일서버정보_사용자_ID'){ $uc_id $minfo['config_val']; }
    if(
$minfo['config_key']=='메일서버정보_패스워드2'){ 
        
$uc_pw $minfo['config_val']; 
        
$uc_pw decrypt($uc_pw,"m.j.s.f.t"); // 암호 푼다.
    
}
}

function 
add_file($files){
    Global 
$eid;
    
$mktime date("YmdHis",time());
    
$rtn_file null;
    
$cnt 0;
    foreach(
$files as $key=>$f){
        if(
$f['name']!=''){
            
$ff null;
            
$dest "./tmp/{$eid}_{$mktime}_add{$cnt}";
            
copy($f['tmp_name'],$dest);
            
$ff['dest'] = $dest;
            
$ff['fname'] = $f['name'];
            
$rtn_file[] = $ff;
            
$cnt++;
        }
    }
    return 
$rtn_file;
}

include(
"./lib/PHPMailer5/PHPMailerAutoload.php"); // phpmailer 5 모듈 그누보드 2.0 모듈하고 몇몇 명령어나 대소문자나 기타 틀림

$smtp_use $uc_smtp;
$smtp_port $uc_port;
$smtp_mail_id $uc_id;
$smtp_mail_pw $uc_pw;

$files add_file($_FILES); // 첨부파일 배열 처리

$st_path "./tmp/{$file_name}"// 거래명세표 파일 처리
$st_name $file_name// 거래명세표 파일 처리

// 한글깨지면 class.phpmailer.php 파일에 public $CharSet = 'iso-8859-1'; 라인을 public $CharSet = 'utf-8';으로 수정 할것.
$mail = new PHPMailer(true);
$mail->IsSMTP();
$mail->SMTPDebug 2//// 0 = off (for production use) 1 = client messages 2 = client and server messages
$mail->Host $smtp_use;   // email 보낼때 사용할 서버를 지정
$mail->SMTPAuth true;          // SMTP 인증을 사용함
$mail->Port $smtp_port;            // email 보낼때 사용할 포트를 지정
if($uc_port=='465'){
  
$mail->SMTPSecure "ssl";        // SSL을 사용함
} else if($uc_port=='587'){
  
$mail->SMTPSecure "tls";        // TLS을 사용함
}
$mail->Username   $smtp_mail_id// 계정
$mail->Password   $smtp_mail_pw// 패스워드

$mail->setFrom($send_email$send_name);
$v explode(",",$recv_email); // 받는사람 추가 , 로 여러명 지원
foreach($v as $key=>$val){
if(
trim($val)!=''){
    
$mail->addAddress($val);
}
}
$mail->Subject $email_subject;         // 메일 제목
$mail->isHTML(true); 
$mail->Body $email_content."<br>";
$mail->addAttachment($st_path$st_name);
foreach(
$files as $key=>$f){
  
$mail->addAttachment($f['dest'], $f['fname']);
}
$res $mail->send();              // 실제로 메일을 보냄

if($res=='1'){
    
//echo "메일을 전송하였습니다."; 
    
$sql "update sale_m set receipt_yn = 1, receipt_date = '".date("Y-m-d H:i:s",time())."'
                where midx in (
{$midx_list})
    "
;
    
mysql_query($sql,$connect_e1000y);
?>
<script>
    alert('메일 전송을 완료하였습니다.');
    parent.window.opener.document.location.reload();
    window.close();
</script>
<?php
} else {
    echo 
"메일 전송에 실패하였습니다. 보내는 메일 설정이나 여러가지를 확인해보시기 바랍니다. 아래 에러문구 기반으로 고객센터에 연락하시기 바랍니다.<br>";
    echo 
$mail->ErrorInfo;
}

?>