I'm afraid you can't for the purposes you want.
If you want to do this to serve web pages, as far as I can tell, the browsers won't work with such MIME responses for rendering pages.
If you want an example of how this messages works, send yourself an email with an attachment and on your email client (not an webmail) go to the "View source" option on the email body.
You'll see your message, the attachment and possibly other parts on the same message using the MIME Multipart encoding.
OTOH, if you want it to send email, there are libraries, like PHPMailer, that will do all the encoding for you.
If that's what you want, check this example at their website.
Edit:
You could use PHPMailer to build the message, then you just use the result, instead of actually sending the email.
Try something like this:
** This is untested code, just for a starting point **
<?php
require_once('../class.phpmailer.php');
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
try {
$mail->MsgHTML(file_get_contents('contents.html'));
$mail->AddAttachment('images/phpmailer.gif'); // attachment
$mail->AddAttachment('images/phpmailer_mini.gif'); // attachment
$mime_message = $mail->CreateBody();
echo $mime_message;
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
?>