<?php
$fileatt = "/home/brandon/created/test.pdf"; // Path to the affidavit file
$fileatt_type = "application/octet-stream"; // File Type of the affidavit pdf being sent as an attachment
$fileatt_name = $name." affidavit.pdf"; // Filename that will be used for the file as the attachment

$email_from = "affidavit@authentrus.com"; // Whom the email is from
$email_subject = $name." Affidavit"; // The Subject of the email
$email_txt = $name." has filled out an affidavid request"; // Message that the email has in it

//$email_to = "phadley@authentrus.com";
$email_to = "joanna@reliableid.com"; // Whom the email is to
if ($email) $email_to.=";".$email;
//$email_to=$email;
//echo "<BR>The email will be sent to $email_to even though the customer said $email.";

$headers = "From: ".$email_from;
$headers.="\nX-ReliableID-IP-orig: ".$_SERVER["REMOTE_ADDR"];
$headers.="\nX-serial: $enrollee_id";

$file = fopen($fileatt,'rb');       ##Not file_get_contents?
$data = fread($file,filesize($fileatt));
fclose($file);

$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";


#Opening disclaimer about MIME

//$email_message .= "This is a multi-part message in MIME format.\n\n";

#Message for html part

$email_message.="--{$mime_boundary}\n" .
"Content-Type:text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$email_message . "\n\n";
$email_message.="
<pre>
Attached to this email is your finished Affidavit of Identity, you 
should take it to a notary along with two of your identification cards 
with picture – driver’s license and passport, military ID or other photo ID preferred.  
Please take the ID cards and the Affidavit with you to a notary in your state, 
and have the notary complete the notarization as required.  
NOTE:  Do NOT sign this form ahead of time – it must be signed in the presence of the notary.

Scan your ID cards, saving as a jpg or tif, file, then go to <A href=https://www.startssl.com/?app=12 target=blank>StartCom</A> 
for your Class Two certification. 

Please use Firefox, not Internet Explorer.  This is recommended for the following secure transaction.  Then follow these steps:

Here the steps to get this going:<OL>

<LI>Navigate to <A href=https://www.startssl.com/?app=12>the startssl registration page</A>  (with Firefox)
<LI>Click on \"Register\"
<LI>Provide all of the details in the form and click \"Continue\"
<LI>Check your email account for the verification code. This should take less than a minute.
<LI>Enter the code into the field at the screen (copy / paste)
<LI>At the next step the browser creates a private key - Continue.
<LI>Thereafter, a client authentication certificate will be installed into the certificate store of the browser.
<LI>Finally you enter the StartSSL Control Panel - your account.
<LI>At the right hand side one can view current status and all other kinds of information.
<LI>Click on the \"Validations Wizard\" tab
<LI>Select \"Personal Identity Validation\"
<LI>Select \"Personal Class 2\"
<LI>Upload the documents. Each time another document is selected it's uploaded instantly. After all documents are uploaded click on \"Continue\"
<LI>Click on Finish and wait for the response from the StartSSL group. 

If you have questions on this process, <A href=mailto:certmaster@startcom.org>email StartCom</A> for support.

<LI>Finally, scan and email the notarized Affidavit and ID images to me at <A href=mailto:joanna@reliableid.com>joanna@reliableid.com</A> or fax to 850-597-9201.  Call me at 850-878-9548 with any questions.</LI>
</OL>

Thank you for your confidence!
Joanna Lilly

Reliable ID

<A href=www.reliableid.com>www.reliableid.com</A>
</pre>
";

$data = chunk_split(base64_encode($data));

#Message for pdf part
$email_message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";

$ok = @mail($email_to, $email_subject, $email_message, $headers);

if($ok) {
echo "<p><strong>The affidavit was successfully sent!</strong></p>";
} else {
die("Sorry there was an error sending your affidavit!");
}
?>