Ask a Question related to PHP Development, Design and Development.
-
nic den #1
copy Attachement from Email on server (files copied are not valid)
Hi,
I'm getting emails from an address trough a script and I want to copy the
attached files on the server. I can get the files and copy them on the
server (trough the function below) BUT the files are not valid (images
cannot be displayed)
how can I solve this?
------------------------------------------
function get_attachments($mbox,$msgno){
$o = imap_fetchstructure($mbox, $msgno);
$dir = "C:/AppServ/www/getinfo/fileadmin/testmail/"; // TEST
if ($o->type == 1 || ($o->ifsubtype == 1 && $o->subtype == 'MIXED')) {
$parts = $o->parts;
$i=1;
$retour = array();
foreach($parts as $part) {
$fname = '';
if (!isset($part->encoding) && $part->encoding == 3) {
$str = imap_base64(trim(@imap_fetchbody($mbox, $msgno,$i)));
} else {
$str = imap_fetchbody($mbox, $msgno,$i);
}
if ($part->ifdparameters == 1) {
$dparams = $part->dparameters;
foreach($dparams as $dparam) {
if ($dparam->attribute == "FILENAME") {
$fname = $dparam->value;
}
}
}
if ($fname=="") {
if ($part->ifparameters == 1) {
$params = $part->parameters;
foreach($params as $param) {
if ($param->attribute == "NAME") {
$fname = $param->value;
}
}
}
}
if ($fname=="") {$fname = "part$i";}
$fp = fopen($dir.$fname,"wb");
if (!$fp) { return FALSE; }
fwrite($fp,$str);
fclose($fp);
$i++;
}
return $retour;
} else {
return "no attach";
}
}
nic den Guest
-
i m using asp to copy a file but its not copied
hi i m using scripting.filesystemobject to copy a file from server directory with another name, but i m not able to do it whenever i call that... -
Offering music files that cannot be copied
Hi, I want to make available a few music tracks on the website I am building but I don?t want the user to be able to copy the files. What is the... -
CDOSYS - IF NOT A VALID EMAIL
with the cdosys script i have, it works fine if you have a dim email that is an email address, but if a user were to leave that field blank, or not... -
No files copied using Copy Project
Christopher, Double check that you are doing everything as outlined in the following kb article... -
compiled DLL not copied to the server bin folder automatically
I'm working on several ASP.NET projects at the same time. I have a separate web server and each has its own solution folder on my local PC. The... -
Re: copy Attachement from Email on server (files copied are not valid)
"nic den" <ndengler@yahoo.fr> wrote in message
news:3f587c11$1@news.swissonline.ch...<snip users untested code>> Hi,
> I'm getting emails from an address trough a script and I want to copy the
> attached files on the server. I can get the files and copy them on the
> server (trough the function below) BUT the files are not valid (images
> cannot be displayed)
>
> how can I solve this?
Aren't e-mail attachments Base64 encoded?
Guest



Reply With Quote

