AcMailer\Service\MailService::addAttachment PHP Method

addAttachment() public method

public addAttachment ( string $path, string | null $filename = null )
$path string
$filename string | null
    public function addAttachment($path, $filename = null)
    {
        if (isset($filename)) {
            $this->attachments[$filename] = $path;
        } else {
            $this->attachments[] = $path;
        }
        return $this;
    }

Usage Example

 public function testAttachmentsTotal()
 {
     $this->assertCount(0, $this->mailService->getAttachments());
     $this->mailService->setAttachments(array('one', 'two', 'three'));
     $this->mailService->addAttachments(array('four', 'five', 'six'));
     $this->mailService->addAttachment('seven');
     $this->mailService->addAttachment('eight', 'with-alias');
     $this->assertCount(8, $this->mailService->getAttachments());
     $this->mailService->setAttachments(array('one', 'two'));
     $this->assertCount(2, $this->mailService->getAttachments());
     $this->mailService->addAttachments(array('three', 'four'));
     $this->assertCount(4, $this->mailService->getAttachments());
 }
All Usage Examples Of AcMailer\Service\MailService::addAttachment