473,322 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

unsupported body type in imap

111 100+
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

[PHP]$mbox = imap_open ($host, $login, $password) or die("can't connect: " . imap_last_error());
$message_count = imap_num_msg($mbox);

for ($jk = $message_count; ($message_count-6) <= $jk; $jk--)
{
$structure = imap_fetchstructure($mbox, $jk , FT_UID);
$parts = $structure->parts;

for($i = 1; $i < count($parts); $i++)
{
$part = $parts[$i];

if($part->disposition == "ATTACHMENT")
{
// some more code here
}
}
}[/PHP]


Basically the code above is meant to read attachments from emails in a mailbox and save the attached files in the current working directory of the script that is running this code.

This is done by getting the

[PHP]$part->type;[/PHP]
of the email to identify the primary body type of the attached file and then read accordingly.

The primary body type is meant to be between 0 and 7, (imap_fetchstructure ), however i'm getting a primary body type of 9, which is totally messing things up becuase i can't seem to read this file successfully.


Also when reading emails, we are supposed to ignore the first element of the array. i.e in the above code

[PHP]$parts[0];[/PHP]
is meant to be ignored and we should start reading from

[PHP]$parts[1];[/PHP]

however in the email that i'm getting with the weird primary body type the attachment seems to be in the
[PHP]$parts[0];[/PHP]
element of the array, which also seems odd.


The attachmenat is meant to be a (.csv) file, and i can open the attachment using outlook 2003, therefore, i know that the attached file is not corrupted and is properly intact.
Does anyone know why i would recieve such a primary body type, or experienced this before, and know of any way that i can get around this so that i can read the attached file.

any help would be great.
Dec 10 '07 #1
1 2202
pbmods
5,821 Expert 4TB
Heya, Nitin.

Check out the first comment on the imap_fetchstructure() page.
Dec 23 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Joachim Smit | last post by:
Is it possible to extract the email-body from a IMAP-mail-file ? The function 'imap_body()' expects that I'm connected to an IMAP-server, but I'm not. I just have the file. So I'm looking for...
1
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()...
6
by: DJ Craig | last post by:
I keep getting this error: Fatal error: Unsupported operand types in /usr/local/etc/httpd/htdocs/djtricities/kat/bpmchart/chart.php on line 58 I've looked for hours for some type of error, and...
0
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...
2
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....
1
by: [ Nicola ] | last post by:
Using imap i must zap through emails in my email address, then saving part of the message (the main body that is). Question is, how am i supposed to read only the message's content, ignoring all...
8
by: Gilbert Fine | last post by:
This is a very strange exception raised from somewhere in our program. I have no idea how this happen. And don't know how to reproduce. It just occurs from time to time. Can anyone give me some...
0
by: contactme | last post by:
Hi, Is it possible to open concurrent connections using Net::IMAP::Simple library ? My IMAP server allows 4 connections per ip, so I am having following problems while using Net::IMAP::Simple and...
11
by: mp- | last post by:
I want to be able to allow people to check their email from my PHP online application. Given only the users 1) email address, 2) username (if applicable) and 3) password - how can I auto detect...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.