Emailing with attachments works on one server, but not on another

I’ll try to keep this concise. I use this function:

// SENDS AN EMAIL WITH AN ATTACHMENT
function mail_attachment($Recipient, $Subject, $Body, $ExtraHeaders, $AttachmentFilePathsArray, $OverrideNamesArray = array(), $HTMLMail = false) {
                  
	$AttachFile_type = 'image/jpeg';
		
	$RandStr = md5(microtime());
	$MIME_Boundary = "==Multipart_Boundary_x{$RandStr}x";
	    
	$AttachFile_headers = "\
MIME-Version: 1.0\
" .
        "Content-Type: multipart/mixed;\
" . 
        " boundary=\\"{$MIME_Boundary}\\"";
        
        $AppeBody = '';
	
	foreach ($AttachmentFilePathsArray AS $i => $AttachFilePath) {
		$AttachFile_name = (isset($OverrideNamesArray[$i]) && $OverrideNamesArray[$i] != '')?$OverrideNamesArray[$i]:((substr_count($AttachFilePath, '/'))?substr(strrchr($AttachFilePath, '/'), 1):$AttachFilePath);
		
		$AttachFile_pointer = fopen($AttachFilePath, 'rb');
		$AttachFile_data    = fread($AttachFile_pointer, filesize($AttachFilePath));
		fclose($AttachFile_pointer);
		
		$AttachFile_data = chunk_split(base64_encode($AttachFile_data));
	
		$AppeBody .=
		"--{$MIME_Boundary}\
" . 
		"Content-Type: {$AttachFile_type};\
" . 
		" name=\\"{$AttachFile_name}\\"\
" . 
		"Content-Transfer-Encoding: base64\
\
" . 
		$AttachFile_data . "\
\
";
	}
		
	$Body =
	"This is a multi-part message in MIME format.\
\
" . 
	"--{$MIME_Boundary}\
" . 
	(($HTMLMail)?"Content-Type: text/html; charset=\\"iso-8859-1\\"\
\
":'') .
	$Body . "\
\
" .
	((count($AttachmentFilePathsArray) > 0)?"\
\
$AppeBody":'') . "--{$MIME_Boundary}--";
	
	// Send the email
	mail($Recipient, $Subject, str_replace("\	", '', $Body), "$ExtraHeaders$AttachFile_headers"); 
}

On one server that I use, this works perfectly. On a different server (one that I own) I use this exact same function, yet the emails are just full of plain text containing the whole base64 strings, headers and everything.

Is there some configuration I’m missing?