Strict Standards: Declaration of action_plugin_blog::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/lib/plugins/blog/action.php on line 13

Strict Standards: Declaration of action_plugin_indexmenu::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/lib/plugins/indexmenu/action.php on line 13

Strict Standards: Declaration of action_plugin_importoldchangelog::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/lib/plugins/importoldchangelog/action.php on line 8

Strict Standards: Declaration of action_plugin_importoldindex::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/lib/plugins/importoldindex/action.php on line 8

Strict Standards: Declaration of action_plugin_include::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/lib/plugins/include/action.php on line 19

Deprecated: Assigning the return value of new by reference is deprecated in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/inc/parserutils.php on line 208

Deprecated: Assigning the return value of new by reference is deprecated in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/inc/parserutils.php on line 211

Deprecated: Assigning the return value of new by reference is deprecated in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/inc/parserutils.php on line 421

Deprecated: Assigning the return value of new by reference is deprecated in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/inc/parserutils.php on line 594

Strict Standards: Declaration of cache_instructions::retrieveCache() should be compatible with cache::retrieveCache($clean = true) in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/inc/cache.php on line 291

Deprecated: Function split() is deprecated in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/inc/auth.php on line 154

Strict Standards: Only variables should be passed by reference in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/doku.php on line 73
受信メールをログへ書き出し [開発チーム]

Deprecated: Function split() is deprecated in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/inc/parser/lexer.php on line 517

Deprecated: Function split() is deprecated in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/inc/parser/lexer.php on line 517

Deprecated: Function split() is deprecated in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/inc/parser/lexer.php on line 517

Deprecated: Function split() is deprecated in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/inc/parser/lexer.php on line 517

Deprecated: Function split() is deprecated in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/inc/parser/lexer.php on line 517

Deprecated: Function split() is deprecated in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/inc/parser/lexer.php on line 517
Writing /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/data/cache/d/d9dac56d9fe8b24650087afe81398d25.i failed
Unable to save cache file. Hint: disk full; file permissions; safe_mode setting.

Deprecated: Function split() is deprecated in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/inc/parser/lexer.php on line 517

Deprecated: Function split() is deprecated in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/inc/parser/lexer.php on line 517

Deprecated: Function split() is deprecated in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/inc/parser/lexer.php on line 517

Deprecated: Function split() is deprecated in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/inc/parser/lexer.php on line 517

Deprecated: Function split() is deprecated in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/inc/parser/lexer.php on line 517

Deprecated: Function split() is deprecated in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/inc/parser/lexer.php on line 517
Writing /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/data/cache/d/d9dac56d9fe8b24650087afe81398d25.i failed
Unable to save cache file. Hint: disk full; file permissions; safe_mode setting.
Writing /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/data/cache/d/d9dac56d9fe8b24650087afe81398d25.xhtml failed

▼メールサーバー限定

受信したメールをファイルへ追記していくプログラムです。

今回は、「ml」サーバーにて、

ml:~# vi /etc/postfix/virtual

# peにメールの転送
php@navi-lookup.com php@fideli.info


ml:~# postmap hash:/etc/postfix/virtua

pe」サーバーにて

pe2500:~# vi /etc/aliases
# phpときたら、ファイルの実行を行う
php: "| /usr/bin/php /tmp/mail_data/mail_change.php"

pe2500:~# newaliases

◆peサーバーに作成したphpファイル

Mail/mimeDecode.phpが使えるように、pearの導入が必要です。

<?php
 
// メール用ファイル
require_once 'Mail/mimeDecode.php';
 
// デバッグ用
function memo($val){
        print_r($val);
        echo("\n");
}
 
// メール内容
$params['include_bodies'] = true;
$params['decode_bodies']  = true;
$params['decode_headers'] = true;
$params['input'] = file_get_contents("php://stdin");
$params['crlf'] = "\r\n";
$structure = Mail_mimeDecode::decode($params);
 
 
// 送信者
$mail = $structure->headers['from'];
$mail = addslashes($mail);
$mail = str_replace('"','',$mail);
 
