Gossamer Forum
Home : General : Internet Technologies :

Whats wrong with this?

Quote Reply
Whats wrong with this?
Can anyone tell me what's wrong with this?

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.

Last edited by:

JoFrRi: Aug 6, 2005, 3:54 PM
Quote Reply
Re: [JoFrRi] Whats wrong with this? In reply to
Hi,

What does the email show as the full header? (i.e do a "print" of $message).

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Whats wrong with this? In reply to
As usual, thanks for replying Andy.

I eventually figured it out. So far it's working okay. I'll make sure to be back with my next problem. =)