среда, 11 сентября 2013 г.

xinetd for http

service ws
{
   port            = 8022
   socket_type     = stream
   wait            = no
   type = UNLISTED
   user            = root
   server          = /usr/bin/php5
   server_args = /root/ws.php
   log_on_success  += USERID
   log_on_failure  += USERID
   disable         = no
   #bind = 127.0.0.1
#       flags=REUSE
}



<?php
ob_start();


echo "Node is running.";


$r=ob_get_contents();
ob_end_clean();
resp($r);

function resp($d){
 $l=strlen($d);
 echo "HTTP/1.1 200 OK\r\n";
 echo "Content-Type: Content-Type: text/plain\r\n";
 echo "Connnection: close\r\n";
 echo "Content-length: {$l}\r\n";
 echo "\r\n";
 die($d);
}




Кастомные сообщения об ошибках постфикса

posconf -t
отдаст текущие настройки

создаём /etc/postfix/bouncr.cf

и в main.cf 

# custom template
bounce_template_file = /etc/postfix/bounce.cf

Catch-all STMP в php

Catch-all STMP в php


#!/usr/bin/php
<?php
date_default_timezone_set('Europe/Moscow');
$dir='/var/www/system/htdocs/mail/list/';
$input = file_get_contents('php://stdin');
preg_match('|^To: (.*)|', $input, $matches);
if ($matches[1]){
$d=preg_replace('/[^a-z\d@\.-]+/','',$matches[1]);
$d=str_replace('@','_',$d);
} else $d='undef';
if (!is_dir($dir.$d)){
  mkdir($dir.$d,0770);
}
$input=explode("\n\n",$input,2);
$input[0].="\nX-SaaS-Origin:".getenv('PWD');
$input=implode("\n\n",$input);

$fn=date('Y-m-d.His_').'rand'.rand(1111,9999).'.txt';

file_put_contents($dir.$d.'/'.$fn, $input);

mutt: отправка письма с аттачем и изменение from

echo "123456fdsgdfghsdfg" |  mutt -s t2  -a /home/alazutov/sqlite.sh   -- to@domain1 to@test.ru


Проставить поле "ОТ" можно очень просто
 export EMAIL="alazutov@tst.ru"