Basic implementation event signup
This commit is contained in:
@ -35,45 +35,8 @@ class MailController
|
||||
if (isset($_REQUEST['action'])) {
|
||||
switch ($_REQUEST['action']) {
|
||||
case 'send-email':
|
||||
// SMTP-Konfiguration
|
||||
$smtp_host = 'bdp.mein-verein.online'; // SMTP-Host
|
||||
$smtp_port = 25; // SMTP-Port
|
||||
$smtp_username = 'noreply@mareike.sachsen.pfadfinden.de'; // SMTP-Benutzername
|
||||
$smtp_password = 'fwJ_wxbW9G45'; // SMTP-Passwort
|
||||
$smtp_secure = 'tls'; // Verschlüsselung (tls oder ssl)
|
||||
|
||||
// Einstellungen für wp_mail ändern
|
||||
add_action( 'phpmailer_init', function( $phpmailer ) use ( $smtp_host, $smtp_port, $smtp_username, $smtp_password, $smtp_secure ) {
|
||||
$phpmailer->isSMTP();
|
||||
$phpmailer->Host = $smtp_host;
|
||||
$phpmailer->Port = $smtp_port;
|
||||
$phpmailer->SMTPAuth = true;
|
||||
$phpmailer->Username = $smtp_username;
|
||||
$phpmailer->Password = $smtp_password;
|
||||
$phpmailer->setFrom('info@pfadfinden-halle.de', 'Pfadfinden - Halle');
|
||||
#$phpmailer->SMTPSecure = $smtp_secure;
|
||||
} );
|
||||
|
||||
// Senden Sie die E-Mail
|
||||
$sent = wp_mail($_REQUEST['mail-to'],$_REQUEST['mail-subject'],$_REQUEST['mail-text'],
|
||||
['Reply-To: ' . $_REQUEST['mail-from'], 'Content-Type: text/html; charset=UTF-8']);
|
||||
|
||||
// Überprüfen, ob die E-Mail erfolgreich gesendet wurde
|
||||
if ( $sent ) {
|
||||
echo '<p>E-Mail wurde erfolgreich gesendet!</p>';
|
||||
} else {
|
||||
echo '<p>Fehler beim Senden der E-Mail!</p>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
echo $_REQUEST['mail-to'] . '<br />';
|
||||
echo $_REQUEST['mail-text'];
|
||||
|
||||
echo 'mail gesendet';
|
||||
|
||||
new Sendmail();
|
||||
new MailCompose();
|
||||
break;
|
||||
|
||||
case 'create_group_form':
|
||||
|
72
modules/Mail/Controllers/class-sendmail.php
Normal file
72
modules/Mail/Controllers/class-sendmail.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
namespace Bdp\Modules\Mail\Controllers;
|
||||
|
||||
class Sendmail
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
global $_REQUEST;
|
||||
|
||||
|
||||
$smtp_host = 'bdp.mein-verein.online'; // SMTP-Host
|
||||
$smtp_port = 25; // SMTP-Port
|
||||
$smtp_username = 'noreply@mareike.sachsen.pfadfinden.de'; // SMTP-Benutzername
|
||||
$smtp_password = 'fwJ_wxbW9G45'; // SMTP-Passwort
|
||||
$smtp_secure = 'tls'; // Verschlüsselung (tls oder ssl)
|
||||
|
||||
// Einstellungen für wp_mail ändern
|
||||
add_action( 'phpmailer_init', function( $phpmailer ) use ( $smtp_host, $smtp_port, $smtp_username, $smtp_password, $smtp_secure ) {
|
||||
#$phpmailer->isSMTP();
|
||||
#$phpmailer->Host = $smtp_host;
|
||||
#$phpmailer->Port = $smtp_port;
|
||||
#$phpmailer->SMTPAuth = true;
|
||||
#$phpmailer->Username = $smtp_username;
|
||||
#$phpmailer->Password = $smtp_password;
|
||||
$phpmailer->setFrom('info@pfingstlager-24.de', "KoPfiLa '24 - Die Lagerleitung");
|
||||
#$phpmailer->SMTPSecure = $smtp_secure;
|
||||
} );
|
||||
|
||||
|
||||
$unfiltered_mails = explode(',', str_replace(';', ',', $_REQUEST['mail-to']));
|
||||
$mail_to = array();
|
||||
foreach ($unfiltered_mails as $recipient) {
|
||||
$recipient = trim($recipient);
|
||||
if (!in_array($recipient, $mail_to)) {
|
||||
$mail_to[] = $recipient;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($mail_to as $mail_to_line) {
|
||||
if (str_contains($mail_to_line, '<')) {
|
||||
$pattern = '/^(.*)<(.*)>$/';
|
||||
if (preg_match($pattern, $mail_to_line, $matches)) {
|
||||
$name = trim($matches[1]); // Name
|
||||
$email = trim($matches[2]); // E-Mail-Adresse
|
||||
|
||||
$content = str_replace('[anrede]', 'Hallo ' . $name . ',', $_REQUEST['mail-text']);
|
||||
$content = str_replace('[name]', $name, $content);
|
||||
$content = nl2br($content);
|
||||
$sent = wp_mail($email, $_REQUEST['mail-subject'], $content,
|
||||
['Reply-To: ' . $_REQUEST['mail-from'], 'Content-Type: text/html; charset=UTF-8']);
|
||||
|
||||
// Überprüfen, ob die E-Mail erfolgreich gesendet wurde
|
||||
if ($sent) {
|
||||
kompass_print_message_box(__('Mail sent to', BDP_LV_PLUGIN_SLUG) . ': ' . $email);
|
||||
} else {
|
||||
kompass_print_message_box(__('Mail failed to sent to', BDP_LV_PLUGIN_SLUG) . ': ' . $email, 'error');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$sent = wp_mail($_REQUEST['mail-to'],$_REQUEST['mail-subject'], $_REQUEST['mail-text'],
|
||||
['Reply-To: ' . $_REQUEST['mail-from'], 'Content-Type: text/html; charset=UTF-8']);
|
||||
|
||||
// Überprüfen, ob die E-Mail erfolgreich gesendet wurde
|
||||
if ( $sent ) {
|
||||
kompass_print_message_box(__('Mail sent to', BDP_LV_PLUGIN_SLUG) .': ' . $_REQUEST['mail-to']) ;
|
||||
} else {
|
||||
kompass_print_message_box(__('Mail failed to sent to', BDP_LV_PLUGIN_SLUG) .': ' . $_REQUEST['mail-to'], 'error') ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,32 +1,35 @@
|
||||
<?php
|
||||
|
||||
function kompass_print_mail_compose()
|
||||
function kompass_print_mail_compose(?string $to = null, ?string $subject = null)
|
||||
{
|
||||
global $dbHandler;
|
||||
$current_user = wp_get_current_user();
|
||||
?>
|
||||
|
||||
<form method="post" action="admin.php?page=kompass-mail" style="width: 80%; margin: auto">
|
||||
|
||||
<table style="width: 100%">
|
||||
<input type="hidden" name="action" value="send-email" />
|
||||
<tr>
|
||||
<td><?= __('From: ', BDP_LV_PLUGIN_SLUG); ?></td>
|
||||
<td><input type="text" name="mail-from" style="width: 100%"></td>
|
||||
<td><input type="text" name="mail-from" style="width: 100%" value="<?= $current_user->user_email; ?>"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?= __('To: ', BDP_LV_PLUGIN_SLUG); ?></td>
|
||||
<td><input type="text" name="mail-to" style="width: 100%"></td>
|
||||
<td><input value="<?= $to ?? ''; ?>" type="text" name="mail-to" style="width: 100%"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?= __('Subject: ', BDP_LV_PLUGIN_SLUG); ?></td>
|
||||
<td><input type="text" name="mail-subject" style="width: 100%"></td>
|
||||
<td><input value="<?= $subject ?? ''; ?>" type="text" name="mail-subject" style="width: 100%"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php
|
||||
wp_editor( '', 'gutenberg_content', array(
|
||||
wp_editor( '<h3>[anrede]</h3><br /> <br />', 'mycustomeditor', array(
|
||||
'textarea_name' => 'mail-text',
|
||||
// 'media_buttons' => false, // Deaktivieren der Medien-Upload-Schaltfläche
|
||||
'media_buttons' => false,
|
||||
'tinymce' => ['content_style' => 'html{ background: none !important; }', ]
|
||||
|
||||
) );
|
||||
|
||||
submit_button(__('Send email', BDP_LV_PLUGIN_SLUG));
|
||||
?>
|
||||
</form>
|
||||
|
Reference in New Issue
Block a user