/**
  * Set the attachement.
  *
  * @param string $path
  */
 public function attach($file)
 {
     if (File::exists($file)) {
         $filename = explode('/', $file)[count(explode('/', $file)) - 1];
         $mime = mime_content_type($file);
         $attachment = new \Sendgrid\Attachment();
         $attachment->setContent(File::get($file));
         $attachment->setType($mime);
         $attachment->setFilename($filename);
         $attachment->setDisposition('attachment');
         $attachment->setContentId($filename);
         $this->mail->addAttachment($attachment);
     }
     return $this;
 }
Beispiel #2
0
 public function testCheckIfCantOpenFile()
 {
     $file = File::get(__DIR__ . '/dummy/doesntexist.jpg');
     $this->assertEmpty($file, 'Could open file');
 }