added notification emails for newsletter confirmation and unsubscription
This commit is contained in:
parent
64345dbcd0
commit
74be45851e
@ -1,49 +1,48 @@
|
||||
---
|
||||
title: Nachricht versandt
|
||||
title: Kleines Dankeschön
|
||||
date: 2025-02-04 10:20
|
||||
author: Tobias Radloff
|
||||
summary: Danke für deine Nachricht.
|
||||
lang: de
|
||||
slug: danke
|
||||
save_as: kontakt/danke/index.html
|
||||
url: kontakt/danke/
|
||||
save_as: newsletter/danke.html
|
||||
---
|
||||
|
||||
Danke für deine Nachricht. Ich antworte bestimmt bald. Und bis es soweit ist, kannst du dich an diesem Gedicht von mir erfreuen :-)
|
||||
Klasse, dass du dich für meinen Newsletter angemeldet hast. Als kleines Dankeschön und um die Wartezeit auf die nächste Ausgabe zu verkürzen, ist hier ein bislang unveröffentlichtes Gedicht von mir. Viel Spaß :-)
|
||||
|
||||
## Handwerk
|
||||
|
||||
Dichter, Autor, Mann der Worte
|
||||
so werd ich genannt
|
||||
doch nicht nur mein Geist ist fleißig,
|
||||
nein, auch meine Hand.
|
||||
|
||||
Vor Schmutz unter den Fingernägeln
|
||||
schreck ich nicht zurück
|
||||
ein echter Mann wie ich, der hat
|
||||
handwerkliches Geschick.
|
||||
|
||||
Ich freu mich, wenn es gilt, ein Löch-
|
||||
lein in die Wand zu bohr'n
|
||||
denn jedes Mal treff ich mit Verve
|
||||
genau ins Wasserrohr.
|
||||
|
||||
Die Muttern an den Autorädern
|
||||
zieh ich selber nach
|
||||
klemm' mir dabei den Ischias
|
||||
und lieg' drei Wochen flach.
|
||||
|
||||
Ich bau IKEA-Möbel auf
|
||||
die Schwerkraft baut sie ab
|
||||
beim Umzug helf ich freudig mit
|
||||
und mach als erster schlapp.
|
||||
|
||||
Die Waschmaschine ist kaputt?
|
||||
Ich kümmere mich drum
|
||||
wofür, wenn nicht für Wasserschäden,
|
||||
gibt's Versicherung'n?
|
||||
|
||||
Doch neuerdings werd ich nicht mehr
|
||||
gefragt in Handwerksfragen
|
||||
So bleibt mir nur ein Handwerk noch:
|
||||
Gedichte aufzusagen.
|
||||
> ## Handwerk
|
||||
>
|
||||
> Dichter, Autor, Mann der Worte
|
||||
> so werd ich genannt
|
||||
> doch nicht nur mein Geist ist fleißig,
|
||||
> nein, auch meine Hand.
|
||||
>
|
||||
> Vor Schmutz unter den Fingernägeln
|
||||
> schreck ich nicht zurück
|
||||
> ein echter Mann wie ich, der hat
|
||||
> handwerkliches Geschick.
|
||||
>
|
||||
> Ich freu mich, wenn es gilt, ein Löch-
|
||||
> lein in die Wand zu bohr'n
|
||||
> denn jedes Mal treff ich mit Verve
|
||||
> genau ins Wasserrohr.
|
||||
>
|
||||
> Die Muttern an den Autorädern
|
||||
> zieh ich selber nach
|
||||
> klemm' mir dabei den Ischias
|
||||
> und lieg' drei Wochen flach.
|
||||
>
|
||||
> Ich bau IKEA-Möbel auf
|
||||
> die Schwerkraft baut sie ab
|
||||
> beim Umzug helf ich freudig mit
|
||||
> und mach als erster schlapp.
|
||||
>
|
||||
> Die Waschmaschine ist kaputt?
|
||||
> Ich kümmere mich drum
|
||||
> wofür, wenn nicht für Wasserschäden,
|
||||
> gibt's Versicherung'n?
|
||||
>
|
||||
> Doch neuerdings werd ich nicht mehr
|
||||
> gefragt in Handwerksfragen
|
||||
> So bleibt mir nur ein Handwerk noch:
|
||||
> Gedichte aufzusagen.
|
||||
@ -1,8 +1,8 @@
|
||||
---
|
||||
title: "Das lief richtig gut :-)"
|
||||
title: "Das hat geklappt"
|
||||
date: 2025-03-04 23:19
|
||||
author: Tobias Radloff
|
||||
summary: Erfolg auf der ganzen Linie
|
||||
summary: Ein Arbeitsschritt wurde erfolgreich bewältigt.
|
||||
lang: de
|
||||
slug: success
|
||||
save_as: success.html
|
||||
@ -12,8 +12,6 @@ featured_image:
|
||||
credit: Ian Stauffer on Unsplash.com
|
||||
---
|
||||
|
||||
Na, das lief doch mal richtig gut. Erfolg auf der ganzen Linie, würde ich sagen. So soll es sein, und so bleibt es hoffentlich auch.
|
||||
|
||||
<script src="{static}/js/Message.js"></script>
|
||||
|
||||
[← zur Startseite](/)
|
||||
|
||||
@ -3,10 +3,17 @@
|
||||
|
||||
require(dirname(__FILE__) . '/../settings.php');
|
||||
|
||||
$successURL = '/confirmed.html';
|
||||
$successURL = '/newsletter/danke.html';
|
||||
$errorURL = '/error.html';
|
||||
$err = 'Bestätigung fehlgeschlagen';
|
||||
|
||||
// contents of notification email
|
||||
$mailContents = [
|
||||
'subject' => 'Neuer Newsletter-Abonnent',
|
||||
'bodyText' => "Jemand hat seine Emailadresse für den Empfang des Newsletters bestätigt:\n\n%Placeholder%",
|
||||
'fromAddress' => '***REMOVED***', // 'newsletter@tobias-radloff.de'
|
||||
'fromName' => 'Tobias Radloff'
|
||||
];
|
||||
|
||||
// Adds new subscriber to database. Returns an error message on failure, TRUE on success.
|
||||
function AddSubscriberToDB($subscriberAddress, $subscriberName = NULL) {
|
||||
@ -22,7 +29,6 @@ function AddSubscriberToDB($subscriberAddress, $subscriberName = NULL) {
|
||||
global $general;
|
||||
$query = $pdo->prepare($general['sql']['create_record']);
|
||||
if ( ( ! $query->execute([':e' => $subscriberAddress, ':n' => $subscriberName]) ) or ( $query->fetch() ) ) {
|
||||
// error_log("Datenbankfehler: Einfügen von Emailadresse {$subscriberAddress} ergab einen Fehler.");
|
||||
return 'Fehler beim Eintragen in die Datenbank';
|
||||
}
|
||||
return TRUE;
|
||||
@ -52,5 +58,7 @@ try {
|
||||
}
|
||||
|
||||
// success
|
||||
GracefulExit($successURL, 'Bestätigung erfolgt: Newsletter-Anmeldung bestätigt');
|
||||
$mailContents['bodyText'] = str_replace('%Placeholder%', $e, $mailContents['bodyText']);
|
||||
SendEmail($general['notificationAddress'], $mailContents);
|
||||
GracefulExit($successURL);
|
||||
?>
|
||||
@ -27,7 +27,7 @@ $mailContents = [
|
||||
];
|
||||
|
||||
try {
|
||||
sendEmail($_POST['email'], $mailContents);
|
||||
SendEmail($_POST['email'], $mailContents);
|
||||
} catch (Exception $e) {
|
||||
GracefulExit($errorURL, "{$err}: {$e->getMessage()}");
|
||||
}
|
||||
|
||||
@ -27,7 +27,8 @@ $general = [
|
||||
'read_record' => 'SELECT 1 FROM subscribers WHERE email = :e;',
|
||||
'update_record' => '',
|
||||
'delete_record' => 'DELETE FROM subscribers WHERE email = :e;'
|
||||
]
|
||||
],
|
||||
'notificationAddress' => 'webseite@tobias-radloff.de'
|
||||
];
|
||||
// complete site URL
|
||||
$general['siteURL'] = 'https://' . $general['domain'];
|
||||
|
||||
@ -8,7 +8,7 @@ $errorURL = '/error.html';
|
||||
$err = 'Anmeldung fehlgeschlagen';
|
||||
|
||||
// body template for confirmation email
|
||||
$bodyConfirmation = [
|
||||
$body = [
|
||||
'Hallo!',
|
||||
'Bitte bestätige die Anmeldung für meinen Newsletter, indem du auf den folgenden Link klickst:',
|
||||
'%Placeholder%',
|
||||
@ -16,10 +16,10 @@ $bodyConfirmation = [
|
||||
];
|
||||
|
||||
// contents of confirmation email
|
||||
$mailConfirmation = [
|
||||
$mailContents = [
|
||||
'subject' => 'Newsletter-Anmeldung bestaetigen',
|
||||
'bodyHTML' => '<p>' . implode('</p><p>', $bodyConfirmation) . '</p>',
|
||||
'bodyText' => implode("\n\n", $bodyConfirmation),
|
||||
'bodyHTML' => '<p>' . implode('</p><p>', $body) . '</p>',
|
||||
'bodyText' => implode("\n\n", $body),
|
||||
'fromAddress' => '***REMOVED***', // 'newsletter@tobias-radloff.de'
|
||||
'fromName' => 'Tobias Radloffs Newsletter'
|
||||
];
|
||||
@ -48,12 +48,12 @@ try {
|
||||
// build and add link to
|
||||
$confirmQuery = http_build_query(['c' => GetConfirmationHash($email), 'e' => $email]);
|
||||
$confirmLink = $general['siteURL'] . $general['confirmScript'] . "?" . $confirmQuery;
|
||||
$mailConfirmation['bodyHTML'] = str_replace('%Placeholder%', $confirmLink, $mailConfirmation['bodyHTML']);
|
||||
$mailConfirmation['bodyText'] = str_replace('%Placeholder%', $confirmLink, $mailConfirmation['bodyText']);
|
||||
$mailContents['bodyHTML'] = str_replace('%Placeholder%', $confirmLink, $mailContents['bodyHTML']);
|
||||
$mailContents['bodyText'] = str_replace('%Placeholder%', $confirmLink, $mailContents['bodyText']);
|
||||
|
||||
// send email
|
||||
try {
|
||||
SendEmail($email, $mailConfirmation);
|
||||
SendEmail($email, $mailContents);
|
||||
} catch (Exception $e) {
|
||||
GracefulExit($errorURL, "{$err}: {$e->getMessage()}");
|
||||
}
|
||||
|
||||
@ -6,6 +6,15 @@ $successURL = '/success.html';
|
||||
$errorURL = '/error.html';
|
||||
$err = "Abmeldung fehlgeschlagen";
|
||||
|
||||
// contents of notification email
|
||||
$mailContents = [
|
||||
'subject' => 'Ein Newsletter-Abonnent weniger',
|
||||
'bodyText' => "Jemand hat sich vom Newsletter abgemeldet:\n\n%Placeholder%",
|
||||
'fromAddress' => '***REMOVED***', // 'newsletter@tobias-radloff.de'
|
||||
'fromName' => 'Tobias Radloff'
|
||||
];
|
||||
|
||||
|
||||
function RemoveSubscriberFromDB($subscriberAddress) {
|
||||
$pdo = getPDO();
|
||||
|
||||
@ -49,5 +58,7 @@ try {
|
||||
}
|
||||
|
||||
// success
|
||||
$mailContents['bodyText'] = str_replace('%Placeholder%', $e, $mailContents['bodyText']);
|
||||
SendEmail($general['notificationAddress'], $mailContents);
|
||||
GracefulExit($successURL, 'Abmeldung erfolgt: Emailadresse ist aus dem Newsletter ausgetragen');
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user