src/Mailer/Email.php
public function setAttachments($attachments) {
		$attach = [];
		foreach ((array)$attachments as $name => $fileInfo) {
			if (!is_array($fileInfo)) {
				$fileInfo = ['file' => $fileInfo];
			}
			if (!isset($fileInfo['file'])) {
				if (!isset($fileInfo['data'])) {
					throw new InvalidArgumentException('No file or data specified.');
				}
				if (is_int($name)) {
					throw new InvalidArgumentException('No filename specified.');
				}
			} else {
				$fileName = $fileInfo['file'];
				if (!preg_match('~^https?://~i', $fileInfo['file'])) {
					$fileInfo['file'] = realpath($fileInfo['file']);
				}
				if ($fileInfo['file'] === false || !Utility::fileExists($fileInfo['file'])) {
					throw new InvalidArgumentException(sprintf('File not found: "%s"', $fileName));
				}
				if (is_int($name)) {
					$name = basename($fileInfo['file']);
				}
			}
			if (!isset($fileInfo['mimetype'])) {
				$ext = pathinfo($name, PATHINFO_EXTENSION);
				$fileInfo['mimetype'] = $this->_getMimeByExtension($ext);
			}
			$attach[$name] = $fileInfo;
		}
		$this->_attachments = $attach;

		return $this;
	}
public function setAttachments($attachments) {
		$attach = [];
		foreach ((array)$attachments as $name => $fileInfo) {
			if (!is_array($fileInfo)) {
				$fileInfo = ['file' => $fileInfo];
			}
			if (!isset($fileInfo['file'])) {
				if (!isset($fileInfo['data'])) {
					throw new InvalidArgumentException('No file or data specified.');
				}
				if (is_int($name)) {
					throw new InvalidArgumentException('No filename specified.');
				}
			} else {
				$fileName = $fileInfo['file'];
				if (!preg_match('~^https?://~i', $fileInfo['file'])) {
					$fileInfo['file'] = realpath($fileInfo['file']);
				}
				if ($fileInfo['file'] === false || !Utility::fileExists($fileInfo['file'])) {
					throw new InvalidArgumentException(sprintf('File not found: "%s"', $fileName));
				}
				if (is_int($name)) {
					$name = basename($fileInfo['file']);
				}
			}
			if (!isset($fileInfo['mimetype'])) {
				$ext = pathinfo($name, PATHINFO_EXTENSION);
				$fileInfo['mimetype'] = $this->_getMimeByExtension($ext);
			}
			$attach[$name] = $fileInfo;
		}
		$this->_attachments = $attach;

		return $this;
	}
public function setAttachments ( $ attachments ) { $ attach = [ ] ; foreach ( ( array ) $ attachments as $ name => $ fileInfo ) { if ( ! is_array ( $ fileInfo ) ) { $ fileInfo = [ 'file' => $ fileInfo ] ; } if ( ! isset ( $ fileInfo [ 'file' ] ) ) { if ( ! isset ( $ fileInfo [ 'data' ] ) ) { throw new InvalidArgumentException ( 'No file or data specified.' ) ; } if ( is_int ( $ name ) ) { throw new InvalidArgumentException ( 'No filename specified.' ) ; } } else { $ fileName = $ fileInfo [ 'file' ] ; if ( ! preg_match ( '~^https?://~i' , $ fileInfo [ 'file' ] ) ) { $ fileInfo [ 'file' ] = realpath ( $ fileInfo [ 'file' ] ) ; } if ( $ fileInfo [ 'file' ] === false || ! Utility :: fileExists ( $ fileInfo [ 'file' ] ) ) { throw new InvalidArgumentException ( sprintf ( 'File not found: "%s"' , $ fileName ) ) ; } if ( is_int ( $ name ) ) { $ name = basename ( $ fileInfo [ 'file' ] ) ; } } if ( ! isset ( $ fileInfo [ 'mimetype' ] ) ) { $ ext = pathinfo ( $ name , PATHINFO_EXTENSION ) ; $ fileInfo [ 'mimetype' ] = $ this -> _getMimeByExtension ( $ ext ) ; } $ attach [ $ name ] = $ fileInfo ; } $ this -> _attachments = $ attach ; return $ this ; }
Overwrite to allow mimetype detection

@param string|array $attachments String with the filename or array with filenames
@return $this
@throws \InvalidArgumentException
Overwrite to allow mimetype detection