// 文字列の抽出
preg_match("/<.*>/",$mail,$str);
if($str[0]!=""){
$str=substr($str[0],1,strlen($str[0])-2);
$mail = $str;
}
 
// 件名・本文
$diary_subject = $structure->headers['subject'];
$diary_body = $structure->body;
 
// 保存先ディレクトリ・作成ファイル名
define("DIR","/tmp/mail_data/");
$file = DIR."mail_data_file.txt";
 
 
# ------------------------------------
 
 
// 追記ファイルがなければ作成
if(!file_exists($file)){
        touch($file);
}
 
 
if(file_exists($file)){
        // ファイル開放
        $fpw=fopen($file,"a");
 
        // 文字コードの変換
        $diary_subject = mb_convert_encoding($diary_subject, "UTF-8", "JIS");
        $diary_body = mb_convert_encoding($diary_body, "UTF-8", "JIS");
 
        // ファイルに書き込み
        fputs($fpw,$mail."\n");
        fputs($fpw,$diary_subject."\n");
        fputs($fpw,$diary_body."\n");
 
    // ファイルを閉じる
    fclose($fpw);
}
DB版
<?php
define("DF_DB_HOST","localhost");
define("DF_DB_PORT","55432");
define("DF_DB_NAME","pedb");
define("DF_DB_USER","pedb");
define("DF_DB_PASS","pedb");
 
require_once 'Mail/mimeDecode.php'; 
require_once("HTTP/Client.php");
 
if($stdin = @file_get_contents("php://stdin")){
  $params = array();
  $params['include_bodies'] = true; 
  $params['decode_bodies']  = true; 
  $params['decode_headers'] = true; 
  $params['input'] = $stdin; 
  $params['crlf'] = "\r\n";
  $structure = Mail_mimeDecode::decode($params); 
  $mail = $structure->headers['from']; 
  $mail = addslashes($mail); 
  $mail = str_replace('"','',$mail);
  if(preg_match("/<.*>/",$mail,$str)){
    if($str[0]!=""){ 
      $str=substr($str[0],1,strlen($str[0])-2); 
      $mail = $str; 
    }
  }
  $subject = mb_convert_encoding($structure->headers['subject'], "UTF-8", "JIS");
  $body = mb_convert_encoding($structure->body, "UTF-8", "JIS");
//  if($mail != "" and $subject != "" and $body != ""){
    $hash = array(
            "km_mail" => $mail,
            "km_subject" => $subject,
            "km_body" => $body,
        );
    if(!pg_insert(getDb(),"kabarai_mail",$hash)){
      exit();
    }
    $client =& new HTTP_Client();
    $url = "http://www.fideli.com/kbnl/m/kbnlMail/";
    $param = array(
            "id" => "kbnlMail",
            "op" => "admail",
            "km_mail" => $mail,
            "km_subject" => mb_convert_encoding($subject,"EUC-JP","UTF-8"),
            "km_body" => mb_convert_encoding($body,"EUC-JP","UTF-8"),
        );
    $client->post($url, $param);
    $response = $client->currentResponse(); 
 
//  }
}
 
function getDb(){
  return pg_connect(
            "host=".DF_DB_HOST.
            " port=".DF_DB_PORT.
            " dbname=".DF_DB_NAME.
            " user=".DF_DB_USER.
            " password=".DF_DB_PASS
          );  
}
 
/*
 CREATE TABLE kabarai_mail ( 
  km_uniqnum SERIAL  NOT NULL 
  ,km_mail text 
  ,km_reg_time TIMESTAMP  NULL  DEFAULT now()
  ,km_subject text 
  ,km_body text 
);
 
*/
受信メールをログへ書き出し.txt · 最終更新: 2010/07/27 15:46 (外部編集)
www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0

Strict Standards: Only variables should be passed by reference in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/doku.php on line 81