query('SELECT count(*) FROM proben WHERE date(STR_TO_DATE(termin, "%d.%m.%Y")) > (SELECT CURDATE() ) ORDER BY date(STR_TO_DATE(termin, "%d.%m.%Y"));'); $count_proben = $res->fetch(PDO::FETCH_NUM)[0]; } catch(Exception $e) { $error_msg = $e->getMessage(); } } if ( $error_msg != "" ) { // Fehlerbehandlung // schickt mir ne E-Mail mit der Fehlermeldung $pheanstalk = new Pheanstalk('192.168.122.1'); $data = array( 'To' => array('status@iamfabulous.de'), 'Name' => 'Fehler | Gospelchor Adlershof', 'From' => 'noreply@gospeladlershof.de', 'ReplyTo' => 'status@iamfabulous.de', 'Subject' => 'Gospelchor Adlershof | Error', 'HTMLMessage' => null, 'TextMessage' => $error_msg, ); $pheanstalk ->useTube('contactme_mail') ->put(json_encode($data)); } else { if ( $count_proben <= 4 ) { // email schicken, da wenige proben in der datenbank vorhanden sind $text_msg = 'Hi Lotte, es sind nur noch ' . $count_proben . ' Proben eingetragen. Viele Grüße Max'; $pheanstalk = new Pheanstalk('192.168.122.1'); $data = array( 'To' => array('chorleiter@gospeladlershof.de'), //'To' => array('chorleiter@gospeladlershof.de', 'webmaster@gospeladlershof.de'), //'To' => array('status@iamfabulous.de', 'webmaster@gospeladlershof.de'), 'Name' => 'Gospelchor Adlershof', 'From' => 'noreply@gospeladlershof.de', 'ReplyTo' => 'webmaster@gospeladlershof.de', 'Subject' => '[Chor-Admin] Wenige Proben', 'HTMLMessage' => null, 'TextMessage' => $text_msg, ); $pheanstalk ->useTube('contactme_mail') ->put(json_encode($data)); } }