newsletter config try
This commit is contained in:
parent
7e5872aad1
commit
49d48015a8
4 changed files with 29 additions and 20 deletions
|
|
@ -8,15 +8,12 @@ return array(
|
|||
),
|
||||
'email' => [
|
||||
'transport' => [
|
||||
'type' => 'smtp',
|
||||
'host' => 'smtp.outlook.com',
|
||||
'port' => 587,
|
||||
'security' => 'tls',
|
||||
'auth' => true,
|
||||
'username' => 'adrien.payet@outlook.com',
|
||||
'password' => 't8nVpxCpEZcqH8y'
|
||||
'type' => 'smtp',
|
||||
'host' => 'mail.infomaniak.com',
|
||||
'port' => 465,
|
||||
'security' => true
|
||||
]
|
||||
],
|
||||
],
|
||||
'routes' => array(
|
||||
require __DIR__ . '/routes/virtual-category.php',
|
||||
require __DIR__ . '/routes/send-newsletter.php',
|
||||
|
|
|
|||
|
|
@ -8,15 +8,27 @@ return [
|
|||
$request = json_decode($jsonRequest);
|
||||
|
||||
$kirby = kirby();
|
||||
|
||||
$emailPage = page($data->uri);
|
||||
$content = $emailPage->content()->kt();
|
||||
|
||||
try {
|
||||
$kirby->email([
|
||||
'from' => "info@actuel-inactuel.fr",
|
||||
'to' => 'payet.adrien@protonmail.com',
|
||||
'subject' => 'actualités',
|
||||
'body' => 'Ceci est un test simple.',
|
||||
]);
|
||||
return json_encode(['status' => 'success', 'message' => 'Email envoyé avec succès.']);
|
||||
if ($kirby->email([
|
||||
'from' => "info@actuel-inactuel.fr",
|
||||
'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()]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue