Implement placeholders
This commit is contained in:
parent
e456bedc68
commit
4d1c18c542
File diff suppressed because one or more lines are too long
|
@ -44,6 +44,17 @@ paths:
|
||||||
description: "Error message, only included if an error has occurred"
|
description: "Error message, only included if an error has occurred"
|
||||||
required: false
|
required: false
|
||||||
definitions:
|
definitions:
|
||||||
|
Placeholder:
|
||||||
|
type: "object"
|
||||||
|
properties:
|
||||||
|
name:
|
||||||
|
type: "string"
|
||||||
|
required: true
|
||||||
|
description: "Name of the placeholder - will be converted to ALL CAPS by the server if it isn't already"
|
||||||
|
value:
|
||||||
|
type: "string"
|
||||||
|
required: false
|
||||||
|
description: "Value to insert into placeholder"
|
||||||
Attachment:
|
Attachment:
|
||||||
type: "object"
|
type: "object"
|
||||||
properties:
|
properties:
|
||||||
|
@ -107,6 +118,11 @@ definitions:
|
||||||
description: "Array of `Attachment` objects to be attached to the email"
|
description: "Array of `Attachment` objects to be attached to the email"
|
||||||
items:
|
items:
|
||||||
$ref: "#/definitions/Attachment"
|
$ref: "#/definitions/Attachment"
|
||||||
|
placeholders:
|
||||||
|
type: "array"
|
||||||
|
description: "Array of `Placeholder` objects. Any occurrences of `{PLACEHOLDER_NAME}` (`name` in all caps enclosed with curly brackets) in the email's HTML or plain text will be replaced by `value`."
|
||||||
|
items:
|
||||||
|
$ref: "#/definitions/Placeholder"
|
||||||
key:
|
key:
|
||||||
type: "string"
|
type: "string"
|
||||||
description: "API key to authenticate request with"
|
description: "API key to authenticate request with"
|
||||||
|
|
|
@ -22,6 +22,11 @@ try {
|
||||||
$html = ($json["html"] ? $json["html"] : ($json["htmlurl"] ? file_get_contents($json["htmlurl"]) : null));
|
$html = ($json["html"] ? $json["html"] : ($json["htmlurl"] ? file_get_contents($json["htmlurl"]) : null));
|
||||||
$text = ($json["text"] ? $json["text"] : ($json["texturl"] ? file_get_contents($json["texturl"]) : null));
|
$text = ($json["text"] ? $json["text"] : ($json["texturl"] ? file_get_contents($json["texturl"]) : null));
|
||||||
|
|
||||||
|
foreach ($json["placeholders"] as $placeholder) {
|
||||||
|
$html = str_replace("{".strtoupper($placeholder["name"])."}", $placeholder["value"], $html);
|
||||||
|
$text = str_replace("{".strtoupper($placeholder["name"])."}", $placeholder["value"], $text);
|
||||||
|
}
|
||||||
|
|
||||||
$mailer->isSMTP();
|
$mailer->isSMTP();
|
||||||
$mailer->Host = $MAIL_HOST;
|
$mailer->Host = $MAIL_HOST;
|
||||||
$mailer->SMTPAuth = (bool) $MAIL_USER;
|
$mailer->SMTPAuth = (bool) $MAIL_USER;
|
||||||
|
|
Loading…
Reference in a new issue