2014-03-03 58 views
0

我真的雨燕发送两个字母:迅速安装文件两个字母

$mail = Mailer::getInstance($oData->Subject); 
        $mail->setTo($oData->Email, $oData->Recipient) 
         ->setBody($body , 'text/html') 
         ->setFrom(array('[email protected]' => 'some.com')); 
        $mail->setAttach($_FILES["Resume"]["tmp_name"]); 

        if (isset($aContent['Recipient']) && !empty($aContent['Recipient']['Value'])) { 
         $mail->setTo($aContent['Recipient']['Value']); 
        } 

        if ($mail->send()) { 
         $mail2 = Mailer::getInstance("Thanks!"); 
         $mail2->setFrom(array('[email protected]' => 'some.com')) 
          ->setTo(array($aContent['Email']['Value'])) 
          ->setBody($thanksEnding , 'text/html') 
          ->setSubject("Wonderful Subj"); 
         if ($mail2->send()) { 
          $this->show->success = TRUE; 
          $this->show->message = __("Message sent."); 
         } 
        } else { 
         $this->show->message = __("Error."); 
        } 

和两个字母有附件。我怎样才能使第一个字母附件?

+0

显示'Mailer :: getInstance'的代码!这很可能是你的麻烦。 –

+0

我使用代码$ mail2 = new Mailer(“Thanks!”)解决了一个问题; – user3374941

回答

1
getInstance() 

看起来像是工厂模式或单件模式。它看起来更像是一个单例模式,因此在调用时您将获得对象的SAME实例。

所以$mail$mail2可能是相同的情况。

使用更好的设计模式并使用new Mailer()创建新实例。

+0

谢谢,我认为这会有所帮助。 – user3374941

0

在发送之前调用$mailer2->setAttach(null);可能会诀窍。

+0

它会导致致命错误:(不幸的是 – user3374941

+0

对不起,不是致命的错误,只是警告,但消息总之没有发送 – user3374941

+0

警告:fopen()[function.fopen]:文件名不能为空... Warning:Can not修改标题信息 - 已经发送的标题(输出开始于... – user3374941