Outlook mail
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
if (session_id() === "") {
session_start();
}
setlocale(LC_ALL, "nl_NL.UTF-8");
include '../../includes/authorize.php';
include '../resources/database/MysqliDb.php';
$db = new MysqliDb ($server, $user, $password, $database);
include '../../includes/authorize.php';
if (!empty($_POST)) {
sendMails($_POST['changes']);
}
/**
* @param $data array of users with the changes made that affect them
*
* @return array
*/
function sendMails($data)
{
if (isset($_GET['showAs'])) {
$showAs = $_GET['showAs'];
} else {
$showAs = "BUSY";
}
try {
foreach ($data as $user) {
$to = $user['info']['naam'] . " <" . $user['info']['email'] . ">";
if ($user['info']['email'] == $_POST['organizer']['email']) {
$organizer = "Wijzigingsbeheer";
$organizer_email = "[email protected]";
} else {
$organizer = $_POST['organizer']['naam'];
$organizer_email = $_POST['organizer']['email'];
}-
$participant_name = $user['info']['naam'];
$participant_email = $user['info']['email'];
foreach ($user['changes'] as $change) {
$date = date("Ymd", strtotime($change['date']));
if ($change['daypart'] == 0) {
$startTime = '0830';
$endTime = '1230';
} else {
$startTime = '1300';
$endTime = '1700';
}
$subject = $_POST['newTask']['name'];
$desc = 'Veranderingen in het planbord';
$headers = "Content-type: text/calendar; Content-Disposition: inline; charset=utf-8; filename=calendar.ics;";
// $headers .= "Content-Type: text/plain;charset=\"utf-8\"";
$UniqueID = time() + rand(0, 100);
$message =
"BEGIN:VCALENDAR\r\n"
. "PRODID:-//Planbord\r\n"
. "VERSION:2.0\r\n"
. "METHOD:REQUEST\r\n"
. "BEGIN:VEVENT\r\n"
. "DTSTAMP:" . date('Ymd') . 'T' . date('His') . "\r\n"
. "DTSTART:" . $date . "T" . $startTime . "00\r\n"
. "ORGANIZER;CN=" . $organizer . ":mailto:" . $organizer_email . "\r\n"
. "SUMMARY:" . $subject . "\r\n"
. "UID: " . $UniqueID . "\r\n"
. "DTEND:" . $date . "T" . $endTime . "00\r\n"
. "LOCATION: Uw werkplek \r\n"
. "DESCRIPTION:" . $desc . "\r\n"
. "ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=TENTATIVE;CN=" . $participant_name . " :MAILTO:" . $participant_email . "\r\n"
. "X-MICROSOFT-CDO-BUSYSTATUS:" . $showAs . "\r\n"
. "END:VEVENT\r\n"
. "END:VCALENDAR";
$headers .= $message;
mail($to, $subject, $message, $headers);
}
}
} catch (Exception $ex) {
$return['code'] = 500;
$return['message'] = "Er is iets mis gegaan met het versturen van de mails, deze foutmelding kan helpen met het oplossen: " . $ex;
return;
}
$return['code'] = 200;
$return['message'] = "De mails zijn verzonden.";
return;
}
if (session_id() === "") {
session_start();
}
setlocale(LC_ALL, "nl_NL.UTF-8");
include '../../includes/authorize.php';
include '../resources/database/MysqliDb.php';
$db = new MysqliDb ($server, $user, $password, $database);
include '../../includes/authorize.php';
if (!empty($_POST)) {
sendMails($_POST['changes']);
}
/**
* @param $data array of users with the changes made that affect them
*
* @return array
*/
function sendMails($data)
{
if (isset($_GET['showAs'])) {
$showAs = $_GET['showAs'];
} else {
$showAs = "BUSY";
}
try {
foreach ($data as $user) {
$to = $user['info']['naam'] . " <" . $user['info']['email'] . ">";
if ($user['info']['email'] == $_POST['organizer']['email']) {
$organizer = "Wijzigingsbeheer";
$organizer_email = "[email protected]";
} else {
$organizer = $_POST['organizer']['naam'];
$organizer_email = $_POST['organizer']['email'];
}-
$participant_name = $user['info']['naam'];
$participant_email = $user['info']['email'];
foreach ($user['changes'] as $change) {
$date = date("Ymd", strtotime($change['date']));
if ($change['daypart'] == 0) {
$startTime = '0830';
$endTime = '1230';
} else {
$startTime = '1300';
$endTime = '1700';
}
$subject = $_POST['newTask']['name'];
$desc = 'Veranderingen in het planbord';
$headers = "Content-type: text/calendar; Content-Disposition: inline; charset=utf-8; filename=calendar.ics;";
// $headers .= "Content-Type: text/plain;charset=\"utf-8\"";
$UniqueID = time() + rand(0, 100);
$message =
"BEGIN:VCALENDAR\r\n"
. "PRODID:-//Planbord\r\n"
. "VERSION:2.0\r\n"
. "METHOD:REQUEST\r\n"
. "BEGIN:VEVENT\r\n"
. "DTSTAMP:" . date('Ymd') . 'T' . date('His') . "\r\n"
. "DTSTART:" . $date . "T" . $startTime . "00\r\n"
. "ORGANIZER;CN=" . $organizer . ":mailto:" . $organizer_email . "\r\n"
. "SUMMARY:" . $subject . "\r\n"
. "UID: " . $UniqueID . "\r\n"
. "DTEND:" . $date . "T" . $endTime . "00\r\n"
. "LOCATION: Uw werkplek \r\n"
. "DESCRIPTION:" . $desc . "\r\n"
. "ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=TENTATIVE;CN=" . $participant_name . " :MAILTO:" . $participant_email . "\r\n"
. "X-MICROSOFT-CDO-BUSYSTATUS:" . $showAs . "\r\n"
. "END:VEVENT\r\n"
. "END:VCALENDAR";
$headers .= $message;
mail($to, $subject, $message, $headers);
}
}
} catch (Exception $ex) {
$return['code'] = 500;
$return['message'] = "Er is iets mis gegaan met het versturen van de mails, deze foutmelding kan helpen met het oplossen: " . $ex;
return;
}
$return['code'] = 200;
$return['message'] = "De mails zijn verzonden.";
return;
}
Er zijn nog geen reacties op dit bericht.