Can anyone tell me what's wrong with this?
// SEND EMAIL WITH ATTACHMENT
$filename = $_POST[pathtitle] . ".doc";
$eAddress = $_POST[recipient];
$eSubject = $_POST[sender] . " sent you a bible study!";
$filepath = "downloads/studies/" . $filename;
$file = "downloads/studies/" . $filename;
if(!file_exists($file)) {
echo($file . "<p />");
die("<p align='center'>Error: Study file does not exist, please <a href='contact.php' class='Link1'>contact</a> administrators.</p>");
}
// SET HEADERS AND MESSAGE
$headers = "MIME-Version: 1.0\n";
$headers .= "From: " . $_POST[sender] . " <" . $_POST[senderemail] . ">\n";
$headers .= "Reply-To: " . $_POST[senderemail] . "\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"BOUNDARY-12345\";\n";
$headers .= "Content-Transfer-Encoding: 7bit\n";
$headers .= "This part of the E-mail should never be seen. If\n";
$headers .= "you are reading this, consider upgrading your e-mail\n";
$headers .= "client to a MIME-compatible client.\n";
$message .= "Your friend, " . $_POST[sender] . " wants to share this with you.\n\n";
$message .= "Please see the attached file.\n";
$message .= "--BOUNDARY-12345\n";
$message .= "Content-Type: application/msword; name=\"$filename\";\n";
$message .= "Content-Transfer-Encoding: base64\n";
$message .= "Content-Disposition: attachment; filename=\"$filename\"\n\n";
// ENCODE DATA FOR FILE
$path = $filepath;
$fp = fopen($path, 'r');
do {
$data = fread($fp, 8192);
if (strlen($data) == 0) break;
$content .= $data;
} while (true);
$content_encode = chunk_split(base64_encode($content));
$message .= $content_encode . "\n";
$message .= "--BOUNDARY-12345\n";
$domail = mail($eAddress, $eSubject, $message, $headers);
if(!$domail) {
echo("<p align='center'><b>Error:</b> email service currently unavailable.</p>");
} else {
echo("<p align='center'><b>Success!</b> Your email has been successfully sent.</p>");
}
}
Basically my problem is that for awhile it was sending the email, now it's sending it, but I'm not receiving it, the file is attached, but the text
$message .= "Your friend, " . $_POST[sender] . " wants to share this with you.\n\n";
$message .= "Please see the attached file.\n";
only half shows up.
Code:
// SEND EMAIL WITH ATTACHMENT
$filename = $_POST[pathtitle] . ".doc";
$eAddress = $_POST[recipient];
$eSubject = $_POST[sender] . " sent you a bible study!";
$filepath = "downloads/studies/" . $filename;
$file = "downloads/studies/" . $filename;
if(!file_exists($file)) {
echo($file . "<p />");
die("<p align='center'>Error: Study file does not exist, please <a href='contact.php' class='Link1'>contact</a> administrators.</p>");
}
// SET HEADERS AND MESSAGE
$headers = "MIME-Version: 1.0\n";
$headers .= "From: " . $_POST[sender] . " <" . $_POST[senderemail] . ">\n";
$headers .= "Reply-To: " . $_POST[senderemail] . "\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"BOUNDARY-12345\";\n";
$headers .= "Content-Transfer-Encoding: 7bit\n";
$headers .= "This part of the E-mail should never be seen. If\n";
$headers .= "you are reading this, consider upgrading your e-mail\n";
$headers .= "client to a MIME-compatible client.\n";
$message .= "Your friend, " . $_POST[sender] . " wants to share this with you.\n\n";
$message .= "Please see the attached file.\n";
$message .= "--BOUNDARY-12345\n";
$message .= "Content-Type: application/msword; name=\"$filename\";\n";
$message .= "Content-Transfer-Encoding: base64\n";
$message .= "Content-Disposition: attachment; filename=\"$filename\"\n\n";
// ENCODE DATA FOR FILE
$path = $filepath;
$fp = fopen($path, 'r');
do {
$data = fread($fp, 8192);
if (strlen($data) == 0) break;
$content .= $data;
} while (true);
$content_encode = chunk_split(base64_encode($content));
$message .= $content_encode . "\n";
$message .= "--BOUNDARY-12345\n";
$domail = mail($eAddress, $eSubject, $message, $headers);
if(!$domail) {
echo("<p align='center'><b>Error:</b> email service currently unavailable.</p>");
} else {
echo("<p align='center'><b>Success!</b> Your email has been successfully sent.</p>");
}
}
Basically my problem is that for awhile it was sending the email, now it's sending it, but I'm not receiving it, the file is attached, but the text
$message .= "Your friend, " . $_POST[sender] . " wants to share this with you.\n\n";
$message .= "Please see the attached file.\n";
only half shows up.