/home/mjc1/public_html/j3demo/adm/mail_send_process.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
<?php
include("./_common.php");

//_pr($_GET);

$post_list "";
foreach(
$_POST as $key=>$val){
    
$post_list .= "$key:$val,";
}

$mailing_array = Array();

if(
$cust_type=='all'){
    
$where "";
    if(
$mailing_type=='1'){
        
$where .= " and user_define4 = '1' ";
    }
    if(
$cust_level!='all'){
        
$where .= " and user_define5 = '{$cust_level}' ";
    }
    if(
$mail_addr_search!=''){
        
$where .= " and email like '%{$mail_addr_search}%' ";
    }

    
$sql "select * from customers where biztype = 1 and email <> '' and email <> '@' {$where} ";
    
//_pr($sql);
    
$res mysql_query($sql,$connect_j3);
    while(
$info=mysql_fetch_array($res)){
        
$add "Y";
        foreach(
$mailing_array as $key=>$val){
            if(
$info['email']==$val){ $add "N"; }
        }
        if(
$add=='Y'){
            
$mailing_array[] = $info['email'];
        }
    }
} else {
    
$email_list substr($email_list,0,strlen($email_list)-1);
    
$mailing_array explode(",",$email_list);
}

if(
$mode=='ajax'){ // 발송 가능한 갯수만 추려 표시한다.
    
echo count($mailing_array);
} else {

    
$mail_list "";
    foreach(
$mailing_array as $key=>$val){
        
$mail_list .= "{$val},";
    }
    
$mail_list substr($mail_list,0,strlen($mail_list)-1);

    
$sql "select * from shop_mail where idx = '{$idx}' ";
    
$mail_info sql_fetch($sql,$connect_j3);

    
$ma_subject $mail_info['ma_subject'];
    
$ma_content $mail_info['ma_content'];

    
$snd_email $config['admin_email'];
    
$rcv_email $mail_list;
    
//echo $rcv_email;
    
$mail = new PHPMailer;

    
$rtn email_send($mail$ma_subject$ma_content$snd_email$rcv_email);
    if(
$rtn=='OK'){
        
$ma_last_option $mail_info['ma_last_option']."time:".G5_TIME_YMDHIS." / _get:".$post_list." / mailling:{$mail_list}".chr(10).chr(10);
        
$sql "update shop_mail set
                    ma_last_option = '
{$ma_last_option}'
                where idx = '
{$idx}'
        "
;
        
mysql_query($sql,$connect_j3);
?>
<script>
    alert('메일 발송이 완료되었습니다.');
    document.location.href='mail_list.php';
</script>
<?php
    
} else {
        
_pr($rtn);
    }
}
?>