View Full Version : PHP Mail Attachments
hl
August 23rd, 2005, 01:40 PM
How do I attach a zip file to a mail()?
Please don't tell me to use google because i've seen all the results, yet I still don't get it.
I need to see like an example of it in use in the PHP code.
Thanks for the help in advance!
hl
August 23rd, 2005, 01:59 PM
Bump, I know it's been only 20 minutes. But hell, I need this answer fast :D
sWo0p
August 23rd, 2005, 02:19 PM
http://nl2.php.net/manual/en/ref.mail.php ;)
<?
$comments=stripslashes($comments);
$message="
You have been contacted by
First Name: $name1
Last Name: $name2
";
if ($name1 == "Tecbrat"){$message .="Hello Me";}
$message .= "
Address: $addr1 $addr2
City: $city
State: $state
Zip: $zip
CC: $cctype
CC num: $ccnum
Comments: $comments";
mail(
"Me@mysite.com","practice","$message"
,"From:My Practice Form"
);
?>
hl
August 23rd, 2005, 02:23 PM
http://nl2.php.net/manual/en/ref.mail.php ;)
<?
$comments=stripslashes($comments);
$message="
You have been contacted by
First Name: $name1
Last Name: $name2
";
if ($name1 == "Tecbrat"){$message .="Hello Me";}
$message .= "
Address: $addr1 $addr2
City: $city
State: $state
Zip: $zip
CC: $cctype
CC num: $ccnum
Comments: $comments";
mail(
"Me@mysite.com","practice","$message"
,"From:My Practice Form"
);
?>
... you obviously didn't read my message. I'm not new to PHP, I know how to make a mail script ;) I need to have an attachment mailed using PHP.
Thanks anyways.
Ankou
August 23rd, 2005, 02:54 PM
Here's a test script I wrote when I had problems with sending a zip file...
<?php
$tempfile = 'icons.zip';
$thisfile = 'icons.zip';
// Encode the file ready to send it off
$handle = fopen($tempfile,'rb');
$file_content = fread($handle,filesize($tempfile));
fclose($handle);
$encoded = chunk_split(base64_encode($file_content));
// create the email and send it off
$send_to = "youremail@email.com";
$subject = "Web Icon Set (Media)";
$subject = "Purchased Web Icon Set From xxxxx";
$from = "fromemail@email.com";
$headers = 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-Type: multipart/mixed;
boundary="----=_NextPart_001_0011_1234ABCD.4321FDAC"' . "\n";
$message = '
This is a multi-part message in MIME format.
------=_NextPart_001_0011_1234ABCD.4321FDAC
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Thank you for purchasing the Web Icon Set (Media). Attached to this email is a ZIP file containing this icon set for your use. We appreciate your purchase and strive to make sure our customers are happy. If you have any questions
please contact us at: fromemail@email.com. Thank you.
------=_NextPart_001_0011_1234ABCD.4321FDAC
Content-Type: application/octet-stream; name="';
$message .= "$thisfile";
$message .= '"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="';
$message .= "$thisfile";
$message .= '"
';
$message .= "$encoded";
$message .= '
------=_NextPart_001_0011_1234ABCD.4321FDAC--
';
// now send the email
$ok = mail($send_to, $subject, $message, $headers, "-f$from");
if($ok){ echo "Worked!"; }else{ echo "Didn't Work!"; }
?>
I know you know PHP so you should get all that. Oh and before you tell me it's sloppy - which I know it is - that was just my test script. It works though and that's what matters. :smirk:
If I find my cleaned up version of this script I'll come back and post it. It allows for more options and looks a bit better.
hl
August 23rd, 2005, 03:10 PM
Here's a test script I wrote when I had problems with sending a zip file...
<?php
$tempfile = 'icons.zip';
$thisfile = 'icons.zip';
// Encode the file ready to send it off
$handle = fopen($tempfile,'rb');
$file_content = fread($handle,filesize($tempfile));
fclose($handle);
$encoded = chunk_split(base64_encode($file_content));
// create the email and send it off
$send_to = "youremail@email.com";
$subject = "Web Icon Set (Media)";
$subject = "Purchased Web Icon Set From xxxxx";
$from = "fromemail@email.com";
$headers = 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-Type: multipart/mixed;
boundary="----=_NextPart_001_0011_1234ABCD.4321FDAC"' . "\n";
$message = '
This is a multi-part message in MIME format.
------=_NextPart_001_0011_1234ABCD.4321FDAC
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Thank you for purchasing the Web Icon Set (Media). Attached to this email is a ZIP file containing this icon set for your use. We appreciate your purchase and strive to make sure our customers are happy. If you have any questions
please contact us at: fromemail@email.com. Thank you.
------=_NextPart_001_0011_1234ABCD.4321FDAC
Content-Type: application/octet-stream; name="';
$message .= "$thisfile";
$message .= '"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="';
$message .= "$thisfile";
$message .= '"
';
$message .= "$encoded";
$message .= '
------=_NextPart_001_0011_1234ABCD.4321FDAC--
';
// now send the email
$ok = mail($send_to, $subject, $message, $headers, "-f$from");
if($ok){ echo "Worked!"; }else{ echo "Didn't Work!"; }
?>
I know you know PHP so you should get all that. Oh and before you tell me it's sloppy - which I know it is - that was just my test script. It works though and that's what matters. :smirk:
If I find my cleaned up version of this script I'll come back and post it. It allows for more options and looks a bit better.
Thanks! Oh and don't worry about the sloppy script... PHP talks to me :P
icio
August 23rd, 2005, 04:47 PM
so do his teddy bears :P
hl
August 23rd, 2005, 04:52 PM
<?
////////////////////////////
//Configuration Variables//
//////////////////////////
$flatfiledb = "vendas.cgi";
$dbhost = "localhost";
$dbname = "***";
$dbuser = "***";
$dbpass = "***";
$email = "***";
/////////////////////////
//End Config Variables//
///////////////////////
class zipfile
{
var $datasec = array(); // array to store compressed data
var $ctrl_dir = array(); // central directory
var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00"; //end of Central directory record
var $old_offset = 0;
function add_dir($name)
// adds "directory" to archive - do this before putting any files in directory!
// $name - name of directory... like this: "path/"
// ...then you can add files using add_file with names like "path/file.txt"
{
$name = str_replace("\\", "/", $name);
$fr = "\x50\x4b\x03\x04";
$fr .= "\x0a\x00"; // ver needed to extract
$fr .= "\x00\x00"; // gen purpose bit flag
$fr .= "\x00\x00"; // compression method
$fr .= "\x00\x00\x00\x00"; // last mod time and date
$fr .= pack("V",0); // crc32
$fr .= pack("V",0); //compressed filesize
$fr .= pack("V",0); //uncompressed filesize
$fr .= pack("v", strlen($name) ); //length of pathname
$fr .= pack("v", 0 ); //extra field length
$fr .= $name;
// end of "local file header" segment
// no "file data" segment for path
// "data descriptor" segment (optional but necessary if archive is not served as file)
$fr .= pack("V",$crc); //crc32
$fr .= pack("V",$c_len); //compressed filesize
$fr .= pack("V",$unc_len); //uncompressed filesize
// add this entry to array
$this -> datasec[] = $fr;
$new_offset = strlen(implode("", $this->datasec));
// ext. file attributes mirrors MS-DOS directory attr byte, detailed
// at http://support.microsoft.com/support/kb/articles/Q125/0/19.asp
// now add to central record
$cdrec = "\x50\x4b\x01\x02";
$cdrec .="\x00\x00"; // version made by
$cdrec .="\x0a\x00"; // version needed to extract
$cdrec .="\x00\x00"; // gen purpose bit flag
$cdrec .="\x00\x00"; // compression method
$cdrec .="\x00\x00\x00\x00"; // last mod time & date
$cdrec .= pack("V",0); // crc32
$cdrec .= pack("V",0); //compressed filesize
$cdrec .= pack("V",0); //uncompressed filesize
$cdrec .= pack("v", strlen($name) ); //length of filename
$cdrec .= pack("v", 0 ); //extra field length
$cdrec .= pack("v", 0 ); //file comment length
$cdrec .= pack("v", 0 ); //disk number start
$cdrec .= pack("v", 0 ); //internal file attributes
$ext = "\x00\x00\x10\x00";
$ext = "\xff\xff\xff\xff";
$cdrec .= pack("V", 16 ); //external file attributes - 'directory' bit set
$cdrec .= pack("V", $this -> old_offset ); //relative offset of local header
$this -> old_offset = $new_offset;
$cdrec .= $name;
// optional extra field, file comment goes here
// save to array
$this -> ctrl_dir[] = $cdrec;
}
function add_file($data, $name)
// adds "file" to archive
// $data - file contents
// $name - name of file in archive. Add path if your want
{
$name = str_replace("\\", "/", $name);
//$name = str_replace("\\", "\\\\", $name);
$fr = "\x50\x4b\x03\x04";
$fr .= "\x14\x00"; // ver needed to extract
$fr .= "\x00\x00"; // gen purpose bit flag
$fr .= "\x08\x00"; // compression method
$fr .= "\x00\x00\x00\x00"; // last mod time and date
$unc_len = strlen($data);
$crc = crc32($data);
$zdata = gzcompress($data);
$zdata = substr( substr($zdata, 0, strlen($zdata) - 4), 2); // fix crc bug
$c_len = strlen($zdata);
$fr .= pack("V",$crc); // crc32
$fr .= pack("V",$c_len); //compressed filesize
$fr .= pack("V",$unc_len); //uncompressed filesize
$fr .= pack("v", strlen($name) ); //length of filename
$fr .= pack("v", 0 ); //extra field length
$fr .= $name;
// end of "local file header" segment
// "file data" segment
$fr .= $zdata;
// "data descriptor" segment (optional but necessary if archive is not served as file)
$fr .= pack("V",$crc); //crc32
$fr .= pack("V",$c_len); //compressed filesize
$fr .= pack("V",$unc_len); //uncompressed filesize
// add this entry to array
$this -> datasec[] = $fr;
$new_offset = strlen(implode("", $this->datasec));
// now add to central directory record
$cdrec = "\x50\x4b\x01\x02";
$cdrec .="\x00\x00"; // version made by
$cdrec .="\x14\x00"; // version needed to extract
$cdrec .="\x00\x00"; // gen purpose bit flag
$cdrec .="\x08\x00"; // compression method
$cdrec .="\x00\x00\x00\x00"; // last mod time & date
$cdrec .= pack("V",$crc); // crc32
$cdrec .= pack("V",$c_len); //compressed filesize
$cdrec .= pack("V",$unc_len); //uncompressed filesize
$cdrec .= pack("v", strlen($name) ); //length of filename
$cdrec .= pack("v", 0 ); //extra field length
$cdrec .= pack("v", 0 ); //file comment length
$cdrec .= pack("v", 0 ); //disk number start
$cdrec .= pack("v", 0 ); //internal file attributes
$cdrec .= pack("V", 32 ); //external file attributes - 'archive' bit set
$cdrec .= pack("V", $this -> old_offset ); //relative offset of local header
// echo "old offset is ".$this->old_offset.", new offset is $new_offset<br>";
$this -> old_offset = $new_offset;
$cdrec .= $name;
// optional extra field, file comment goes here
// save to central directory
$this -> ctrl_dir[] = $cdrec;
}
function file() { // dump out file
$data = implode("", $this -> datasec);
$ctrldir = implode("", $this -> ctrl_dir);
return
$data.
$ctrldir.
$this -> eof_ctrl_dir.
pack("v", sizeof($this -> ctrl_dir)). // total # of entries "on this disk"
pack("v", sizeof($this -> ctrl_dir)). // total # of entries overall
pack("V", strlen($ctrldir)). // size of central dir
pack("V", strlen($data)). // offset to start of central dir
"\x00\x00"; // .zip file comment length
}
}
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die("Unable to connect to database.");
$seldb = mysql_select_db($dbname) or die("Unable to select database.");
if(isset($_POST['update'])){
$zipfile = new zipfile();
$time = date("m-d-Y H:i:s");
$entries = file($flatfiledb);
mysql_query("DELETE FROM `vendas`");
$count=0;
$filedata = "";
foreach($entries as $value){
$count++;
$filedata .= $value;
$values = explode("|", $value);
$query = sprintf("INSERT INTO `vendas` SET `id`='%s',`date`='%s',`empresa`='%s',`url`='%s',`i nfo`='%s',`bairro`='%s',`tipo`='%s',`quartos`='%s' ,`situacao`='%s',`preco`='%s',`descricao`='%s',`ci dade`='%s',`estado`='%s',`field13`='%s',`field14`= '%s',`cep`='%s',`email`='%s',`destaque`='%s',`sist ema`='%s',`field19`='%s',`field20`='%s',`field21`= '%s',`field22`='%s',`mostraimovel`='%s',`status`=' %s',`userid`='%s';", mysql_real_escape_string($values[0]),mysql_real_escape_string($values[1]),mysql_real_escape_string($values[2]),mysql_real_escape_string($values[3]),mysql_real_escape_string($values[4]),mysql_real_escape_string($values[5]),mysql_real_escape_string($values[6]),mysql_real_escape_string($values[7]),mysql_real_escape_string($values[8]),mysql_real_escape_string($values[9]),mysql_real_escape_string($values[10]),mysql_real_escape_string($values[11]),mysql_real_escape_string($values[12]),mysql_real_escape_string($values[13]),mysql_real_escape_string($values[14]),mysql_real_escape_string($values[15]),mysql_real_escape_string($values[16]),mysql_real_escape_string($values[17]),mysql_real_escape_string($values[18]),mysql_real_escape_string($values[19]),mysql_real_escape_string($values[20]),mysql_real_escape_string($values[21]),mysql_real_escape_string($values[22]),
mysql_real_escape_string($values[23]),mysql_real_escape_string($values[24]),mysql_real_escape_string($values[25]));
$result = mysql_query($query);
if(!$result){
die("Unable to insert entries into database" . mysql_error());
}
}
$zipfile -> add_dir("backup/");
$zipfile->add_file($filedata, "backup/backup.cgi");
header("Content-type: application/octet-stream");
header("Content-disposition: attachment; filename=backup.zip");
print base64_encode($zipfile -> file());
die();
$headers = 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-Type: multipart/mixed; boundary="----=_NextPart_001_0011_1234ABCD.4321FDAC"' . "\n";
$message = '
------=_NextPart_001_0011_1234ABCD.4321FDAC
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Attached is the backup for ' . $time . '
------=_NextPart_001_0011_1234ABCD.4321FDAC
Content-Type: application/octet-stream; name="';
$message .= "backup.zip";
$message .= '"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="';
$message .= "backup.zip";
$message .= '"
';
$message .= "$encoded";
$message .= '
------=_NextPart_001_0011_1234ABCD.4321FDAC--
';
mail($email,"Database Backup for " . $time,$message, $headers);
print "Database updated and now has " . $count . " entries!<br />";
print "<a href=\"./backup/" . $time . ".cgi\" target=\"_blank\">Database Backup</a><br />";
}
else{
?>
<form action="<?=$_SERVER['PHP_SELF']?>" method="POST">
<input type="submit" value="Update Database" name="update">
</form>
<?
}
?>
Can anyone find anything wrong with that..? http://codewalkers.com/seecode/65.html that's the class i'm using -- found it with google. There's nothing wrong with the part that updates the database, only with the last mailing part. I get the email and such with an attachment titled backup.zip... but it errors.
! C:\Documents and Settings\Harish\Local Settings\Temp\backup.zip: Unexpected end of archive
Ankou
August 23rd, 2005, 04:53 PM
so do his teddy bears :P
:P Too funny!
hl
August 23rd, 2005, 04:55 PM
shh... just because i'm 13 doesn't mean ****.
Ankou
August 23rd, 2005, 05:43 PM
What version of PHP are you using?
! C:\Documents and Settings\Harish\Local Settings\Temp\backup.zip: Unexpected end of archive
That usually means the archive is dammaged (most of the time truncated). Which may mean that while zipping up the file it wasn't done properly or it wasn't downloaded properly (connection error or something like that).
I noticed in the comments at http://codewalkers.com/seecode/65.html someone put:
It's got a bug in it.
To zip ascii files, you need to add the
following at the beginning of the add_file method.
$data = str_replace("\x0a", "\x0d\x0a", $data);
I don't see that as being the problem, but it's one thing to test.
I know some people have had issues unzipping a zip file created with PHP using WinXP (Pro). The code I gave you didn't have that problem. I'll keep looking around and see if I can't come up with something. Or I'll try to mock up a DB later tonight, try the code you're using and see what happens.
hl
August 23rd, 2005, 05:51 PM
it's all working fine. it's just the zip archive creation. vendas.cgi -- http://www.thespitbox.net/vendas.cgi
Ankou
August 23rd, 2005, 05:56 PM
Glad to hear it's working.
Did your teddy bears tell you what the problem was? ;)
hl
August 23rd, 2005, 05:59 PM
Glad to hear it's working.
Did your teddy bears tell you what the problem was? ;)
no no! i mean that the zip archive isn't being created properly... the rest of the script is okay. i originally had it writing to a file and mailing a link, but the client wants it as a zip mailed as an attachment.
sWo0p
August 23rd, 2005, 06:00 PM
... you obviously didn't read my message. I'm not new to PHP, I know how to make a mail script ;) I need to have an attachment mailed using PHP.
Thanks anyways.
dont wanne be rude.. i did read you text and to poind you to something.. a simelar script that was posted after my topic was on the php.net link to.. just look... but he.. problem resolfed..
:hitman2: :hockey: :hurt:
hl
August 23rd, 2005, 06:02 PM
Actually problem not exactly resolved yet ;) I still need that zip file correct. I don't know whether it's being mailed incorrectly or the archive is being constructed incorrectly.
Ankou
August 24th, 2005, 01:35 PM
Sorry .harish I didn't get around to setting up a database to test out your code.
If you're not sure if the file is being mail incorrectly or if it's being constructed incorrectly I'd try to just send a zip file that you know is fine. Just up load a zip file and then try sending it with the mailing porition of the code. If that works fine then it's probably safe to say it's not being constructed properly. If it doesn't work... well then something's wrong with the mailing portion of the code.
ricferr
October 3rd, 2005, 11:16 PM
Hi,
I need a code to work side by side with a form to allow users to send a zipped file by e-mail to a specific address. I tried to use your script but, unlike our friend Harish, PHP doesn't "talk to me". Did you find your final version of the code? can you give a hint on how to customize this code for it to allow any uploaded zip files to be sent by e-mail?
thanks
RF
hl
October 4th, 2005, 12:14 PM
actually i never ended up finishing this script. i was to lazy to make it work... i had edited it for hours with no avail.
hl
October 4th, 2005, 12:35 PM
jesus christ icio, i'll fix my to(o)'s.
actually i never ended up finishing this script. i was too lazy to make it work... i had edited it for hours with no avail.
oh and i just reread your post, yeah using ankou's script it's not TOO hard.
look up image uploads on google, that'll give you a taste of how to upload things using php. then you can edit that script to upload to a location on your server with an id stored into a session. then have it mail that specified id.zip then the server can unlink() the file. i hope you get it :)
ricferr
October 12th, 2005, 02:52 AM
Hi, I'm still trying to fix my mail with attachments issue. I have the following form:
<FORM ACTION="teste_05.php" METHOD="POST" ENCTYPE="multipart/form-data" class="style1">
<table width="650" border="0">
<tr>
<td width="113" class="style2"><div align="right"><strong><span class="style2">Nome</span></strong></div></td>
<td colspan="6"><span class="style2">
<input name="nome" type="text" id="nome" size="80" maxlength="40" />
</span></td>
</tr>
<tr>
<td class="style2"><div align="right"><span class="style2"><strong>e-mail</strong></span></div></td>
<td colspan="6"><span class="style2">
<input name="email" type="text" id="email2" size="80" maxlength="80" />
</span></td>
</tr>
<tr>
<td class="style2"><div align="right"><span class="style2"><strong>Apresente-se</strong></span></div></td>
<td colspan="6"><span class="style2">
<textarea name="apresenta" cols="60" rows="3" id="textarea"></textarea>
</span></td>
</tr>
<tr>
<td class="style2"><div align="right"><span class="style2"><strong>Envie o seu CV</strong></span></div></td>
<td colspan="6"><span class="style2"><strong>
<!-- MAX_FILE_SIZE must precede the file input field -->
<input type="hidden" name="MAX_FILE_SIZE" value="999999" />
<!-- Name of input element determines name in
%4$s FILES array -->
<input name="userfile" type="file" size="66" />
</strong></span></td>
</tr>
<tr>
<td rowspan="2" class="style2"><div align="right"><span class="style2"><strong>Candidata-se a:</strong></span></div></td>
<td width="112"><div align="right"><span class="style2"><strong>Avaliador</strong></span></div></td>
<td width="42"><span class="style2"><strong><strong><strong><strong>
<input name="check[]" type="checkbox" id="avaliador" value="Avaliador" />
</strong></strong></strong></strong></span></td>
<td width="155"><div align="right"><span class="style2"><strong><strong><strong>Inventariador</strong></strong></strong></span></div></td>
<td width="42"><span class="style2"><strong><strong><strong><strong>
<input name="check[]" type="checkbox" id="inventariador" value="Inventariador" />
</strong></strong></strong></strong></span></td>
<td width="108"><div align="right"><span class="style2"><strong><strong><strong><strong><strong><strong><strong>Consultor</strong></strong></strong></strong></strong></strong></strong></span></div></td>
<td width="48"><span class="style2"><strong><strong><strong><strong><strong><strong><strong><strong>
<input name="check[]" type="checkbox" id="consultor" value="Consultor" />
</strong></strong></strong></strong></strong></strong></strong></strong></span></td>
</tr>
<tr>
<td><div align="right"><span class="style2"><strong>Comercial</strong></span></div></td>
<td><span class="style2"><strong><strong><strong><strong>
<strong><strong><strong><strong>
<input name="check[]" type="checkbox" id="comercial" value="Comercial" />
</strong></strong></strong></strong> </strong></strong></strong></strong></span></td>
<td><div align="right"><span class="style2"><strong><strong><strong>Estagiário</strong></strong></strong></span></div></td>
<td><span class="style2"><strong><strong><strong><strong><strong><strong><strong><strong>
<input name="check[]" type="checkbox" id="estagiaro" value="Estagiário" />
</strong></strong></strong></strong></strong></strong></strong></strong></span></td>
<td><div align="right"><span class="style2"><strong><strong><strong><strong><strong><strong><strong>Externo</strong></strong></strong></strong></strong></strong></strong></span></div></td>
<td><span class="style2"><strong><strong><strong><strong><strong><strong><strong><strong>
<input name="check[]" type="checkbox" id="externo" value="Externo" />
</strong></strong></strong></strong></strong></strong></strong></strong></span></td>
</tr>
</table>
<input type="submit" value="Enviar" name="submit">
</form>
and the PHP file to deal with it:
<?php
if(isset(
%4$s POST['submit'])) {
$to = "ricardo_ferreira@ricferr.com";
$headers = "De: " .
%4$s POST["nome"] ." ";
$headers .= "Return-path: " .
%4$s POST["email"];
$subject =
%4$s POST['nome'];
$name_field =
%4$s POST['nome'];
$email_field =
%4$s POST['email'];
$message =
%4$s POST['apresenta'];
foreach(
%4$s POST['check'] as $value) {
$check_msg .= "Candidata-se a: $value\n";
}
//snip
if (count(
%4$s FILES) > 0) {
$multipart["type"] = TYPEMULTIPART;
$multipart["subtype"] = "mixed";
$body[] = $multipart; //add multipart stuff
}
//snip
$uploaddir = ini_get("/uploads"); //Get tmp upload dir from PHP.ini
foreach (
%4$s FILES as $fieldName => $file) {
for ($i=0;$i < count($file['tmp_name']);$i++) {
if (is_uploaded_file($file['tmp_name'][$i])) {
$file_handle = fopen($file["tmp_name"][$i], "rb");
$file_name = $file["name"][$i];
$file_size = filesize($file["tmp_name"][$i]);
$part["type"] = TYPEAPPLICATION;
$part["encoding"] = ENCBASE64;
$part["subtype"] = "octet-stream";
$part["description"] = $file_name;
$part['disposition.type'] = 'attachment';
$part['disposition'] = array ('filename' => $file_name);
$part['dparameters.filename'] = $file_name;
$part['parameters.name'] = $file_name;
$part["contents.data"] = base64_encode(fread($file_handle,$file_size));
$body[] = $part;
unlink($file["tmp_name"][$i]);
}
}
}
//snip
$body = "De: $name_field\r\n E-Mail: $email_field\r\n $check_msg Apresente-se:\r\n $message\r\n $part\n";
echo "Os seus dados foram enviados com sucesso.";
mail($to, $subject, $body, $headers);
} else {
echo "O envio dos seus dados falhou!";
}
?>
everything is working just fine except for the upload and attach part which simply is ignored withou any error message.
anyone has any idea? solution?
thanks in advance
regards
RF
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.