473,546 Members | 2,644 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

unsupported body type in imap

111 New Member
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($m box);

for ($jk = $message_count; ($message_count-6) <= $jk; $jk--)
{
$structure = imap_fetchstruc ture($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_fetchstruc ture ), 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 2212
pbmods
5,821 Recognized Expert Expert
Heya, Nitin.

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

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

Similar topics

3
4378
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 a possiblity to use imap_body and give the name of the file as a parameter. Thanks in advance.
1
3264
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...
6
34647
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 tried lots of different things, but I can't get it to work. I did a google search for "unsupported operand types" and for most of the people...
0
3987
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...
2
7560
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
4475
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 additional informations (charset and whatsoever? I'm currently reading the text like this: imap_body ($this->inbox, $i) Fact if, that this way i get...
8
9495
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 suggestion to fix this? Thanks. -- Gilbert
0
1384
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 Net::IMAP::Simple::SSL libraries: 1) The method new returns a valid connection even on 5th try, though the login fails as it looks like IMAP->login...
11
10701
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 a remote IMAP/POP3 server so that I can connect and fetch mail for the user. (Ultimately, I don't want users to have to know what the IMAP/POP3...
0
7504
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...
0
7435
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...
0
7947
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7792
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...
0
5080
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1921
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
1
1046
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
747
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.