working mail system

database scheme
This commit is contained in:
Johannes Theiner 2021-04-23 09:17:58 +02:00
parent 996d4c50dd
commit cfc154c407
5 changed files with 53 additions and 9 deletions

20
config.ini.php.sample Normal file
View File

@ -0,0 +1,20 @@
;<?php die(); ?>
[database]
db_host = localhost
db_database = alumni
db_user =
db_password =
[mail]
mail_server =
mail_port = 25
mail_user =
mail_address =
mail_password =
[style]
title = Alumni Max Emden
logo_url = https://max-emden.net/iserv/logo/logo.jpg
description = Beschreibender Text
privacy_url = https://max-emden.de/wordpress/impressum

5
create.sql Normal file
View File

@ -0,0 +1,5 @@
create table entries(id bigint auto_increment primary key, name varchar(255), mail varchar(255) unique,
year int(4), birthday date, verify bool, vocation varchar(255)
);
create table verify(id bigint primary key, uuid BINARY(16) ,foreign key verify(id) REFERENCES entries(id));

View File

@ -17,7 +17,7 @@ function returnHeader() {
<!Doctype html> <!Doctype html>
<html lang="de"> <html lang="de">
<head> <head>
<title>Alumni Max Emden</title> <title><?php echo getConfig()["title"] ?></title>
<link rel="stylesheet" href="https://unpkg.com/spectre.css/dist/spectre.min.css"> <link rel="stylesheet" href="https://unpkg.com/spectre.css/dist/spectre.min.css">
<link rel="stylesheet" href="https://unpkg.com/spectre.css/dist/spectre-exp.min.css"> <link rel="stylesheet" href="https://unpkg.com/spectre.css/dist/spectre-exp.min.css">
<link href="https://cdn.datatables.net/1.10.24/css/jquery.dataTables.min.css" rel="stylesheet"> <link href="https://cdn.datatables.net/1.10.24/css/jquery.dataTables.min.css" rel="stylesheet">

View File

@ -17,7 +17,7 @@ $maxDate = date("m-d-Y", strtotime("-10 years"));
<div class="columns"> <div class="columns">
<div class="column col-2"></div> <div class="column col-2"></div>
<div class="column col-8"> <div class="column col-8">
<img class="img-responsive" src="<?php echo $config['logo_url'] ?>" alt="Logo Max-Windmüller Gymnasium"/> <img class="img-responsive" src="<?php echo $config['logo_url'] ?>" alt="Logo der Schule"/>
</div> </div>
<div class="column col-2"></div> <div class="column col-2"></div>
</div> </div>
@ -56,13 +56,12 @@ $maxDate = date("m-d-Y", strtotime("-10 years"));
<div class="form-group"> <div class="form-group">
<label class="form-label" for="vocation">Tätigkeit</label> <label class="form-label" for="vocation">Tätigkeit</label>
<textarea name="vocation" id="vocation" required="required" class="form-input"> <textarea name="vocation" id="vocation" required="required" class="form-input"></textarea>
</textarea>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="form-checkbox"> <label class="form-checkbox">
<input type="checkbox"> <input type="checkbox" id="privacy" name="privacy" required="required">
<i class="form-icon"></i>Ich akzeptiere hiermit<a <i class="form-icon"></i>Ich akzeptiere hiermit<a
href="<?php echo $config['privacy_url'] ?>" target="_blank" href="<?php echo $config['privacy_url'] ?>" target="_blank"
class="font-semibold text-black border-b-2 border-gray-200 hover:border-gray-500"> class="font-semibold text-black border-b-2 border-gray-200 hover:border-gray-500">

View File

@ -1,15 +1,31 @@
<?php <?php
//if ($_SERVER['REQUEST_METHOD'] != "POST") { if ($_SERVER['REQUEST_METHOD'] != "POST") {
// die(); die();
//} }
require_once 'general.php';
require_once 'vendor/autoload.php';
use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\PHPMailer;
$name = $_POST['name'];
$mail = $_POST['mail'];
$year = $_POST['year'];
$birthday = $_POST['birthday'];
$vocation = $_POST['vocation'];
$privacy = $_POST['privacy'];
//validate here
$config = getConfig(); $config = getConfig();
$mail = new PHPMailer(true); $mail = new PHPMailer(true);
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->Host = $config['mail_server']; $mail->Host = $config['mail_server'];
$mail->Port = $config['mail_port']; $mail->Port = $config['mail_port'];
$mail->Username = $config['mail_user']; $mail->Username = $config['mail_user'];
@ -17,9 +33,13 @@ $mail->Password = $config['mail_password'];
$mail->From = $config['mail_address']; $mail->From = $config['mail_address'];
$mail->FromName = 'Mailer'; $mail->FromName = 'Mailer';
$mail->addAddress('test@joethei.de', 'Joe User'); try {
$mail->addAddress('test@joethei.de', 'Joe User');
} catch (\PHPMailer\PHPMailer\Exception $e) {
}
$mail->Subject = 'Here is the subject'; $mail->Subject = 'Here is the subject';
$mail->AltBody = 'Message without html';
$mail->Body = 'This is the HTML message body <b>in bold!</b>'; $mail->Body = 'This is the HTML message body <b>in bold!</b>';