HEX
Server: Apache/2.4.37 (CentOS Stream) OpenSSL/1.1.1k
System: Linux ysnet.com.tw 4.18.0-553.5.1.el8.x86_64 #1 SMP Tue May 21 05:46:01 UTC 2024 x86_64
User: test (521)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: //proc/thread-self/cwd/send_cancel_email.php
<?php
// send_cancel_email.php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // 安全接收並處理 POST 變數
    $user_id = isset($_POST['user_id']) ? htmlspecialchars(trim($_POST['user_id'])) : '';
	$phone  = isset($_POST['phone']) ? htmlspecialchars(trim($_POST['phone'])) : '';
	$reason  = isset($_POST['reason']) ? htmlspecialchars(trim($_POST['reason'])) : '';
	$email   = isset($_POST['email']) ? htmlspecialchars(trim($_POST['email'])) : '';
	$apply   = isset($_POST['apply']) ? htmlspecialchars(trim($_POST['apply'])) : '';

//   $user_id = "2025022409";
//   $phone  = "0987654321";
//   $reason  = "測試";
//   $email   = "johnson770623@yahoo.com";
	if ($apply){
    	// 主旨與內文
    	$subject = "[定期定額付款申請通知] 客戶編號:$user_id";
    	$message = "您好,\n\n我們已收到您的定期定額付款申請,以下為您填寫的資料:\n\n" .
               "用戶 ID:$user_id\n" .
               "聯絡電話:$phone\n\n" .
               "我們將於 1~2 個工作天內與您聯繫,謝謝!\n\n亞訊客服團隊 敬上";

    	// 內部通知信件(寄給 service@ysnet.com.tw)
    	$adminSubject = "[通知] 有客戶申請定期扣款付款 (用戶ID: $user_id)";
    	$adminMessage = "有一位客戶申請定期扣款付款,以下是客戶填寫內容:\n\n" .
                    "用戶 ID:$user_id\n" .
                    "聯絡電話:$phone\n" .
                    "電子信箱:$email\n" ;

    	$headers = "From: service@ysnet.com.tw\r\n" .
               "Reply-To: service@ysnet.com.tw\r\n" .
               "Content-Type: text/plain; charset=UTF-8";

    	// 寄出信件(給客戶)
    	$sentToClient = mail($email, $subject, $message, $headers);

    	// 寄出信件(給管理員)
    	$sentToAdmin = mail("service@ysnet.com.tw", $adminSubject, $adminMessage, $headers);

    	if ($sentToClient && $sentToAdmin) {
        	echo "success";
    	} else {
        	echo "failed";
    	}
    } else {
   	
    	// 主旨與內文
    	$subject = "[定期定額扣款終止申請通知] 客戶編號:$user_id";
    	$message = "您好,\n\n我們已收到您的定期扣款終止申請,以下為您填寫的資料:\n\n" .
               "用戶 ID:$user_id\n" .
               "聯絡電話:$phone\n" .
               "終止原因:$reason\n\n" .
               "我們將於 1~2 個工作天內與您聯繫,謝謝!\n\n亞訊客服團隊 敬上";

    	// 內部通知信件(寄給 service@ysnet.com.tw)
    	$adminSubject = "[通知] 有客戶申請終止定期扣款 (用戶ID: $user_id)";
    	$adminMessage = "有一位客戶申請終止定期扣款,以下是客戶填寫內容:\n\n" .
                    "用戶 ID:$user_id\n" .
                    "聯絡電話:$phone\n" .
                    "電子信箱:$email\n" .
                    "終止原因:$reason\n";

    	$headers = "From: service@ysnet.com.tw\r\n" .
               "Reply-To: service@ysnet.com.tw\r\n" .
               "Content-Type: text/plain; charset=UTF-8";

    	// 寄出信件(給客戶)
    	$sentToClient = mail($email, $subject, $message, $headers);

    	// 寄出信件(給管理員)
    	$sentToAdmin = mail("service@ysnet.com.tw", $adminSubject, $adminMessage, $headers);

    	if ($sentToClient && $sentToAdmin) {
        	echo "success";
    	} else {
        	echo "failed";
    	}
    }

} else {
   echo "無效的請求方式";
}
?>