Attachment in admin_ticket
Posted: Fri May 08, 2009 7:16 am
Script URL: local
Version of script: 2.0
Hosting company:
URL of phpinfo.php:
URL of session_test.php:
What terms did you try when SEARCHING for a solution:
Write your message below:
I have a question and I know its out of the scope of support for klemen, hopefully someone can help me with it so here it is.
I've altered admin_ticket, by adding an other link to send an email with the info from the ticket to a certain person, everything works fine, but the attachment (if there is any added to the ticket) is not shown as it should, I get the name of the attachment but with some other characters with it so it is not as it should: (example)
The original attachment has the name: Q298169.pdf but when I had send it, it shows as 7#Q298169.pdf, and the size is 249B instead of 17 KB.
I know it as something to do with the att_id (and what comes more with it).
Here is the code I use to send it (part of it):
Hope someone can help me or direct me into the right direction.
Thanks already.
Version of script: 2.0
Hosting company:
URL of phpinfo.php:
URL of session_test.php:
What terms did you try when SEARCHING for a solution:
Write your message below:
I have a question and I know its out of the scope of support for klemen, hopefully someone can help me with it so here it is.
I've altered admin_ticket, by adding an other link to send an email with the info from the ticket to a certain person, everything works fine, but the attachment (if there is any added to the ticket) is not shown as it should, I get the name of the attachment but with some other characters with it so it is not as it should: (example)
The original attachment has the name: Q298169.pdf but when I had send it, it shows as 7#Q298169.pdf, and the size is 249B instead of 17 KB.
I know it as something to do with the att_id (and what comes more with it).
Here is the code I use to send it (part of it):
Code: Select all
//define the receiver of the email
$to = 'blabla@domain.nl';
//define the subject of the email
$subject = "Bestelling 2009-".$ticket['id'];
//create a boundary string. It must be unique
//so we use the MD5 algorithm to generate a random hash
$random_hash = md5(date('r', time()));
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: blabla@domain.nl\r\nReply-To: blabla@domain.nl\r\nCC: ".$ticket[email].",".$ticket[bhemail].",blabla@domain.nl";
//add boundary string and mime type specification
$headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
//read the atachment file contents into a string,
//encode it with MIME base64,
//and split it into smaller chunks
$attachment = chunk_split(base64_encode(file_get_contents('http://intranet/bestellingendatabase2/attachments')));
//define the body of the message.
ob_start(); //Turn on output buffering
?>
--PHP-mixed-<?php echo $random_hash; ?>
Content-Type: multipart/alternative; boundary="PHP-alt-<?php echo $random_hash; ?>"
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/html; charset="iso-8859-1"
--PHP-alt-<?php echo $random_hash; ?>--
--PHP-mixed-<?php echo $random_hash; ?>
Content-Type: application/pdf; name="<?php echo $ticket[attachments]?>"
Content-Transfer-Encoding: base64
Content-Disposition: attachment
<?php echo $attachment; ?>
--PHP-mixed-<?php echo $random_hash; ?>--
<?php
//copy current buffer contents into $message variable and delete current output buffer
$message = ob_get_clean();
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
Thanks already.