public function testMessageAttachments() { $message = Mail::message('Body text'); $message->attach('../logo.png'); $attached_children = $message->getChildren(); $this->assertTrue(count($attached_children) == 1); $this->assertTrue($attached_children[0] instanceof Swift_Attachment); $attachment = Mail::attachment('../body.png'); $this->assertTrue($attachment instanceof Swift_Attachment); $message->attach($attachment); $attached_children = $message->getChildren(); $this->assertTrue(count($attached_children) == 2); }
/** * Attach a {@link Swift_Mime_MimeEntity} such as an Attachment or MimePart. * * @param Swift_Mime_MimeEntity|string $path_or_entity * @param string $filename * @param string $contentType * * @return Message */ public function attach($path_or_entity = null, $filename = null, $contentType = null) { if ($path_or_entity instanceof \Swift_Mime_MimeEntity) { $this->message->attach($path_or_entity); } else { $attachment = Mail::attachment($path_or_entity, $filename, $contentType); $this->message->attach($attachment); } return $this; }