25 require_once(
"PHPMailer-5.2.6/class.phpmailer.php");
52 if( (defined(
'EMAIL_METHOD')) AND (defined(
'EMAIL_SEND_METHOD')) AND (defined(
'EMAIL_AUTH_ENCRYPTION')) ){
54 if( EMAIL_METHOD ==
'group' ){
55 $this->method =
'group';
57 throw new Exception(
"Fehlkonfiguration des email-moduls! (EMAIL_METHOD)");
60 if( EMAIL_SEND_METHOD ==
'smtp' ){
61 $this->mailer =
'smtp';
63 throw new Exception(
"Fehlkonfiguration des email-moduls! (EMAIL_SEND_METHOD)");
66 if( EMAIL_AUTH_ENCRYPTION ==
'ssl' ){
67 $this->authSecure =
'ssl';
69 throw new Exception(
"Fehlkonfiguration des email-moduls! (EMAIL_AUTH_ENCRYPTION)");
73 throw new Exception(
"Fehlkonfiguration des email-moduls!");
76 if( (!defined(
'EMAIL_SMTP_SERVER'))
77 OR (!defined(
'EMAIL_SMTP_PORT'))
78 OR (!defined(
'EMAIL_SMTP_USERNAME'))
79 OR (!defined(
'EMAIL_ADDRESS'))
80 OR (!defined(
'EMAIL_NAME'))
81 OR (!defined(
'EMAIL_SMTP_PASSWORD')) ){
82 throw new Exception(
"Fehlkonfiguration des email-moduls");
84 if( (EMAIL_SMTP_SERVER ==
'')
85 OR (EMAIL_SMTP_PORT ==
'')
86 OR (EMAIL_SMTP_USERNAME ==
'')
87 OR (EMAIL_ADDRESS ==
'')
89 OR (EMAIL_SMTP_PASSWORD ==
'') ){
90 throw new Exception(
"Fehlkonfiguration des email-moduls");
102 if( (!empty($address)) AND (strpos($address,
"@") !==
false) AND (!empty($name)) ){
103 $this->addressList[] = array($address,$name);
114 $text = strval($text);
115 if( !empty( $text ) ){
116 $this->subject = $text;
129 $text = strval($text);
130 if( !empty( $text ) ){
144 if( class_exists(
"PHPMailer") ){
145 $mail =
new PHPMailer(
true);
147 if( (empty($this->mailer))
148 OR (empty($this->authSecure)) ){
149 throw new Exception(
"Fehlkonfiguration des email-moduls");
151 if( empty($this->addressList) ){
152 throw new Exception(
"Es fehlt die Adressenliste. Email nicht versendet.");
157 $mail->Host = EMAIL_SMTP_SERVER;
158 $mail->SMTPDebug =
false;
161 $mail->SMTPAuth =
true;
162 $mail->Port = EMAIL_SMTP_PORT;
163 $mail->Username = EMAIL_SMTP_USERNAME;
164 $mail->Password = EMAIL_SMTP_PASSWORD;
167 $mail->ContentType =
'text/plain';
168 $mail->IsHTML(
false);
169 foreach( $this->addressList as $add ){
170 if( (is_array($add)) AND (
sizeof($add) >= 2 ) ){
171 $mail->AddAddress($add[0], $add[1]);
174 $mail->SetFrom(EMAIL_ADDRESS, EMAIL_NAME);
175 $mail->AddReplyTo(EMAIL_ADDRESS, EMAIL_NAME);
176 if( !empty($this->subject) ){
179 throw new Exception(
"Keinen Berteff der Email angegeben!");
184 throw new Exception(
"Die Email ist leer!");
189 }
catch (phpmailerException $e) {
190 return $e->errorMessage();
191 }
catch (Exception $e) {
192 return $e->getMessage();
196 throw new Exception(
"PHPMailer nicht gefunden!");
214 if( $this->method ==
'group' ){
215 global $email_groups;
220 global $groups_whitelist;
221 if( !is_array($email_groups) ){
222 throw new Exception(
"Fehlkonfiguration des email-moduls (email_groups)");
224 if( !defined(
'TEACHER_GROUP') ){
225 throw new Exception(
"Lehrer Gruppe in der Konfigurationsdatei nicht angegeben!");
228 $group_mapping =
$au->get_gid_to_name_mapping($groups_whitelist);
231 if( (in_array(
"all",$to)) OR (in_array($t,$to)) ){
232 if( (isset($email_groups[$t])) AND (isset($group_mapping[$t])) ){
233 $this->
addAddress( $email_groups[$t] , $group_mapping[$t]);
240 return "Betreffzeile ist leer. Bitte einen Betreff für die Email eingeben.";
243 return "Es ist kein Text für die Email angegeben. Leere Emails werden nicht verschickt.";
248 }
catch(Exception $e){
249 return $e->getMessage();
270 return "Keinen Betreff angegeben";
275 return "Text ist leer";
280 }
catch(Exception $e){
281 return $e->getMessage();
297 global $groups_whitelist;
298 global $email_groups;
300 $group_mapping =
$au->get_gid_to_name_mapping($groups_whitelist);
302 if( in_array(
"*",$poll->groups) ){
305 foreach( $poll->groups as $gr ){
313 echo
"<tr><td><table style='margin-bottom:1em'>";
315 <td style='font-weight:bold;'>Von:</td>
316 <td style='border-bottom:1px solid #989898'><span style='color:#163E72'>".EMAIL_NAME.
"</span> <".EMAIL_ADDRESS.
"> </td>
319 if( (isset($email_groups[$t])) AND (isset($group_mapping[$t])) AND (in_array($t,$to)) ){
321 <td style='font-weight:bold;'>An:</td>
322 <td style='border-bottom:1px solid #989898'><span style='color:#163E72'>{$group_mapping[$t]}</span> <{$email_groups[$t]}></td>
326 echo
"</table></td></tr>";
328 echo
"<td><span style='font-weight:bold'>Betreff:</span></td>";
331 echo
"<td><input type='text' style='margin-left:2em' size='60' value='$subject' name='email_subject'/></td>";
335 echo
"<td><span style='font-weight:bold'>Text:</span></td>";
338 echo
"<td><textarea cols='70' rows='10' style='margin-left:2em;' name='email_message'>$message</textarea></td>";
352 if( (isset($_POST[
"send_email"])) ){
353 if( (isset($_POST[
"email_subject"]))
356 AND (isset($_POST[
"email_message"])) ){
358 $subject = strip_tags( $_POST[
"email_subject"] );
362 $message = strip_tags( $_POST[
"email_message"] );
367 if( in_array(
"*",$poll->groups) ){
370 foreach( $poll->groups as $gr ){
380 return "Keinen Text eingetragen oder der Betreff der Email ist leer. Bitte dies angeben.";