473,800 Members | 2,483 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP IMAP Attachment issue

I have a bit of code that when using POP in the imap_open connect
string it will return the filenames of the attachments, but when using
IMAP it does not.

Been racking my brain over this for a week now and decided to ask in
here for some help.

CODE:
// open mailbox
$inbox = @imap_open("{" . $SESSION_EMAILS ERVER .
"/imap:143/notls/novalidate-cert}", $SESSION_USERNA ME,
$SESSION_PASSWO RD) or die("Could not open Mailbox - try again later!");

// parse message body
function parse($structur e)
{
global $type;
global $encoding;
// create an array to hold message sections
$ret = array();
// split structure into parts
$parts = $structure->parts;

for($x=0; $x<sizeof($part s); $x++)
{
$ret[$x]["pid"] = ($x+1);
$this = $parts[$x];
// default to text
if ($this->type == "") { $this->type = 0; }
$ret[$x]["type"] = $type[$this->type] . "/" .
strtolower($thi s->subtype);
// default to 7bit
if ($this->encoding == "") { $this->encoding = 0; }
$ret[$x]["encoding"] = $encoding[$this->encoding];
$ret[$x]["size"] = strtolower($thi s->bytes);
$ret[$x]["dispositio n"] = strtolower($thi s->disposition) ;
if (strtolower($th is->disposition) == "attachment ")
{
$params = $this->dparameters;
foreach ($params as $p)
{
if($p->attribute == "FILENAME")
{
$ret[$x]["name"] = $p->value;
break;
}
}
}
}
return $ret;
}

// iterate through object returned by parse()
// create a new array holding information only on message attachments
function get_attachments ($arr)
{
for($x=0; $x<sizeof($arr) ; $x++)
{
if($arr[$x]["dispositio n"] == "attachment ")
{
$ret[] = $arr[$x];
}
}
return $ret;
}

// get message headers and structure
$headers = imap_header($in box, $id);
$structure = imap_fetchstruc ture($inbox, $id);

// if multipart, parse
if(sizeof($stru cture->parts) 1)
{
$sections = parse($structur e);
$attachments = get_attachments ($sections);
}

// if attachments exist
if (is_array($atta chments))
{
// display as list
for($x=0; $x<sizeof($atta chments); $x++)
{
echo "<li><a href=download.p hp?id=$id&pid=" . $attachments[$x]["pid"]
.. ">" . $attachments[$x]["name"] . " (" .
ceil($attachmen ts[$x]["size"]/1024) . " KB)</a>";
}
}

Any help is greatly appreciated. TIA
slim

Aug 4 '06 #1
0 2215

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3285
by: Fabian Müller | last post by:
Hello, I would like to access (open) my remote IMAP Mailbox with the imap_open() function in PHP Version 5.0.4. The Mailbox is located at the german provider freenet.de. The imap_open() function does not produce an error message as you can see below. But when I call the imap_headers() function the warning message mentioned in the subject as well as below is returned.
0
4001
by: dekoffie | last post by:
Hello there, I'm trying to create a connection with an IMAP server which is secured through SSL. I can get the connection just fine, and I get a first respone from the server. But then I send out my login string, and it does not seem to arrive at the server, because I don't get an answer returned! After some time, I receive a message from the server saying that I've been idle for too long, and then the connection gets closed.. But why...
2
1434
by: comp.lang.php | last post by:
Hi all, I am having a mail client script, which will read and send mail to mail server, using IMAP. When i am sending mail with attachment through forwarding, the attachment is not getting attached correctly, Plz any one can help me to come out of the problem. Note : I am using PHP 4.3.10 + IMAP + Apache +Zend Engine v1.3.0 Thanks in advance
4
9756
by: elyob | last post by:
Hi, I'm looking to setup an email system that will log into a catchall account, read to addresses and forward them to a different email address stored in a MySQL table. I may also allow the users to store these emails in their own accounts at a future date. I've got the IMAP checking etc etc working just fine. However this will be more troublesome if someone includes an attachment. Firstly, the imap_body($mbox,$num) chucks out loads of...
0
1129
by: Kevin F | last post by:
Sorry to repost... but 4am didn't get much responses. I've been trying to implement this script, it polls an IMAP inbox for unread messages and displays the sender and subject in a scrollable window using Tkinter. However, when I try to change the search parameters on line 55 from 'unread' (UNSEEN) to 'read' (SEEN), the tkinter window doesn't even pop up anymore. Any idea how to change the parameters of this program and yet still keep...
2
7580
by: J Huntley Palmer | last post by:
I am having a horrific time integrating uw-imap's c-client for imap support in php. The problem is a whole bunch of "Text relocation remains referenced against symbol" errors during linking. Any help appreciated! The ordeal is a follows I am using Solaris 10 with php5.1.1. GCC:
1
2227
by: nitinpatel1117 | last post by:
Hi, i'm using php's imap extension to read emails from a mailbox. My php script has been working fine and i'm pretty sure that there is nothing wrong with it. here is extracts from my code $mbox = imap_open ($host, $login, $password) or die("can't connect: " . imap_last_error()); $message_count = imap_num_msg($mbox);
3
4841
by: kpfunf | last post by:
I have the following code that works in accessing my personal folder inbox and subfolders. Option Explicit Sub SaveAttachmentsToFolder() On Error GoTo SaveAttachmentsToFolder_err ' Declare variables Dim ns As NameSpace Dim Inbox As MAPIFolder Dim SubFolder As MAPIFolder Dim SubSubFolder As MAPIFolder
1
1279
by: kathiresan | last post by:
Hi I'm trying a windows service that fetches the contents of the mails from my inbox and saves them in a database using IMAP protocol. I've fetched the contents of the mail body using the IMAP command "1 UID FETCH 756 BODY\r\n", where 756 is message UID. How can I fetch the attachments so that i can save the attachments in a specific location and i can use them later. I've tried a lot to find this but i couldn't get. Few articles gave me...
0
9695
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9555
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10514
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10260
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10042
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9099
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7588
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5479
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4156
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.