/**
  * Clear out all attachments
  * @return boolean
  */
 public function flushAttachments()
 {
     $success = true;
     foreach ($this->attachmentIds as $id) {
         try {
             $this->message->detach($id);
         } catch (Swift_Message_MimeException $e) {
             $success = false;
             $this->setError("An attachment failed to detach due to the error:<br />" . $e->getMessage());
         }
     }
     $this->attachmentIds = array();
     return $success;
 }
Ejemplo n.º 2
0
 /**
  * Clear out all attachments
  * @return boolean
  */
 function flushAttachments()
 {
     $success = true;
     foreach ($this->attachmentIds as $id) {
         Swift_Errors::expect($e, "Swift_Message_MimeException");
         $this->message->detach($id);
         if ($e) {
             $success = false;
             $this->setError("An attachment failed to detach due to the error:<br />" . $e->getMessage());
         }
         $e = null;
         Swift_Errors::clear("Swift_Message_MimeException");
     }
     $this->attachmentIds = array();
     return $success;
 }
Ejemplo n.º 3
0
 /**
  * Removing all subParts should give a multipart/mixed message with a nested multipart/related document.
  */
 public function testRemovingAllSubParts()
 {
     $msg = new Swift_Message();
     $id1 = $msg->attach(new Swift_Message_Attachment("bar"));
     $id2 = $msg->attach(new Swift_Message_EmbeddedFile("foo"));
     $id3 = $msg->attach(new Swift_Message_Part("test"));
     $msg->detach($id3);
     $structure = $msg->build()->readFull();
     //$this->dump($structure);
     $this->assertNoPattern("~Content-Type: multipart/alternative~", $structure);
     $this->assertPattern("~.*?Content-Type: multipart/mixed;\\s* boundary=(\"?)(.*?)\\1\r\n" . ".*?\r\n\r\n" . ".*?\r\n--\\2\r\n" . "Content-Type: multipart/related;\\s* boundary=(\"?)(.*?)\\3\r\n" . ".*?\r\n\r\n" . ".*?\r\n--\\4\r\n" . ".*?\r\n--\\4--" . "\\s*\r\n--\\2\r\n" . ".*?\r\n\r\n" . ".*?\r\n--\\2--~s", $structure);
 }
Ejemplo n.º 4
0
 /**
  * {@inheritdoc}
  *
  * @return $this|self
  */
 public function detach(\Swift_Mime_MimeEntity $entity) : self
 {
     $this->message->detach($entity);
     return $this;
 }