5 //ini_set('display_errors',0);
6 require_once(dirname(dirname(__FILE__
)).'/config.php');
7 $tmp = explode('@',$_ENV['RECIPIENT']);
10 // BOUNCE EMAILS TO NOREPLY
11 if ($_ENV['RECIPIENT'] == $CFG->noreplyaddress
) {
12 $user = new stdClass();
13 $user->email
= $_ENV['SENDER'];
15 if (!validate_email($user->email
)) {
20 $subject = get_string('noreplybouncesubject','moodle',format_string($site->fullname
));
21 $body = get_string('noreplybouncemessage','moodle',format_string($site->fullname
))."\n\n";
23 $fd = fopen('php://stdin','r');
31 $user->id
= 0; // to prevent anything annoying happening
33 $from->firstname
= null;
34 $from->lastname
= null;
36 $from->maildisplay
= true;
38 email_to_user($user,$from,$subject,$body);
41 /// ALL OTHER PROCESSING
42 // we need to split up the address
43 $prefix = substr($address,0,4);
44 $mod = substr($address,4,2);
45 $modargs = substr($address,6,-16);
46 $hash = substr($address,-16);
48 if (substr(md5($prefix.$mod.$modargs.$CFG->siteidentifier
),0,16) != $hash) {
49 die("HASH DIDN'T MATCH!\n");
51 list(,$modid) = unpack('C',base64_decode($mod.'=='));
53 if ($modid == '0') { // special
57 $modname = $DB->get_field("modules", "name", array("id"=>$modid));
58 include_once('mod/'.$modname.'/lib.php');
60 $function = $modname.'_process_email';
62 if (!function_exists($function)) {
65 $fd = fopen('php://stdin','r');
74 $function($modargs,$body);