/* Copyright (c) Rik Snel 2011, license GNU AGPLv3 */ // check if mandatory config values are set if (!isset($mail_backend)) $mail_backend = 'default'; if (!isset($mail_inhibit)) $mail_inhibit = false; if (!isset($mail_emerg_from)) $mail_emerg_from = 'srv-ovc-linux@ovc.nl'; function mail_backend_default($from, $to, $headers, $subject, $message) { return mail($to, $subject, $message, $headers, '-f '.$from); } function phplib_mail($from_name, $from_addr, $to, $reply_to, $subject, $message) { global $data, $mail_backend, $mail_inhibit; if (!filter_var($from_addr, FILTER_VALIDATE_EMAIL)) error_system("emailadres FROM $from is invalid"); if (!filter_var($to, FILTER_VALIDATE_EMAIL)) error_system("emailadres TO $to is invalid"); if ($from_name) { $from_header = "From: $from_name <$from_addr>\r\n"; } else { $from_header = "From: $from_addr\r\n"; } $headers = $from_header.'X-Mailer: PHP/'.phpversion()."\r\n"; if ($reply_to) $headers .= 'Reply-To: '.$reply_to."\r\n"; $now = date_create_from_format('U.u', $_SERVER['REQUEST_TIME_FLOAT']); $filename = 'mail_'.date_format($now, "YmdGisu").'_'.$to.'.txt'; $bytes = file_put_contents($data.$filename, ($mail_inhibit?"INHIBITED\n":'').$headers."Subject: ".$subject."\r\n".$message); echo("filename=$filename $bytes"); ?>
=$headers?>if ($mail_inhibit) return; switch ($mail_backend) { case 'default': $res = mail_backend_default($from_addr, $to, $headers, $subject, $message); break; default: error_system("impossible value for mail_backend $mail_backend"); } if ($res) logit("mail sent to $to, no error (yet) from backend"); else logit("error sending mail to $to"); } function phplib_mail_emerg($message) { global $mail_emerg_from, $mail_backend, $sysop_email; $headers = "From: $mail_emerg_from\r\n".'X-Mailer: PHP/'.phpversion()."\r\n"; switch ($mail_backend) { case 'default': return mail_backend_default($mail_emerg_from, $sysop_email, $headers, 'errormessage', $message); break; default: // fail silently, we don't want an error loop here } } ?>