在YII

2011-12-28 40 views
0

sendmail.php multidimesional阵列这只是其中attachment.in即时通讯困惑的样品...在YII

class sendmail() 
     public $ATTACHMENT = array(); 
public function MailSend() 
{ 
     $message    = new YiiMailMessage; 
     $message->subject  = $this->SUBJECT; 
     $message->from  = $this->FROM; 
     $message->setBody($this->EMAILBODY, 'text/html','utf-8'); 
     $message->addTo($this->EMAILTO); 
     if (count($this->ATTACHMENT) > 0) 
        { 
         foreach ($this->ATTACHMENT as $Attachement_Array) 
         { 
          if (isset($Attachement_Array['filepath']) && $Attachement_Array['filename'] && $Attachement_Array['mimetype'] && file_exists($Attachement_Array['filepath'])) 
          { 
           $message->attach(Swift_Attachment::fromPath($Attachement_Array['filepath']), $Attachement_Array['filename'], $Attachement_Array['mimetype']); 
          } 
         } 
        } 
} 
} 

mycontroller.php

在这里 $ SendMail-> ATTACHMENT =阵列( “在这里通过什么”);
请给我解释一下 我想要的文件路径,MIME类型的多维数组,文件名

/** SEND EMAIL USING COMMON EMAIL FUNCTIONALITY */ 
    $SendMail    = new SendMail; 
    $SendMail->DRAFT_ID  = $id; 
    $SendMail->SUBJECT  = $modelEmail->subject; 
    $SendMail->FROM   = $modelEmail->email_from; 
    $SendMail->CMPAIGN_ID = 1; 
    $SendMail->TAG_ARRAY = array("[FIRSTNAME]"=>$profiledata->name,"[EMAIL]"=>$profiledata->email,"[CONTACT_NO]"=>$profiledata->contact_no,"[ADDRESS]"=>$profiledata->address,"[WEBSITE]"=>$profiledata->website); 
$SendMail->EMAILTO  = $profiledata->name."<".$profiledata->email.">"; 
$SendMail->ATTACHMENT = array('filepath'=>Yii::app()->params['var_path']."stationary.html"); /// what to write here... i want multidimension array here 

$SendMail->MailSend(); 
/** SEND EMAIL USING COMMON EMAIL FUNCTIONALITY */ 
+0

我不明白你的问题/问题是什么。 – 2011-12-28 19:32:09

回答

0

我的回答是

$attach1    = array(); 
    $attach2    = array(); 
    $attach1    = array('filepath'=>Yii::app()->params['var_path']."stationary.html", 
            'filename'=>"stationary.html", 
            'mimetype'=>"application/html",); 
    $attach2    = array('filepath'=>Yii::app()->params['var_path']."pregmatch1_old.php", 
            'filename'=>"pregmatch1_old.php", 
            'mimetype'=>"application/php",); 
$SendMail->ATTACHMENT = array($attach1,$attach2);