I have a php script that takes data from a form and emails it to my email account. It sends the information as a HTML email. Pretty simple stuff.

How might I get it to send the HTML email data as an attached .html file?

I know how to attach existing files to a php email, but I don't know anything about dynamically creating an html file to attach to a php email.

I'd appreciate it if someone could point me in the right direction.

Below is an example of my existing code, where I create an HTML-style email. I want instead to send everything contained in $messagebody as an .html file attachment.

$headers = "From: Me<email@email.com>\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$subject = "Online Application for Employment";

$messagebody = "<html><head></head><body>";
$messagebody .= "<B>Email Data Here</B>";
$messagebody .= "</body></html>";