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
手紙の出し方 [開発チーム]

れたぁ

/*
今のところ、Ice_LetterはZend_Mailを継承していないので
sendメソッドが呼ばれるたびにクラスないでにゅうしてます
ヘッダー情報が残ってたらとかね(初期化すればいいんだけど)
*/
 
$letter = new Ice_Letter();
$param = array();
$param["TEMPLATE"] = "mybox_entry_new";
$param["To"][0]["NAME"] = "須崎テスト";
//		$param["To"][0]["NAME"] = "suzaki";
$param["To"][0]["MAIL"] = "a@e-classis.co.jp";
 
$param["From"]["NAME"] = "須崎";
$param["From"]["MAIL"] = "prende@fideli.info";
/*
$param["Cc"][0]["NAME"] = "佐藤";
$param["Cc"][0]["MAIL"] = "y_sato@e-classis.co.jp";
$param["Cc"][1]["NAME"] = "李 磊";
$param["Cc"][1]["MAIL"] = "l_lei@e-classis.co.jp";
$param["Cc"][2]["NAME"] = "須崎テスト";
$param["Cc"][2]["MAIL"] = "v@e-classis.co.jp";
*/
$param["REPLACE"]["u_name"] = "おなまえ";
 
if($letter->send($param)){
	debug('メール成功');
}else{
	debug('メール失敗');
}

送信者名や、あて先の名前に日本語を使いたい場合は一回「JIS」に変換してから
「ISO-2022-JP」でエンコードしないと化ける・・・
中国語使えないジャン・・・っていうかこんなん解かるわけないじゃん・・:-(
ぜんど・・なかなか手ごわいね

<?php
 
class Ice_Letter {
 
  public final function __construct($charset=DF_MAIL_CHARSET){
    $this->_charset = $charset;
  }
 
  protected final function encode($str){
    return mb_convert_encoding($str,$this->_charset,DF_CHARSET);
  }
 
  protected final function encodeHead($str){
    return mb_encode_mimeheader(mb_convert_encoding($str,'JIS',DF_CHARSET),$this->_charset);
  }
 
 
  public final function send($param){
    //  mb_internal_encoding(DF_CHARSET);
    if(isset($param["TEMPLATE"]) && $template = $this->getTemplate($param["TEMPLATE"])){
      $subject = $template[0];
      $body = $template[1];
    }else{
      return false;
    }
    $mail = new Zend_Mail($this->_charset);
    try{
      $fromName = DF_MASTER_NAME;
      $fromMail = DF_MASTER_MAIL;
      if(isset($param["From"]) && is_array($param["From"])){
        if(isset($param["From"]["MAIL"])){
          $fromMail = $param["From"]["MAIL"];
          $fromName = (isset($param["From"]["NAME"]))?$param["From"]["NAME"]:"";
        }else{
          return false;
        }
      }
      $mail->setFrom($fromMail,$this->encodeHead($fromName));
      if(!isset($param["Bcc"])){
        $param["Bcc"] = array();
      }
      $param["Bcc"][]["MAIL"] = $fromMail;
      foreach(array("To","Bcc","Cc") as $k => $type){
        if(isset($param[$type]) && is_array($param[$type])){
          foreach($param[$type] as $key => $value){
            $name = "";
            if(isset($value["NAME"])){
              $name = $value["NAME"];
            }
            if(isset($value["MAIL"])){
              $method = "add".$type;
              if($type != "Bcc"){
                $mail->$method($value["MAIL"],$this->encodeHead($name));
              }else{
                debug($value["MAIL"]);
                $mail->$method($value["MAIL"]);
              }
            }else{
              return false;
            }
          }
        }else{
          if(!$k){
            return false;
          }
        }
      }
      $replace = array();
      if(isset($param["REPLACE"]) && is_array($param["REPLACE"])){
        $replace = $param["REPLACE"];
      }
      $mail->setSubject($this->convert($subject,$replace));
      $mail->setBodyText($this->convert($body,$replace));
 
      $mail->send();
    }catch(Zend_Exception $exception) {
      return false;
    }
    return true;
  }
 
  function convert($str,$array){
    $return = "";
    $ArrayData = $array;
    $ArrayData["date"] = date("Y年m月d日",DF_TIME);
    $ArrayData["datehi"] = date("Y年m月d日H時i分",DF_TIME);
    $match = array();
    $reg = '\$\{(.+?)\}';
    if(preg_match_all("/".$reg."/",$str,$match)){
      foreach($match[1] as $key => $val){
        if(!isset($ArrayData[$val])){
          $ArrayData[$val] = "";
        }
      }
    }
    extract($ArrayData);
    $str = '"'.$str.'"';
    $eval = '$return = '.$str.';';
    eval($eval);
    return $this->encode($return);
  }
 
  function getTemplate($file){
    if($file && $file = basename($file)){
      $filePath = DF_LETTER_PATH.DF_DS.$file.".txt";
      if(file_exists($filePath) && is_readable($filePath)){
        if($fp = @file($filePath)){
          $subject = $fp[0];
          unset($fp[0]);
          $body = join(DF_LN,$fp);
          return array($subject,$body);
        }
      }
    }
    return false;
  }
 
}
手紙の出し方.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