. */ if( strlen($rmail->get_from())==0 ) { // You cannot call this file directly dolog("mailreturn", "You cannot call ...._error.php directly", "error"); exit; } // We first check for the delivery report (message/delivery-status) and the // original message (message/rfc822[-headers]) to understand the error mail $message=$rmail->get_message(); for($i=0; $iget_subject()) AND $rmail->get_from()=="Mail Delivery System " ) { // Delay from Karlsruhe mail proxy // do not handle }else { error_webmaster($error, "Unknown mail received: ".$Mail_content); dolog("mailreturn", "Unknown mail received", "error"); } } }else { // Signature failed dolog("mailerror", "Invalid signature. Content: ".$Mail_content."; ".(isset($Mail_applID)?("applID: ".$Mail_applID):("BodyCode: ".$Mail_BodyCode))."; error: ".$error."; subject: ".$rmail->get_subject()); } } function error_abc($Mail_applID, $error, $Mail_BodyCode="") { // Message to a body has failed, inform ABC about the problem global $rmail, $setup; if( $error=="permanent" ) { if( $Mail_applID>0 OR $Mail_BodyCode!="" ) { if( $Mail_applID>0 ) { $query="SELECT `ab_bodies`.`BodyName`, `ab_bodies`.`Email` AS `Email` FROM `ab_bodies`, `persons` WHERE `ab_bodies`.`BodyCode`=`persons`.`BodyCode` AND `persons`.`PersonID`=".addslashes($Mail_applID); }else { $query="SELECT `BodyName`, `Email` FROM `ab_bodies` WHERE `BodyCode`='".addslashes($Mail_BodyCode)."'"; } if( @mysql_num_rows( $res=doquery($query) )==1 ) { $row=mysql_fetch_array($res); $boundary = $rmail->new_boundary(); $header ="From: \"Webmaster ".$setup['SetupEventType']." Application\" <".$setup['WebmasterEmail'].">\n"; $header.="Content-Type: multipart/mixed; boundary=\"".$boundary."\"\n"; $out ="This is a MIME-encapsulated message\n"; $out.="\n--".$boundary."\n\n"; $out.="Dear ABC,\n\n"; $out.="It seems the e-mail address of the body ".$row['BodyName']." (".$row['Email'].")\n"; $out.="is not working. Can you please try to get the right e-mail address in the Address\n"; $out.="Book?\n\n"; $out.="This message has been automatically generated by the ".$setup['SetupEventType']." Application Mailer.\n"; $out.="For every error message I receive, I'll send you a notice. I do not check if you already\n"; $out.="received such a notice. Instead of complaining about this, better try to fix the problem\n"; $out.="as soon as possible.\n\n"; $out.="For questions you can contact the webmaster: ".$setup['WebmasterEmail']."\n\n"; $out.="In the attachment you can find the message on which I based this conclusion.\n\n"; $out.="Greetings from the friendly webmaster.\n"; $out.="\n--".$boundary."\n"; $out.="Content-Type: message/rfc822\n\n"; $out.=$rmail->get_fullmessage()."\n"; $out.="--".$boundary."--\n"; $header.="X-Content: error to abc"; $header.="\nX-ApplicationID: 0"; $header.="\nX-Signature: ".substr(md5("secret".$setup['EventCode']."error to abc"."0"), 0, 24); send_mail($setup['MailABC'], "Error in body e-mail", $out, $header, false, false); dolog("mailreturn", "E-mail address of ".$row['BodyName']." (".$row['Email'].") is incorrect. Informed ABC.", "info"); }else { dolog("mailreturn", "E-mail came back from a body, but I do not know the ID (".$Mail_applID.")", "warning"); } }else { dolog("mailreturn", "E-mail came back from a body, but there was no ID", "warning"); } }elseif( $error=="unknown" ) { // Unknown error in mail to body, forward to webmaster global $Error_action, $Error_diagcode, $Error_status; $boundary = $rmail->new_boundary(); $header ="From: \"Webmaster ".$setup['SetupEventType']." Application\" <".$setup['WebmasterEmail'].">\n"; $header.="Content-Type: multipart/mixed; boundary=\"".$boundary."\"\n"; $out ="This is a MIME-encapsulated message\n"; $out.="\n--".$boundary."\n\n"; $out.="Dear Webmaster,\n\n"; $out.="I was not able to interpret the error that was in the attached e-mail that was\n"; $out.="supposed to reach a body. Please take care of this error.\n\n"; $out.="\tSMTP Action: ".$Error_action."\n"; $out.="\tSMTP Diagnostic-Code: ".$Error_diagcode."\n"; $out.="\tSMTP Status: ".$Error_status."\n\n"; $out.="Greetings from the friendly webmaster.\n"; $out.="\n--".$boundary."\n"; $out.="Content-Type: message/rfc822\n\n"; $out.=$rmail->get_fullmessage()."\n"; $out.="--".$boundary."--\n"; $header.="X-Content: error to webmaster"; $header.="\nX-ApplicationID: 0"; $header.="\nX-Signature: ".substr(md5("secret".$setup['EventCode']."error to webmaster"."0"), 0, 24); send_mail($setup['WebmasterEmail'], "Error in body e-mail", $out, $header, false, false); dolog("mailreturn", "Mail to body failed with unknown error, forwarded mail to webmaster.", "warning"); }else { dolog("mailreturn", "E-mail came back from body, but we don't have to handle it (problem type: ".$error.")", "info"); } } function error_chair($error, $content) { global $rmail, $setup; $message=$rmail->get_message(); if( $error!="delayed" ) { $boundary = $rmail->new_boundary(); $header ="From: \"Webmaster ".$setup['SetupEventType']." Application\" <".$setup['WebmasterEmail'].">\n"; $header.="Content-Type: multipart/mixed; boundary=\"".$boundary."\"\n"; $out ="This is a MIME-encapsulated message\n"; $out.="\n--".$boundary."\n\n"; $out.="Dear Chair team,\n\n"; $out.="A message with the content\n\n"; $out.=" ".$content."\n\n"; $out.="was not delivered and came back with ".$error." error.\n\n"; $out.="The involved message is in the attachment. Please take care of this error.\n\n"; $out.="Greetings from the friendly webmaster.\n"; $out.="\n--".$boundary."\n"; for($i=0; $iget_fullmessage()."\n"; $out.="--".$boundary."--\n"; $header.="X-Content: error to chair"; $header.="\nX-ApplicationID: 0"; $header.="\nX-Signature: ".substr(md5("secret".$setup['EventCode']."error to chair"."0"), 0, 24); send_mail($setup['MailChair'], "Error in mail", $out, $header, false, false); dolog("mailreturn", "Mail returned with ".$error." error. Content: ".$content, "warning"); } } function error_jc($Mail_applID, $error, $content) { // Message to candidate failed, inform JC, and remove the e-mail address global $rmail, $setup; $message=$rmail->get_message(); if( $error!="delayed" ) { if( $Mail_applID>0 ) { $query="SELECT `FirstName`, `LastName`, `BodyCode`, `Email` FROM `candidates` WHERE `id`=".addslashes($Mail_applID); if( @mysql_num_rows( $res=doquery($query) )==1 ) { $row=mysql_fetch_array($res); $boundary = $rmail->new_boundary(); $header ="From: \"Webmaster ".$setup['SetupEventType']." Application\" <".$setup['WebmasterEmail'].">\n"; $header.="Content-Type: multipart/mixed; boundary=\"".$boundary."\"\n"; $out ="This is a MIME-encapsulated message\n"; $out.="\n--".$boundary."\n\n"; $out.="Dear JC,\n\n"; $out.="It seems the e-mail address of ".$row['FirstName']." ".$row['LastName']."\n"; $out.="(".$row['BodyCode']."; ".$row['Email'].") is not working properly.\n\n"; $out.="An e-mail that was send with as content\n\n"; $out.=" ".$content."\n\n"; $query=""; switch( $error ) { case "temporaly": $out.="did not arrive in the candidates mailbox. It was a temporaly error, so\n"; $out.="no action from your side is needed. If you think it is important the\n"; $out.="candidate receives the message, you could resend it. You can find the\n"; $out.="message in the attachment.\n\n"; break; case "permanent": $out.="did not arrive in the candidates mailbox. It was a permanent error, which\n"; $out.="means the e-mail address is invalid. Can you please try to get the right\n"; $out.="e-mail address in the candidature? I'll now remove the e-mail from the\n"; $out.="candidature to prevent future error messages.\n\n"; $query="UPDATE `candidates` SET `Email`='' WHERE `id`=".addslashes($Mail_applID); break; case "unknown": $out.="did not arrive in the candidates mailbox. It was an unknown error, so\n"; $out.="I have no clue what to do. Please check the attachment and try to figure\n"; $out.="out the problem yourself. If you think it is important the candidate\n"; $out.="receives the message, you could resend it. You can find the message in\n"; $out.="the attachment.\n\n"; break; } $out.="This message has been automatically generated by the ".$setup['SetupEventType']." Application Mailer.\n"; $out.="For every error message I receive, I'll send you a notice. I do not check if you already\n"; $out.="received such a notice. Instead of complaining about this, better try to fix the problem\n"; $out.="as soon as possible.\n\n"; $out.="For questions you can contact the webmaster: ".$setup['WebmasterEmail']."\n\n"; $out.="In the attachment you can find the message on which I based this conclusion.\n\n"; $out.="Greetings from the friendly webmaster.\n"; $out.="\n--".$boundary."\n"; for($i=0; $iget_fullmessage()."\n"; $out.="--".$boundary."--\n"; $header.="X-Content: error to jc"; $header.="\nX-ApplicationID: 0"; $header.="\nX-Signature: ".substr(md5("secret".$setup['EventCode']."error to jc"."0"), 0, 24); send_mail($setup['MailJc'], "Error in candidates e-mail", $out, $header, false, false); if( strlen($query)>0 ) { if( doquery($query) ) { dolog("mailreturn", "E-mail address of ".$row['FirstName']." ".$row['LastName']." (".$row['BodyCode']."; ".$row['Email'].") is incorrect. Removed e-mail address and informed jc.", "info"); }else { dolog("mailreturn", "E-mail address of ".$row['FirstName']." ".$row['LastName']." (".$row['BodyCode']."; ".$row['Email'].") is incorrect. Failed removing e-mail address and informed jc.", "error"); } }else { dolog("mailreturn", "E-mail to ".$row['FirstName']." ".$row['LastName']." (".$row['BodyCode']."; ".$row['Email'].") failed. Informed jc.", "info"); } }else { dolog("mailreturn", "E-mail came back from a candidate, but I do not know the ID (".$Mail_applID.")", "warning"); } }else { dolog("mailreturn", "E-mail came back from a candidate, but there was no ID", "warning"); } }else { dolog("mailreturn", "E-mail came back from candidate, but we don't have to handle it (problem type: ".$error.")", "info"); } } function error_organizer($Mail_applID, $error, $content) { // Message to participant failed, inform organizer, and remove the e-mail address global $rmail, $setup; $message=$rmail->get_message(); if( $error!="delayed" ) { if( $Mail_applID>0 ) { $query="SELECT `FirstName`, `LastName`, `BodyCode`, `Email` FROM `persons` WHERE `PersonID`=".addslashes($Mail_applID); if( @mysql_num_rows( $res=doquery($query) )==1 ) { $row=mysql_fetch_array($res); $boundary = $rmail->new_boundary(); $header ="From: \"Webmaster ".$setup['SetupEventType']." Application\" <".$setup['WebmasterEmail'].">\n"; $header.="Content-Type: multipart/mixed; boundary=\"".$boundary."\"\n"; $out ="This is a MIME-encapsulated message\n"; $out.="\n--".$boundary."\n\n"; $out.="Dear Organizer,\n\n"; $out.="It seems the e-mail address of ".$row['FirstName']." ".$row['LastName']."\n"; $out.="(".$row['BodyCode']."; ".$row['Email'].") is not working properly.\n\n"; $out.="An e-mail that was send with as content\n\n"; $out.=" ".$content."\n\n"; $query=""; switch( $error ) { case "temporaly": $out.="did not arrive in the participants mailbox. It was a temporaly error, so\n"; $out.="no action from your side is needed. If you think it is important the\n"; $out.="participant receives the message, you could resend it. You can find the\n"; $out.="message in the attachment.\n\n"; break; case "permanent": $out.="did not arrive in the participants mailbox. It was a permanent error, which\n"; $out.="means the e-mail address is invalid. Can you please try to get the right\n"; $out.="e-mail address in the application? I'll now remove the e-mail from the\n"; $out.="application to prevent future error messages.\n\n"; $query="UPDATE `persons` SET `Email`='', `Log`=CONCAT(`Log`,'\n".date("Y-m-d H:i:s").": e-mail address removed by system (invalid mailbox)') WHERE `PersonID`=".addslashes($Mail_applID); break; case "unknown": $out.="did not arrive in the participants mailbox. It was an unknown error, so\n"; $out.="I have no clue what to do. Please check the attachment and try to figure\n"; $out.="out the problem yourself. If you think it is important the participant\n"; $out.="receives the message, you could resend it. You can find the message in\n"; $out.="the attachment.\n\n"; break; } $out.="This message has been automatically generated by the ".$setup['SetupEventType']." Application Mailer.\n"; $out.="For every error message I receive, I'll send you a notice. I do not check if you already\n"; $out.="received such a notice. Instead of complaining about this, better try to fix the problem\n"; $out.="as soon as possible.\n\n"; $out.="For questions you can contact the webmaster: ".$setup['WebmasterEmail']."\n\n"; $out.="In the attachment you can find the message on which I based this conclusion.\n\n"; $out.="Greetings from the friendly webmaster.\n"; $out.="\n--".$boundary."\n"; for($i=0; $iget_fullmessage()."\n"; $out.="--".$boundary."--\n"; $header.="X-Content: error to organizer"; $header.="\nX-ApplicationID: 0"; $header.="\nX-Signature: ".substr(md5("secret".$setup['EventCode']."error to organizer"."0"), 0, 24); send_mail($setup['EventErrorEmail'], "Error in participant e-mail", $out, $header, false, false); if( strlen($query)>0 ) { if( doquery($query) ) { dolog("mailreturn", "E-mail address of ".$row['FirstName']." ".$row['LastName']." (".$row['BodyCode']."; ".$row['Email'].") is incorrect. Removed e-mail address and informed organiser.", "info"); }else { dolog("mailreturn", "E-mail address of ".$row['FirstName']." ".$row['LastName']." (".$row['BodyCode']."; ".$row['Email'].") is incorrect. Failed removing e-mail address and informed organiser.", "error"); } }else { dolog("mailreturn", "E-mail to ".$row['FirstName']." ".$row['LastName']." (".$row['BodyCode']."; ".$row['Email'].") failed. Informed organiser.", "info"); } }else { dolog("mailreturn", "E-mail came back from a participant, but I do not know the ID (".$Mail_applID.")", "warning"); } }else { dolog("mailreturn", "E-mail came back from a participant, but there was no ID", "warning"); } }else { dolog("mailreturn", "E-mail came back from participant, but we don't have to handle it (problem type: ".$error.")", "info"); } } function error_webmaster($error, $content) { global $rmail, $setup; $message=$rmail->get_message(); if( $error!="delayed" ) { $mail = new MailOut($setup['MailReturnpath'], $setup['WebmasterEmail']); $mail->add_header("X-Content: error to webmaster"); $mail->add_header("X-ApplicationID: 0"); $mail->add_header("X-Signature: ".substr(md5("secret".$setup['EventCode']."error to webmaster"."0"), 0, 24)); $mail->add_header("From: \"Webmaster ".$setup['SetupEventType']." Application\" <".$setup['WebmasterEmail'].">"); $mail->add_header("Subject: Error returned in reply to e-mail from ".$setup['SetupEventType']." mailer"); $mail->set_message("This is a MIME-encapsulated message\n"); $mail->add_header("Content-Type: text/plain; charset=UTF-8", 1); $msg = "Dear Webmaster,\n\n"; $msg.= "A message with the content\n\n"; $msg.= " ".$content."\n\n"; $msg.= "was not delivered and came back with ".$error." error.\n\n"; $msg.= "The involved message is in the attachment. Please take care of this error.\n\n"; $msg.= "Greetings from the friendly webmaster.\n"; $mail->set_message($msg, 1); $mail->add_header("Content-Type: message/rfc822", 2); $mail->set_message($rmail->get_fullmessage(), 2); $mail->send(); dolog("mailreturn", "Mail returned with ".$error." error. Content: ".$content, "warning"); } } ?>