src/Mail/Mail.php
private function formatMessage() {

		$message = [];
		$files 	 = true === isset($this -> headers['files']) ? $this -> headers['files'] : [];

		if(count($files) > 0) {
			
			$message[] = sprintf("--Boundary-mixed-%s\r\n", $this -> getBoundary());
			$message[] = sprintf("Content-Type: multipart/alternative; boundary=\"Boundary-alt-%s\"\r\n\r\n", $this -> getBoundary());
		}

		if(true === isset($this -> message['text'])) {

			$message[] = sprintf("--Boundary-alt-%s\r\n", $this -> getBoundary());
			$message[] = "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
			$message[] = "Content-Transfer-Encoding: 7bit\r\n\r\n";
			$message[] = sprintf("%s\r\n\r\n", $this -> message['text']);
		}

		if(true === isset($this -> message['html'])) {

			$message[] = sprintf("--Boundary-alt-%s\r\n", $this -> getBoundary());
			$message[] = "Content-Type: text/html; charset=\"iso-8859-1\"\r\n";
			$message[] = "Content-Transfer-Encoding: 7bit\r\n\r\n";
			$message[] = sprintf("%s\r\n\r\n", $this -> message['html']);
		}

		$message[] = sprintf("--Boundary-alt-%s--\r\n\r\n", $this -> getBoundary());

		if(count($files) > 0) {
			
			foreach($files as $attachment) {

				$stream 	= fopen($attachment -> file -> entity() -> getBasepath(), 'rb');
				$data 		= fread($stream, $attachment -> file -> getFilesize());
				$data 		= chunk_split(base64_encode($data));

				$message[] = sprintf("--Boundary-mixed-%s\r\n", $this -> getBoundary());
				$message[] = sprintf("Content-Type: %s; name=\"%s\"\r\n", $attachment -> mime, $attachment -> name);
				$message[] = "Content-Transfer-Encoding: base64\r\n";
				$message[] = "Content-Disposition: attachment \r\n\r\n";
				$message[] = sprintf("%s\r\n", $data);
			}

			$message[] = sprintf("--Boundary-mixed-%s--\r\n", $this -> getBoundary());
		}

		return implode('', $message);
	}
private function formatMessage() {

		$message = [];
		$files 	 = true === isset($this -> headers['files']) ? $this -> headers['files'] : [];

		if(count($files) > 0) {
			
			$message[] = sprintf("--Boundary-mixed-%s\r\n", $this -> getBoundary());
			$message[] = sprintf("Content-Type: multipart/alternative; boundary=\"Boundary-alt-%s\"\r\n\r\n", $this -> getBoundary());
		}

		if(true === isset($this -> message['text'])) {

			$message[] = sprintf("--Boundary-alt-%s\r\n", $this -> getBoundary());
			$message[] = "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
			$message[] = "Content-Transfer-Encoding: 7bit\r\n\r\n";
			$message[] = sprintf("%s\r\n\r\n", $this -> message['text']);
		}

		if(true === isset($this -> message['html'])) {

			$message[] = sprintf("--Boundary-alt-%s\r\n", $this -> getBoundary());
			$message[] = "Content-Type: text/html; charset=\"iso-8859-1\"\r\n";
			$message[] = "Content-Transfer-Encoding: 7bit\r\n\r\n";
			$message[] = sprintf("%s\r\n\r\n", $this -> message['html']);
		}

		$message[] = sprintf("--Boundary-alt-%s--\r\n\r\n", $this -> getBoundary());

		if(count($files) > 0) {
			
			foreach($files as $attachment) {

				$stream 	= fopen($attachment -> file -> entity() -> getBasepath(), 'rb');
				$data 		= fread($stream, $attachment -> file -> getFilesize());
				$data 		= chunk_split(base64_encode($data));

				$message[] = sprintf("--Boundary-mixed-%s\r\n", $this -> getBoundary());
				$message[] = sprintf("Content-Type: %s; name=\"%s\"\r\n", $attachment -> mime, $attachment -> name);
				$message[] = "Content-Transfer-Encoding: base64\r\n";
				$message[] = "Content-Disposition: attachment \r\n\r\n";
				$message[] = sprintf("%s\r\n", $data);
			}

			$message[] = sprintf("--Boundary-mixed-%s--\r\n", $this -> getBoundary());
		}

		return implode('', $message);
	}
private function formatMessage ( ) { $ message = [ ] ; $ files = true === isset ( $ this -> headers [ 'files' ] ) ? $ this -> headers [ 'files' ] : [ ] ; if ( count ( $ files ) > 0 ) { $ message [ ] = sprintf ( "--Boundary-mixed-%s\r\n" , $ this -> getBoundary ( ) ) ; $ message [ ] = sprintf ( "Content-Type: multipart/alternative; boundary=\"Boundary-alt-%s\"\r\n\r\n" , $ this -> getBoundary ( ) ) ; } if ( true === isset ( $ this -> message [ 'text' ] ) ) { $ message [ ] = sprintf ( "--Boundary-alt-%s\r\n" , $ this -> getBoundary ( ) ) ; $ message [ ] = "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n" ; $ message [ ] = "Content-Transfer-Encoding: 7bit\r\n\r\n" ; $ message [ ] = sprintf ( "%s\r\n\r\n" , $ this -> message [ 'text' ] ) ; } if ( true === isset ( $ this -> message [ 'html' ] ) ) { $ message [ ] = sprintf ( "--Boundary-alt-%s\r\n" , $ this -> getBoundary ( ) ) ; $ message [ ] = "Content-Type: text/html; charset=\"iso-8859-1\"\r\n" ; $ message [ ] = "Content-Transfer-Encoding: 7bit\r\n\r\n" ; $ message [ ] = sprintf ( "%s\r\n\r\n" , $ this -> message [ 'html' ] ) ; } $ message [ ] = sprintf ( "--Boundary-alt-%s--\r\n\r\n" , $ this -> getBoundary ( ) ) ; if ( count ( $ files ) > 0 ) { foreach ( $ files as $ attachment ) { $ stream = fopen ( $ attachment -> file -> entity ( ) -> getBasepath ( ) , 'rb' ) ; $ data = fread ( $ stream , $ attachment -> file -> getFilesize ( ) ) ; $ data = chunk_split ( base64_encode ( $ data ) ) ; $ message [ ] = sprintf ( "--Boundary-mixed-%s\r\n" , $ this -> getBoundary ( ) ) ; $ message [ ] = sprintf ( "Content-Type: %s; name=\"%s\"\r\n" , $ attachment -> mime , $ attachment -> name ) ; $ message [ ] = "Content-Transfer-Encoding: base64\r\n" ; $ message [ ] = "Content-Disposition: attachment \r\n\r\n" ; $ message [ ] = sprintf ( "%s\r\n" , $ data ) ; } $ message [ ] = sprintf ( "--Boundary-mixed-%s--\r\n" , $ this -> getBoundary ( ) ) ; } return implode ( '' , $ message ) ; }
Formats the messages and returns it as a string
@return string
Formats the messages and returns it as a string