newsletter config try
This commit is contained in:
parent
7e5872aad1
commit
49d48015a8
4 changed files with 29 additions and 20 deletions
|
|
@ -15,7 +15,7 @@ tabs:
|
||||||
month:
|
month:
|
||||||
label: Mois
|
label: Mois
|
||||||
type: date
|
type: date
|
||||||
display: "mmmm YYYY"
|
display: "MM/YYYY"
|
||||||
default: today
|
default: today
|
||||||
width: 1/4
|
width: 1/4
|
||||||
sendBtn:
|
sendBtn:
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,12 @@ return array(
|
||||||
),
|
),
|
||||||
'email' => [
|
'email' => [
|
||||||
'transport' => [
|
'transport' => [
|
||||||
'type' => 'smtp',
|
'type' => 'smtp',
|
||||||
'host' => 'smtp.outlook.com',
|
'host' => 'mail.infomaniak.com',
|
||||||
'port' => 587,
|
'port' => 465,
|
||||||
'security' => 'tls',
|
'security' => true
|
||||||
'auth' => true,
|
|
||||||
'username' => 'adrien.payet@outlook.com',
|
|
||||||
'password' => 't8nVpxCpEZcqH8y'
|
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'routes' => array(
|
'routes' => array(
|
||||||
require __DIR__ . '/routes/virtual-category.php',
|
require __DIR__ . '/routes/virtual-category.php',
|
||||||
require __DIR__ . '/routes/send-newsletter.php',
|
require __DIR__ . '/routes/send-newsletter.php',
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,27 @@ return [
|
||||||
$request = json_decode($jsonRequest);
|
$request = json_decode($jsonRequest);
|
||||||
|
|
||||||
$kirby = kirby();
|
$kirby = kirby();
|
||||||
|
|
||||||
|
$emailPage = page($data->uri);
|
||||||
|
$content = $emailPage->content()->kt();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$kirby->email([
|
if ($kirby->email([
|
||||||
'from' => "info@actuel-inactuel.fr",
|
'from' => "info@actuel-inactuel.fr",
|
||||||
'to' => 'payet.adrien@protonmail.com',
|
'to' => page("inscription")->toStructure()->pluck("email"),
|
||||||
'subject' => 'actualités',
|
'subject' => $data->subject,
|
||||||
'body' => 'Ceci est un test simple.',
|
'body' => [
|
||||||
]);
|
"html" => $emailPage->content()
|
||||||
return json_encode(['status' => 'success', 'message' => 'Email envoyé avec succès.']);
|
],
|
||||||
|
])->isSent()) {
|
||||||
|
return json_encode(['status' => 'success', 'message' => 'Email envoyé avec succès.']);
|
||||||
|
} else {
|
||||||
|
return json_encode([
|
||||||
|
"status" => "error",
|
||||||
|
"message" => "Erreur lors de l'envoi de l'email.",
|
||||||
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
} catch (Exception $error) {
|
} catch (Exception $error) {
|
||||||
return json_encode(['status' => 'error', 'message' => $error->getMessage()]);
|
return json_encode(['status' => 'error', 'message' => $error->getMessage()]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,11 @@ const headers = {
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
function send(event) {
|
async function send(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
fetch("/send-newsletter.json", headers)
|
const response = await fetch("/send-newsletter.json", headers);
|
||||||
.then((res) => res.json())
|
const data = await response.json();
|
||||||
.then((json) => console.log(json));
|
console.log(data);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue