I figured it out myself, but thanks anyway for all the people who viewed the post and didn't say anything. There are two ways to do it, either have a link embeded in the email that has the link to the pdf, or attach the pdf like normal. Here is the code for both. If anyone else wants this to work, and this looks like a lot of code, copy the whole thing and change the obivious things like to and from. Fool around with it for awhile and it will work.
****SEND EMAIL AS ATTACHMENT****
<BR>
<?php
$fileatt = "http://witphp.witstaging.com/CMS"; // Path to the file
$fileatt_type = "application/pdf"; // File Type
$fileatt_name = "CMS.pdf"; // Filename that will be used for the file as the attachment
$email_from = "ME <me@me.com>"; // Who the email is from
$email_subject = "The WIT Whitepaper you requested"; // The Subject of the email
$email_txt = ""; // Message that the email has in it
$email_to = "test@test.com"; // Who the email is to
$headers = "From: ".$email_from;
#$file = fopen($fileatt,'rb');
#$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}\"";
$email_message .= "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type:text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$email_message ."<html><body>THIS IS WHERE THE MESSAGE GOES!!!!br><br>
~Stephen</body></html>\n\n";
$data = chunk_split(base64_encode($data));
$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 "<font face=verdana size=2>The email was successfully sent!</font>";
} else {
die("Sorry but the email could not be sent. Please go back and try again!");
}
?>
<BR>
****EMAIL WITH LINK AS ATTACHMENT****
<?php
/******************************************
Publish On : Jan 10th, 2004
Scripter : Hermawan Haryanto
Version : 1.0
License : GPL (General Public License)
*******************************************/
function sendmail ($from_name, $from_email, $to_name, $to_email, $subject, $text_message="", $html_message, $attachment="")
{
$from = "$from_name <$from_email>";
$to = "$to_name <$to_email>";
$main_boundary = "----=_NextPart_".md5(rand());
$text_boundary = "----=_NextPart_".md5(rand());
$html_boundary = "----=_NextPart_".md5(rand());
$headers = "From: $from\n";
$headers .= "Reply-To: $from\n";
$headers .= "X-Mailer: Hermawan Haryanto ([url]http://hermawan.com[/url])\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed;\n\tboundary=\"$main_boundary\"\n";
$message .= "\n--$main_boundary\n";
$message .= "Content-Type: multipart/alternative;\n\tboundary=\"$text_boundary\"\n";
$message .= "\n--$text_boundary\n";
$message .= "Content-Type: text/plain; charset=\"ISO-8859-1\"\n";
$message .= "Content-Transfer-Encoding: 7bit\n\n";
$message .= ($text_message!="")?"$text_message":"Text portion of HTML Email";
$message .= "\n--$text_boundary\n";
$message .= "Content-Type: multipart/related;\n\tboundary=\"$html_boundary\"\n";
$message .= "\n--$html_boundary\n";
$message .= "Content-Type: text/html; charset=\"ISO-8859-1\"\n";
$message .= "Content-Transfer-Encoding: quoted-printable\n\n";
$message .= str_replace ("=", "=3D", $html_message)."\n";
if (isset ($attachment) && $attachment != "" && count ($attachment) >= 1)
{
for ($i=0; $i<count ($attachment); $i++)
{
$attfile = $attachment[$i];
$file_name = basename ($attfile);
$fp = fopen ($attfile, "r");
$fcontent = "";
while (!feof ($fp))
{
$fcontent .= fgets ($fp, 1024);
}
$fcontent = chunk_split (base64_encode($fcontent));
@fclose ($fp);
$message .= "\n--$html_boundary\n";
$message .= "Content-Type: application/octetstream\n";
$message .= "Content-Transfer-Encoding: base64\n";
$message .= "Content-Disposition: inline; filename=\"$file_name\"\n";
$message .= "Content-ID: <$file_name>\n\n";
$message .= $fcontent;
}
}
$message .= "\n--$html_boundary--\n";
$message .= "\n--$text_boundary--\n";
$message .= "\n--$main_boundary--\n";
@mail ($to, $subject, $message, $headers);
}
# Example
# Sender Name
$from_name = "ME";
# Sender Email
$from_email = "me@me.com";
# Recipient Name
$to_name = "TEST";
# Recipient Email
$to_email = "test@test.com";
# Email Subject
$subject = "Email with embeded file";
# Text Portion
$text_message = "This is HTML email and your email client softawre ain't support HTML email.";
# HTML Portion
$html_message = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n";
$html_message.= "<html><head><title></title>\n";
$html_message.= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n";
$html_message.= "<style type=\"text/css\">\n";
$html_message.= "body, td {\nfont-family: Trebuchet MS;\nfont-size: 12px;\n}\n";
$html_message.= "</style>\n";
$html_message.= "</head>\n";
$html_message.= "<body><table width=\"100%\" cellpadding=0 cellspacing=0><tr valign=top align=center>";
$html_message.= "<td width=300>This is my HTML Body\n<br>";
$html_message.= "<a href=\"http://witphp.witstaging.com/CMS/CMS.pdf\">pdf file</a><br>\n";
$html_message.= "<font color=red>Hi everyone, this is the file.";
$html_message.= "</td>";
$html_message.= "</tr></table>";
$html_message.= "</body></html>";
# Attachment Location
$attachment = array ("CMS.pdf");
# Execute SendMail Function
sendmail ($from_name, $from_email, $to_name, $to_email, $subject, $text_message, $html_message, $attachment);
?>