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:
|
||||
label: Mois
|
||||
type: date
|
||||
display: "mmmm YYYY"
|
||||
display: "MM/YYYY"
|
||||
default: today
|
||||
width: 1/4
|
||||
sendBtn:
|
||||
|
|
|
|||
|
|
@ -9,12 +9,9 @@ return array(
|
|||
'email' => [
|
||||
'transport' => [
|
||||
'type' => 'smtp',
|
||||
'host' => 'smtp.outlook.com',
|
||||
'port' => 587,
|
||||
'security' => 'tls',
|
||||
'auth' => true,
|
||||
'username' => 'adrien.payet@outlook.com',
|
||||
'password' => 't8nVpxCpEZcqH8y'
|
||||
'host' => 'mail.infomaniak.com',
|
||||
'port' => 465,
|
||||
'security' => true
|
||||
]
|
||||
],
|
||||
'routes' => array(
|
||||
|
|
|
|||
|
|
@ -9,14 +9,26 @@ return [
|
|||
|
||||
$kirby = kirby();
|
||||
|
||||
$emailPage = page($data->uri);
|
||||
$content = $emailPage->content()->kt();
|
||||
|
||||
try {
|
||||
$kirby->email([
|
||||
if ($kirby->email([
|
||||
'from' => "info@actuel-inactuel.fr",
|
||||
'to' => 'payet.adrien@protonmail.com',
|
||||
'subject' => 'actualités',
|
||||
'body' => 'Ceci est un test simple.',
|
||||
]);
|
||||
'to' => page("inscription")->toStructure()->pluck("email"),
|
||||
'subject' => $data->subject,
|
||||
'body' => [
|
||||
"html" => $emailPage->content()
|
||||
],
|
||||
])->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) {
|
||||
return json_encode(['status' => 'error', 'message' => $error->getMessage()]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,11 +20,11 @@ const headers = {
|
|||
}),
|
||||
};
|
||||
|
||||
function send(event) {
|
||||
async function send(event) {
|
||||
event.preventDefault();
|
||||
fetch("/send-newsletter.json", headers)
|
||||
.then((res) => res.json())
|
||||
.then((json) => console.log(json));
|
||||
const response = await fetch("/send-newsletter.json", headers);
|
||||
const data = await response.json();
|
||||
console.log(data);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue