Adds an attachment to an email

@param string $file
The full path to the attachment
@param string $name
An alternative name to use for the attachment file
178993
public function addAttachment($file, $name = false)
    {
        if (file_exists($file)) {
            $this->attachemnts[] = array(
                $file => $name
            );
        }
        
        return $this;
    }
1014862
public void link(Name name, File file) {
    DirectoryEntry entry = new DirectoryEntry(this, checkNotReserved(name, "link"), file);
    put(entry);
    file.linked(entry);
  }
878341
protected function writeMigration($name)
    {
        $path = $this->getMigrationPath();

        if($file = pathinfo($this->creator->create($name, $path, $this->migrations), PATHINFO_FILENAME)){

            $this->line("<info>Created Migration:</info> $file");
        } else{

            $this->error("<info>Nothing to migrate.</info>");
        }
    }
972133
private function _saveHd ($path, $name, $file)
		{
			$this->_save($path . DIRECTORY_SEPARATOR . self::F_HD . DIRECTORY_SEPARATOR . $name, $file, self::F_HD);
		}
1308065
public function canSeeEmailAttachment($name)
    {
        $names = [];

        foreach ($this->getCurrentMail()->getAttachments() as $attachment) {
            $names[] = $attachment->name;
        }

        $this->assertTrue($this->contains($name, $names));
    }
929367
public function inlineAttachment($name, $content)
    {
        if (!is_string($content) && (!is_resource($content) || get_resource_type($content) != 'stream')) {
            throw new Exception\InvalidArgumentException(
                sprintf("Attachment content must be either string or stream, %s passed")
            );
        }
        
        $this->attachments[$name] = [
            'content' => $content,
            'inline'  => true
        ];
    }
558924
public function setFiles($file, $name = null)
	{
		// Verifying if is array
		if (is_array($file)) {
			foreach ($file as $k => $v) {
				$this->setFiles($v,$k);
			}
		} else {
			$parray = &$this->files;
			
			if (file_exists($file)) {
				if (is_null($file)) {
					if (isset($parray[$name])) unset($parray[$name]);
				} else {
					if (is_null($name) || is_integer($name)) {
						$count = count($parray);
						$name = 'file_contents_' . $count;
					}
						
					$parray[$name] = $file;
				}
			} else {
				throw new RuntimeException('Invalid file, file not exists.');
			}	
		}
		
		return $this;
	}
1173784
public function sendFile($file, $name=NULL, $contentType='application/octet-stream', $contentDisposition='attachment'){
        if($name == NULL){
            $name= basename($file);
        }
        header('Content-Description: File Transfer');
        header('Content-Type: '.$contentType);
        header('Content-Disposition: '.$contentDisposition.'; filename="'.$name.'"');
        header('Pragma: public');
        header('Content-Length: ' . filesize($file));
        readfile($file);        
    }
820174
public function attachFile($file, $fileName = null)
    {
        if (gettype($file) == 'resource') {
            $this->file = ['fileName' => $fileName, 'fileContent' => $file];
        } else {
            $this->file = ['fileName' => $fileName, 'fileContent' => fopen($file, 'r')];
        }
    }
924438
public function attach($file, $name = null, $type = null)
    {
        if (!$file instanceof MailAttachment) {
            $file = new MailAttachment($file);
        }

        if ($name) {
            $file->setFilename($name);
        }

        if ($type) {
            $file->setContentType($type);
        }

        $this->files[] = $file;

        return $this;
    }
853587
public function addFormField(string $name): void
    {
        $options = $this->formOptions['fields'][$name];
        $wrapper = $this->createWrapper();
        $label = '';

        if (isset($options['label']['text'])) {
            $label = $this->createLabel($options['label']['text'], $name);

            unset($options['label']['text']);
        }

        $input = HtmlTag::createElement('input')
            ->set('type', $options['input']['type'] ?? 'text')
            ->set('id', $name)
            ->set('name', $name);

        $caption = '';

        if (isset($options['caption']['text'])) {
            $input->set('aria-describedby', $name . '_caption');
            $caption = $this->createCaption($options['caption']['text'], $name);

            unset($options['caption']['text']);
        }

        $elements = [
            'wrapper' => $wrapper,
            'label'   => $label,
            'input'   => $input,
            'caption' => $caption
        ];

        foreach ($elements as $name => $element) {
            $$name = $this->assignOptionsToElement($options, $name, $element);
        }

        if (in_array($options['input']['type'] ?? 'text', ['checkbox', 'radio', 'file'])) {
            $wrapper->addElement($input);
            $wrapper->addElement($label);
        } else {
            $wrapper->addElement($label);
            $wrapper->addElement($input);
        }

        $wrapper->addElement($caption);

        echo $wrapper;
    }
1070226
protected function registerAttachment($name, $options)
	{
		$options = $this->mergeOptions($options);
		App::make('AttachmentValidator')->validateOptions($options);
		
		$attachment = App::make('Attachment', array('name' => $name, 'options' => $options));
		$attachment->setInstance($this);
		$this->attachedFiles[$name] = $attachment;
	}
127147
public function addTo(string $email, string $name = null): self
	{
		$this->message->addTo($email, $name);
		$this->recipients[] = $email;
		return $this;
	}
1283552
public function attachment($file, $name = null, $mime = null) {

		if(true === is_string($file)) {
			$file = new File($file);
		}

		if(false === $file instanceof File) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string or sFire\System\File, "%s" given', __METHOD__, gettype($file)), E_USER_ERROR);
		}

		if(false === $file -> isReadable()) {
			return trigger_error(sprintf('Argument 1 passed to %s() must existing and readable file', __METHOD__), E_USER_ERROR);
		}

		if(null !== $name && false === is_string($name)) {
			return trigger_error(sprintf('Argument 2 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($name)), E_USER_ERROR);
		}

		if(null !== $mime && false === is_string($mime)) {
			return trigger_error(sprintf('Argument 3 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($mime)), E_USER_ERROR);
		}

		if(false === isset($this -> headers['files'])) {
			$this -> headers['files'] = [];
		}

		$name = null !== $name ? $name : $file -> entity() -> getBasename();
		$mime = null !== $mime ? $mime : $file -> getMime();

		$this -> headers['files'][] = (object) ['file' => $file, 'name' => $name, 'mime' => $mime];

		return $this;
	}
639774
public function attachment(string $file, ?string $name = null)
  {
    $this->attachment[] = ['file' => $file, 'name' => $name];
    return $this;
  }
701061
def put_attachment(doc, name, file, options = {})
      file = StringIO.new(file) if file.is_a?(String)
      connection.put path_for_attachment(doc, name), file, options
    end
1342289
public function add_bcc($email, $name = null) {
		if ($this->addressee_exists($email, ['bcc'])) {
			return;
		}

		$this->recipients['bcc'][] = [
			'name' => $name,
			'email' => strtolower($email),
		];
	}