當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


PHP WHMCS SendAdminEmail用法及代碼示例

發送管理員電子郵件通知

請求參數

參數 類型 說明 必需的
action string “SendAdminEmail” Required
messagename string 要發送的管理員電子郵件模板的名稱 Optional
custommessage string 為自定義電子郵件發送的 HTML 消息正文 Optional
customsubject string 發送自定義電子郵件的主題 Optional
type string 將發送哪種類型的管理員通知 (‘system’, ‘account’, ‘support’) Optional
deptid int 如果‘support’ $type,則通知所針對的部門ID Optional
mergefields array 要在電子郵件模板中使用的合並字段 Optional

響應參數

參數 類型 說明
result string 操作結果:成功或錯誤

示例請求 (CURL)

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.example.com/includes/api.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
    http_build_query(
        array(
            'action' => 'SendAdminEmail',
            // See https://developers.whmcs.com/api/authentication
            'username' => 'IDENTIFIER_OR_ADMIN_USERNAME',
            'password' => 'SECRET_OR_HASHED_PASSWORD',
            'messagename' => 'Service Unsuspension Successful',
            'mergefields' => array('client_id' => 1, 'service_id' => 1, 'service_product' => 'This is a product', 'service_domain' => 'sampledomain.com'),
            'responsetype' => 'json',
        )
    )
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);

示例請求(本地 API)

$command = 'SendAdminEmail';
$postData = array(
    'messagename' => 'Service Unsuspension Successful',
    'mergefields' => array('client_id' => 1, 'service_id' => 1, 'service_product' => 'This is a product', 'service_domain' => 'sampledomain.com'),
);
$adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later

$results = localAPI($command, $postData, $adminUsername);
print_r($results);

示例響應 JSON

{
    "result": "success"
}

錯誤響應

可能的錯誤條件響應包括:

  • 未找到電子郵件模板

相關用法


注:本文由純淨天空篩選整理自whmcs.com大神的英文原創作品 SendAdminEmail。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。