function start($id) { $GLOBALS["CACHEFILE"] = "/usr/share/artica-postfix/ressources/logs/web/mimedefang.resend.progress.{$id}"; $id = intval($id); $sock = new sockets(); $unix = new unix(); if ($id == 0) { echo "ID: {$id} not supported\n"; build_progress(110, "{failed}"); die; } $postgres = new postgres_sql(); $tempfile = $unix->FILE_TEMP(); $Dirtemp = $unix->TEMP_DIR(); $q = new postgres_sql(); $ligne = pg_fetch_array($q->QUERY_SQL("SELECT * FROM quarmsg WHERE id='{$id}'")); if (!$q->ok) { echo "PostgreSQL Error:" . $q->mysql_error . "\n"; build_progress(110, "PostgreSQL {failed}"); die; } $instance = $unix->hostname_g(); $mailfrom = $ligne["mailfrom"]; $mailto = $ligne["mailto"]; $msgmd5 = $ligne["msgmd5"]; if ($mailfrom == null) { $mailfrom = "root@{$instance}"; } echo "From: {$mailfrom}\n"; echo "To..: {$mailto}\n"; echo "ID..: {$msgmd5}\n"; build_progress(20, "{$mailfrom} {to} {$mailto} ({$msgmd5})"); $sql = "SELECT contentid FROM quardata WHERE msgmd5='{$msgmd5}'"; $ligne = pg_fetch_array($q->QUERY_SQL($sql)); if (!$q->ok) { echo "PostgreSQL Error:" . $q->mysql_error . "\n"; build_progress(110, "PostgreSQL {failed}"); die; } $contentid = $ligne["contentid"]; build_progress(30, "msg id: {$contentid}"); @mkdir($Dirtemp, 0777, true); @chmod($Dirtemp, 0777); $sql = "select lo_export({$contentid}, '{$Dirtemp}/{$msgmd5}.gz')"; if ($GLOBALS["VERBOSE"]) { echo "<hr>{$sql}<br>\n"; } $q->QUERY_SQL($sql); if (!$q->ok) { echo "PostgreSQL Error:" . $q->mysql_error . "\n"; build_progress(110, "PostgreSQL {failed}"); die; } build_progress(40, "{uncompress}"); if (!$unix->uncompress("{$Dirtemp}/{$msgmd5}.gz", "{$Dirtemp}/{$msgmd5}.msg")) { @unlink("{$Dirtemp}/{$msgmd5}.gz"); @unlink("{$Dirtemp}/{$msgmd5}.msg"); build_progress(110, "{uncompress} {failed}"); die; } $smtp = new smtp(); $TargetHostname = inet_interfaces(); if (preg_match("#all#is", $TargetHostname)) { $TargetHostname = "127.0.0.1"; } $params["helo"] = $instance; $params["debug"] = true; $params["host"] = $TargetHostname; $params["bindto"] = "127.0.0.1"; build_progress(50, "{connecting}"); if (!$smtp->connect($params)) { build_progress(110, "{connect} {failed}"); @unlink("{$Dirtemp}/{$msgmd5}.msg"); echo "{$smtp->error_number}: Could not connect to `{$TargetHostname}` {$smtp->error_text}\n"; return; } $finalbody = @file_get_contents("{$Dirtemp}/{$msgmd5}.msg"); build_progress(90, "{sending}"); if (!$smtp->send(array("from" => $mailfrom, "recipients" => $mailto, "body" => $finalbody, "headers" => null))) { build_progress(110, "{sending} {failed}"); @unlink("{$Dirtemp}/{$msgmd5}.msg"); echo "{$smtp->error_number}: Could not connect to `{$TargetHostname}` {$smtp->error_text}\n"; $smtp->quit(); return; } @unlink("{$Dirtemp}/{$msgmd5}.msg"); $smtp->quit(); build_progress(100, "{success}"); }
function _DefaultSettings() { if ($GLOBALS["EnablePostfixMultiInstance"] == 1) { shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.postfix-multi.php --from-main-null"); return; } cleanMultiplesInstances(); SetSALS(); SetTLS(); inet_interfaces(); imap_sockets(); MailBoxTransport(); mynetworks(); headers_check(1); MasterCFBuilder(); mime_header_checks(); smtp_sasl_auth_enable(); smtpd_recipient_restrictions(); smtpd_client_restrictions_clean(); smtpd_client_restrictions(); smtpd_sasl_exceptions_networks(); sender_bcc_maps(); CleanMyHostname(); OthersValues(); luser_relay(); smtpd_sender_restrictions(); smtpd_end_of_data_restrictions(); perso_settings(); remove_virtual_mailbox_base(); postscreen(); smtp_sasl_security_options(); BodyChecks(); postfix_templates(); ReloadPostfix(); }
if ($argv[1] == '--banner') { smtp_banner(true); die; } if ($argv[1] == '--myhostname') { CleanMyHostname(); ReloadPostfix(true); } if ($argv[1] == '--others-values') { OthersValues_start(); } if ($argv[1] == '--mime-header-checks') { mime_header_checks_progress(); } if ($argv[1] == '--interfaces') { inet_interfaces(); MailBoxTransport(); exec("{$GLOBALS["postfix"]} stop"); exec("{$GLOBALS["postfix"]} start"); ReloadPostfix(true); die; } if ($argv[1] == '--mailbox-transport') { MailBoxTransport(); ReloadPostfix(true); die; } if ($argv[1] == '--disable-smtp-sasl') { disable_smtp_sasl(); ReloadPostfix(true); die;
function _DefaultSettings() { if ($GLOBALS["EnablePostfixMultiInstance"] == 1) { shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.postfix-multi.php --from-main-null"); return; } SetTLS(); inet_interfaces(); headers_check(1); ArticaFilterInMasterCF(); ArticaFilterInMasterCFPipe(); MasterCFSSL(); mime_header_checks(); smtp_sasl_auth_enable(); smtpd_recipient_restrictions(); smtpd_client_restrictions(); smtpd_sasl_exceptions_networks(); sender_bcc_maps(); CleanMyHostname(); OthersValues(); MailBoxTransport(); mynetworks(); luser_relay(); perso_settings(); ReloadPostfix(); }
function SendTest($Key) { $GLOBALS["WRITETOFILE"] = dirname(__FILE__) . "/ressources/logs/{$Key}.log"; $sock = new sockets(); $unix = new unix(); $datas = unserialize(base64_decode($sock->GET_INFO($Key))); $listen_addr = null; $recipient = $datas["smtp_dest"]; $sender = $datas["smtp_sender"]; smtp::events("Resolving From {$sender} to: {$recipient}", __FUNCTION__, __FILE__, __LINE__); if (preg_match("#(.+?)@(.+)#", $recipient, $re)) { $domainname = $re[2]; } if (!is_numeric($datas["smtp_auth"])) { $datas["smtp_auth"] = 0; } $TargetHostname = null; $servername = $datas["servername"]; $BinDTO = "127.0.0.1"; if ($servername != "master") { $instance = $servername; $main = new maincf_multi($servername); $listen_addr = $main->ip_addr; $BinDTO = $listen_addr; } else { $instance = $unix->hostname_g(); } $smtp = new smtp(); $NOresolvMX = false; if ($datas["smtp_auth"] == 1) { $TargetHostname = $datas["relay"]; } if ($datas["smtp_local"] == 1) { $TargetHostname = inet_interfaces(); if (preg_match("#all#is", $TargetHostname)) { $TargetHostname = "127.0.0.1"; } smtp::events("Local, instance {$servername}: Sock to `{$TargetHostname}`", __FUNCTION__, __FILE__, __LINE__); if ($servername != "master") { smtp::events("Local, instance {$servername}: changed to inet_interfaces()::{$TargetHostname}", __FUNCTION__, __FILE__, __LINE__); $TargetHostname = $listen_addr; } } if ($TargetHostname == null) { $TargetHostname = $smtp->ResolveMXDomain($domainname); smtp::events("Resolving {$domainname} = `{$TargetHostname}` bind address: {$BinDTO}", __FUNCTION__, __FILE__, __LINE__); } $params["helo"] = $instance; $params["bindto"] = $BinDTO; $params["debug"] = true; smtp::events("smtp_auth: {$datas["smtp_auth"]}, user:{$params["user"]},relay:{$datas["relay"]} ", __FUNCTION__, __FILE__, __LINE__); smtp::events("Me: HELO: {$instance}", __FUNCTION__, __FILE__, __LINE__); if ($datas["smtp_auth"] == 1) { $params["auth"] = true; $params["user"] = $datas["smtp_auth_user"]; $params["pass"] = $datas["smtp_auth_passwd"]; if (trim($datas["relay"]) == null) { if ($TargetHostname != null) { $datas["relay"] = $TargetHostname; } } $TargetHostname = $datas["relay"]; } $params["host"] = $TargetHostname; if (!$smtp->connect($params)) { smtp::events("Error {$smtp->error_number}: Could not connect to `{$TargetHostname}` {$smtp->error_text}", __FUNCTION__, __FILE__, __LINE__); return; } $boundary = md5(uniqid(microtime(), TRUE)); $body[] = "Return-Path: <{$sender}>"; $body[] = "X-Original-To: {$recipient}"; $body[] = "Date: " . date("D, d M Y H:i:s") . " +0100 (CET)"; $body[] = "From: {$sender} (Mail Delivery System)"; $body[] = "Subject: Test Message"; $body[] = "To: {$recipient}"; $body[] = ""; $body[] = ""; $body[] = "This is the mail system at host {$instance}."; $body[] = ""; $body[] = "I'm glade to inform you that your message is"; $body[] = " delivered to you..."; $body[] = ""; $body[] = "For further assistance, please send mail to postmaster."; $body[] = ""; $body[] = "If you do so, please include this problem report. You can"; $body[] = "delete your own text from the attached returned message."; $body[] = ""; $body[] = " The mail system"; $body[] = ""; $body[] = ""; $body[] = ""; $finalbody = @implode("\r\n", $body); if (!$smtp->send(array("from" => $sender, "recipients" => $recipient, "body" => $finalbody, "headers" => null))) { smtp::events("Error {$smtp->error_number}: Could not send to `{$TargetHostname}` {$smtp->error_text}", __FUNCTION__, __FILE__, __LINE__); $smtp->quit(); return; } smtp::events("Success sending message trough [{$TargetHostname}:25]", __FUNCTION__, __FILE__, __LINE__); $smtp->quit(); smtp::events("Test message Success From=<{$sender}> to=<{$recipient}> ", __FUNCTION__, __FILE__, __LINE__); chmod($GLOBALS["WRITETOFILE"], 0775); }