Update mailgun.api.php
This commit is contained in:
parent
08d6246fba
commit
dfa190a9df
|
@ -7,8 +7,40 @@
|
||||||
* @documentation https://documentation.mailgun.com/en/latest/api-sending.html
|
* @documentation https://documentation.mailgun.com/en/latest/api-sending.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if(!check_function_exists("mailgun_send_message")) {
|
if(!check_function_exists("mailgun_get_config")) {
|
||||||
function mailgun_send_message() {
|
function mailgun_get_config() {
|
||||||
// todo
|
$config = get_config();
|
||||||
|
|
||||||
|
return array(
|
||||||
|
"domain" => get_value_in_array("mailgun_domain", $config, ""),
|
||||||
|
"name" => get_value_in_array("mailgun_name", $config, "John Doe"),
|
||||||
|
"address" => get_value_in_array("mailgun_address", $config, ""),
|
||||||
|
"apikey" => get_value_in_array("mailgun_apikey", $config, ""),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!check_function_exists("mailgun_send_message")) {
|
||||||
|
function mailgun_send_message($to, $subject, $content) {
|
||||||
|
$response = false;
|
||||||
|
|
||||||
|
$app_config = mailgun_get_config();
|
||||||
|
|
||||||
|
if(loadHelper("webpagetool")) {
|
||||||
|
$response = get_web_json(sprintf("https://api.mailgun.net/v3/%s/messages", $domain), array(
|
||||||
|
"headers" => array(
|
||||||
|
"Content-Type" => "multipart/form-data",
|
||||||
|
"Authentication" => array("Basic", "api", $app_config['apikey']),
|
||||||
|
),
|
||||||
|
"data" => array(
|
||||||
|
"from" => sprintf("%s <%s>", $app_config['name'], $app_config['address']),
|
||||||
|
"to" => $to,
|
||||||
|
"subject" => $subject,
|
||||||
|
"text" => $content,
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user