This is my page - accessible from index.php?act=page&pg=download.
The beginning of the page....
<?php
// rename id variable
$id = $_GET['id'];
// determine whether to send email or show link
if(isset($id))
{
// rename member id
$member = $GLOBALS['ibforums']->member['id'];
// define query to get file details
$email_sql = "SELECT * FROM `ibf_download` WHERE `id` = '".$id."' LIMIT 1";
$email_query = mysql_query($email_sql) or die(mysql_error());
// define query to get member details
$member_sql = "SELECT * FROM `ibf_members` WHERE `id` = '".$member."' LIMIT 1";
$member_query = mysql_query($member_sql) or die(mysql_error());
// parse file details into an array
while($email_row = mysql_fetch_array($email_query))
{
// rename file details
$url = $email_row['url'];
$name = $email_row['name'];
$size = $email_row['size'];
}
// parse member details into an array
while($member_row = mysql_fetch_array($member_query))
{
// rename member details
$to = $email_row['email'];
$username = $email_row['name'];
}
// get name of file based on url
$file = basename($url);
Where I have the problem:
// define email settings
$subject = "Attachment: $name";
$from = "Da Bricks <webmaster@dabricks.org>";
$message = "Hello, <br><br>Attached is the file you have requested from Da Bricks.<br><br>";
$message .= "If no file is attached please reply back to this email and the file will be email manually.";
$message .= "<br><br>Thanks, <br>Da Bricks";
$border_random = md5(time());
$mail_boundary = "x{$border_random}x";
$new_e_message = "From: {$from}\r\n";
$new_e_message .= "To: {$to}\r\n";
$new_e_message .= "Reply-to: {$from}\r\n";
$new_e_message .= "MIME-Version: 1.0\r\n";
$new_e_message .= "Content-type: multipart/mixed; boundary=\"{$mail_boundary}\"\r\n";
$new_e_message .= "This is a multi-part message in MIME format.\r\n\r\n";
$new_e_message .= "--{$mail_boundary}\r\n";
$new_e_message .= "Content-type: text/plain; charset=\"iso-8859-1\"\r\n";
$new_e_message .= "Content-Transfer-Encoding:7bit\r\n\r\n";
$new_e_message .= "{$message}\r\n\r\n";
$myFile_type = "application/x-shockwave-flash";
$myFile_name = basename($url);
$myFile_size = filesize($url);
$fp = fopen($url,"rb");
$fileData = fread($fp,$myFile_size);
fclose($fp);
$file1 = base64_encode($fileData);
$file = chunk_split($file1);
$new_e_message .= "--{$mail_boundary}\r\n";
$new_e_message .= "Content-type: {$myFile_type}; name=\"{$myFile_name}\"\r\n";
$new_e_message .= "Content-Transfer-Encoding:base64\r\n";
$new_e_message .= "Content-Disposition: attachment; filename=\"{$myFile_name}\"\r\n\r\n";
$new_e_message .= $file."\r\n\r\n";
$new_e_message .= "--{$mail_boundary}--\r\n";
// Send email to member with attachment
$email_file = mail($to,$subject,$message,$new_e_message) or die("Cannot send email.");
// Output status
echo "Successfully emailed $file to $to.";
The above part does not work. I keep on getting Cannot send email.
All the $url are .swf files.
the $url would = /home/joel/public_html/something.zip
I just want to attach $url to the email. Am I going about in the right way? I've taken parts of the script from different tutorial sites...I know the script will most likely work, but customizing it will be tough.
The rest of the page...
}else{
// show links
// define query
$links_sql = "SELECT * FROM `ibf_download`";
$links_query = mysql_query($links_sql) or die(mysql_error());
// Parse into array
while($links_row = mysql_fetch_array($links_query))
{
echo "<a href='index.php?act=page&pg=download&id={$links_row['id']}'>{$links_row['name']}</a><br>";
}
}
?>
Thanks for all your help. I appreciate i