Worked on this for a week now, I have read and read and reread! Looking for like one small edit to be up and running!
If someone could take a look at what I have it would be great. I've posted my attachmenttread.class.php file as well as 2 different headers that dont work and one that does. I am nearly positive it is something to do with the headers or the way the messages are laid out but I cant pin point it. With the help of this forum I will post a modded attachmenttread.class.php that has all the threads tweaks and improvements if you guys want.
Eager to hear what my issue is...
This is my attachmenttread.class.php
<?
######################################
#Coded By Jijo Last Update Date[Jan/19/06]
#http://phpclasses.org
#####################################
##########################################################
###################### Class readattachment ###############
class readattachment
{
function getdecodevalue($message,$coding)
{
if ($coding == 0)
{
$message = imap_8bit($message);
}
elseif ($coding == 1)
{
$message = imap_8bit($message);
}
elseif ($coding == 2)
{
$message = imap_binary($message);
}
elseif ($coding == 3)
{
$message=imap_base64($message);
}
elseif ($coding == 4)
{
$message = imap_qprint($message);
}
elseif ($coding == 5)
{
$message = imap_base64($message);
}
return $message;
}
function getdata($host,$login,$password,$filepath,$album,$folder)
{
$mbox = imap_open ($host, $login, $password) or die("can't connect: " . imap_last_error());
$message = array();
$message["attachment"]["type"][0] = "text";
$message["attachment"]["type"][1] = "multipart";
$message["attachment"]["type"][2] = "message";
//$message["attachment"]["type"][3] = "application";
$message["attachment"]["type"][4] = "audio";
$message["attachment"]["type"][5] = "image";
$message["attachment"]["type"][6] = "video";
$message["attachment"]["type"][7] = "other";
for ($jk = 1; $jk <= imap_num_msg($mbox); $jk++)
{
$headerinfo = imap_header($mbox, $jk);
$subject = $headerinfo->Subject;
$matches = array();
if (preg_match('/^=\?[^?]*\?B\?(.*)\?=/m', $subject, $matches))
$subject = base64_decode($matches[1]);
$structure = imap_fetchstructure($mbox, $jk , FT_UID);
$parts = $structure->parts;
$fpos=1;
for($i = 0; $i < count($parts); $i++)
{
$message["pid"][$i] = ($i);
$part = $parts[$i];
if ($part->type == 0) {
$fpos+=1;
continue;
}
if(TRUE)
{
$message["type"][$i] = $message["attachment"]["type"][$part->type] . "/" . strtolower($part->subtype);
$message["subtype"][$i] = strtolower($part->subtype);
$ext=$part->subtype;
if ($part->ifdparameters)
foreach($part->dparameters as $dparam)
if (strtolower($dparam->attribute) == 'filename') $filename = $dparam->value;
if (empty($filename))
if ($part->ifparameters)
foreach($part->parameters as $param)
if (strtolower($param->attribute) == 'name') $filename = $param->value;
if (empty($filename) && $part->ifid)
$filename = trim($part->id, '<>');
if (empty($filename)) $filename = 'nfn' . rand() . '.' . strtolower($part->subtype);
$mege="";
$data="";
$mege = imap_fetchbody($mbox,$jk,$fpos);
$fp=fopen($filepath . $filename,w);
$data=$this->getdecodevalue($mege,$part->type);
fputs($fp,$data);
fclose($fp);
add_picture($album, $folder, $filename, 0, $subject);
$fpos+=1;
}
}
//imap_delete($mbox,$jk);
}
//imap_expunge($mbox);
imap_close($mbox);
}
}
?>
This one is an MMS sent from my phone that DONT work...
Content-Type: multipart/mixed; boundary="----=_Part_3839038_23551565.1203191401046"
Date: Sat, 16 Feb 2008 14:50:01 -0500 [01:50:01 PM CST]
Delivered-To: upload@mysite.com
From: ##########@mms.att.net
Message-ID: <23076156.1203191401047.JavaMail.wluser@alpagw01>
Mime-Version: 1.0
Received:
* (qmail 11936 invoked by uid 399); 16 Feb 2008 19:50:16 -0000
* from unknown (HELO atlmtaow02.cingularme.com) (66.102.165.7) by mail30.opentransfer.com with SMTP; 16 Feb 2008 19:50:16 -0000
* from alpagw01 ([209.183.34.196]) by atlmtaow02.cingularme.com (InterMail vM.6.01.04.00 201-2131-118-20041027) with ESMTP id <20080216195001.KJRN25910.atlmtaow02.cingularme.com@alpagw01> for <Upload@mysite.com>; Sat, 16 Feb 2008 14:50:01 -0500
Return-Path: <##########@mms.att.net>
Subject: Hi
To: Upload@mysite.com
X-Mms-MMS-Version: 18
X-Mms-Message-Type: 0
X-Mms-Transaction-ID: 1203191315704
X-Nokia-Ag-Internal: ; smiltype=true; internaldate=1203191401034
X-Nokia-Ag-Version: 2.0
X-Virus-Scan: Scanned by clamdmail 0.15 (no viruses); Sat, 16 Feb 2008 13:50:18 -0600
Headers: Show Limited Headers
1 unnamed [image/jpeg] 412.38 KB Download Download in .zip Format
This one does NOT work either. It is sent from my blackberry using the email portion.
Content-Type: multipart/mixed; boundary="part109399-boundary-963297514-2110743521"
Date: Sat, 16 Feb 2008 19:47:38 +0000 [01:47:38 PM CST]
Delivered-To: upload@mysite.com
From: me <me@mypersonalemail.com>
Importance: Normal
MIME-Version: 1.0
Message-ID: <157172620-1203191378-cardhu_decombobulator_blackberry.rim.net-1675838995-@bxe145.bisx.prod.on.blackberry>
Received:
* (qmail 11064 invoked by uid 399); 16 Feb 2008 19:49:47 -0000
* from unknown (HELO py-out-1112.google.com) (64.233.166.181) by mail30.opentransfer.com with SMTP; 16 Feb 2008 19:49:47 -0000
* by py-out-1112.google.com with SMTP id f31so1290029pyh.18 for <upload@mysite.com>; Sat, 16 Feb 2008 11:49:44 -0800 (PST)
* by 10.65.191.3 with SMTP id t3mr6971818qbp.0.1203191383615; Sat, 16 Feb 2008 11:49:43 -0800 (PST)
* from bda170-cell02.bisx.prod.on.blackberry ( [216.9.248.90]) by mx.google.com with ESMTPS id e11sm4828930qbc.5.2008.02.16.11.49.39 (version=SSLv3 cipher=RC4-MD5); Sat, 16 Feb 2008 11:49:41 -0800 (PST)
Reply-To: me@mypersonalemail.com
Return-Path:
* <me@mypersonalemail.com>
* <me@mypersonalemail.com>
Sensitivity: Normal
Subject: IMG00379.jpg
To: upload@mysite.com
X-Priority: Normal
X-Virus-Scan: Scanned by clamdmail 0.15 (no viruses); Sat, 16 Feb 2008 13:49:49 -0600
X-rim-org-msg-ref-id: 157172620
Part(s):
2 IMG00379.jpg [image/jpeg] 370 KB Download Download in .zip Format
Download All Attachments (in .zip file) Download All Attachments (in .zip file)
This one is sent from a web based gmail account and DOES work.
Content-Type: multipart/mixed; boundary="----=_Part_2549_4757736.1203189155175"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:references:x-google-sender-auth; bh=MW4h7FaH/QDZmNEpnnDprq49MTgHgw2mpjOSiSEgE8Y=; b=JsevrYpBQneCKNvsbo7D/TjM6def+faaqTa3g+bKd1cwqPmK8EXmAA0t1NOIi+Ujp8a76RFOEuwQCRji+mgDOh+zCTNFh50bYo8GNQNqcPzfTxuRN0ZEqfY8tT7Iu9yrGv4pHdjXwXLBo0/GreBk4NAYjKvywd1qT9VyPyGWPBQ=
Date: Sat, 16 Feb 2008 14:12:35 -0500 [01:12:35 PM CST]
Delivered-To: upload@mysite.com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:references:x-google-sender-auth; b=WRg7tT6AVbkr4cjb7eY2suYl3WsSE07N6GbcwfeABWvkTmOfmjm+96wpKBtwOngIafPoCLlbdrydCTfz5+cqKmpDNcVKZxJw/mCE8VPHEvStU2jLX8hMg1sBVGJPsyxiwnrVCEI6f/WQgNuoLOZMf8/mAjKqH5CWugVVjXv3uJs=
From: me <me@mypersonalemail.com>
In-Reply-To: <7a5fa6a0802160955q4e263acexe745c91693ddc257@mail.gmail.com>
MIME-Version: 1.0
Message-ID: <7a5fa6a0802161112h16409a3epd16c446d67689843@mail.gmail.com>
Received:
* (qmail 5244 invoked by uid 399); 16 Feb 2008 19:12:39 -0000
* from unknown (HELO wa-out-1112.google.com) (209.85.146.180) by mail30.opentransfer.com with SMTP; 16 Feb 2008 19:12:39 -0000
* by wa-out-1112.google.com with SMTP id j32so1747450waf.19 for <upload@mysite.com>; Sat, 16 Feb 2008 11:12:35 -0800 (PST)
* by 10.114.161.11 with SMTP id j11mr767941wae.127.1203189155175; Sat, 16 Feb 2008 11:12:35 -0800 (PST)
* by 10.114.151.7 with HTTP; Sat, 16 Feb 2008 11:12:35 -0800 (PST)
References: <7a5fa6a0802160954t3292a7bdvff03f71e33fa1a25@mail.gmail.com> <7a5fa6a0802160955q4e263acexe745c91693ddc257@mail.gmail.com>
Return-Path: <me@mypersonalemail.com>
Sender: me@mypersonalemail.com
Subject: Fwd:
To: upload@mysite.com
X-Google-Sender-Auth: 652bd123b537d236
X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on localhost
X-Spam-Level:
X-Spam-Status: No, score=0.5 required=5.0 tests=HTML_40_50,HTML_MESSAGE autolearn=disabled version=3.0.2
X-Virus-Scan: Scanned by clamdmail 0.15 (no viruses); Sat, 16 Feb 2008 13:12:40 -0600
Part(s):
2 flight.jpg [image/jpeg] 53 KB Download