Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imap_header doesn't work with message uid #26

Closed
oliverkaiser opened this issue Nov 30, 2013 · 13 comments
Closed

imap_header doesn't work with message uid #26

oliverkaiser opened this issue Nov 30, 2013 · 13 comments

Comments

@oliverkaiser
Copy link
Contributor

Hi,

nothing is working anymore for me.

ErrorException
imap_header(): Bad message number

my research has shown me that
imap_header()
http://us1.php.net/manual/en/function.imap-headerinfo.php doesn't work with uid ...

think a decision is needed if the slower imap_fetchheader should be used within the getHeaders function

This is a comment on php.net:
"I typically use UID's to identify messages, and recently discovered that the headers I had been pulling using this function and a message-number didn't match the UID's. Instead of worrying about it, I just began using imap_fetchheader() and imap_ rfc822_ parse_ headers() on its output. The only significant difference I immediately noticed was that there is no "udate" property, so I assigned one with the result of strtotime() on the 'date' property.

Dustin"

@oliverkaiser
Copy link
Contributor Author

sorry, don't know what it is but it seems like I have a "broken" message in my mailbox that is making trouble. Will get back on this soon.

@oliverkaiser
Copy link
Contributor Author

ok, seems like some messages are processed correctly (so it basically works) but my 4th message (processing mailbox->getMessages() ...) is making trouble on loading the headers.

messageNumber is set. But probably there is something wrong and the message can not be identified by imap_header()

just tried a short switch to use
imap_fetchheader() and imap_rfc822_arse_headers() but this is missing the following fields compared to imap_header():

  • flags
  • msgno
  • size
  • Maildate
  • udate
  • fetchfrom
  • fetchsubject

@ddeboer
Copy link
Owner

ddeboer commented Nov 30, 2013

Can you try to write a failing test case with your fourth message?

On Sat, Nov 30, 2013 at 8:02 PM, kaiserlos notifications@github.com
wrote:

ok, seems like some messages are processed correctly (so it basically works) but my 4th message (processing mailbox->getMessages() ...) is making trouble on loading the headers.
messageNumber is set. But probably there is something wrong and the message can not be identified by imap_header()
just tried a short switch to use
imap_fetchheader() and imap_rfc822_arse_headers() but this is missing the following fields compared to imap_header():

  • flags
  • msgno
  • size
  • Maildate
  • udate
  • fetchfrom

* fetchsubject

Reply to this email directly or view it on GitHub:
#26 (comment)

@oliverkaiser
Copy link
Contributor Author

actually I am not sure how I could mock it because I can't exactly describe what is wrong. If you want I could send you the login to my testing mailbox, so you can also take a look on it.

@ddeboer
Copy link
Owner

ddeboer commented Dec 1, 2013

Does imap_fetchheader instead of imap_header work on the problematic message (except for the missing properties)?

Or you can paste the source of your message here, so I can have a look. We can then use (parts of) that source for a test case.

@oliverkaiser
Copy link
Contributor Author

Not sure because it breaks the script already at the first message because of the missing properties.

I got it working and pushed it to https://github.com/kaiserlos/imap

After fixing the first (imap_header) problem I got into another problem based on my first email in the list (that worked before my imap_header fix). On parsing the header to recipients there where cases where the host property wasn't set and also one array part which does not have mailbox, host and personal set). I fixed this with the second commit on my fork.

Haven't made a pull request for now because I am not sure if everything is still correct.

(both are spam messages which are coming to an catchall inbox nutzer-catchall@kaiserlos.de)
My broken (fourth message)

Return-Path: <info@adwords3.com>
Delivered-To: nutzer-catchall@gebraucht.de
Received: from ams002.hawkhost.com (ams002.hawkhost.com [159.253.129.252])
    (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
    (No client certificate requested)
    by mail02.dd24.net (Postfix) with ESMTPS id 1640970748
    for <team@gebraucht.de>; Mon, 25 Nov 2013 22:27:10 +0000 (GMT)
Received: from g225183095.adsl.alicedsl.de ([92.225.183.95]:49797 helo=Alex-PC)
    by ams002.hawkhost.com with esmtpa (Exim 4.80.1)
    (envelope-from <info@adwords3.com>)
    id 1Vl4Zl-001xlN-50
    for team@gebraucht.de; Mon, 25 Nov 2013 23:24:17 +0100
From: "info@adwords3.com" <info@adwords3.com>
Subject: =?iso-8859-1?Q?Bewerbung_als_Freiberufler_f=FCr_Webseitenoptimier?=
 =?iso-8859-1?Q?ung_und_Google_Adwords_Werbung?=
To: team@gebraucht.de
Content-Type: text/plain; charset=iso-8859-1
Date: Mon, 25 Nov 2013 23:24:18 +0100
Message-Id: <20131125232418B42F40AE8C$84A108D483@ALEXPC>
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - ams002.hawkhost.com
X-AntiAbuse: Original Domain - gebraucht.de
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - adwords3.com
X-Get-Message-Sender-Via: ams002.hawkhost.com: authenticated_id: info@adwords3.com
X-Source: 
X-Source-Args: 
X-Source-Dir: 

Sehr geehrte Damen und Herren,

ich bewerbe mich als freier Mitarbeiter im Bereich Webseitenoptimierung, 
(Suchmaschinenoptimierung) und Google Adwords Werbung.

Seit Jahren betreue ich erfolgreich verschiedene Webseiten und Online-Shops. 
Hier konnte ich die Zahl der Kunden und der Verkäufe deutlich verbessern. 

2007 bis heute habe ich für verschiedene Online-Marketing-Agenturen Google-
Adwords-Kampagnen entwickelt und optimiert. 

Insgesamt verfüge ich über sechs Jahre Erfahrung im Online-Marketing 
(Suchmaschinenoptimierung und Google Adwords Werbung).

Auf Wunsch biete ich auch Webseitenerstellung und Optimierung und Online-
Shop-Lösungen.

Wenn Sie meine Mitarbeit wünschen, würde ich mich über eine kurze Nachricht 
freuen. Gerne unterbreite ich Ihnen auch ein individuelles Angebot.

Mit freundlichen Grüssen

Lars Fiedler

Tel.: 0152/ 231 17 526 

info@adwordswerbung.net 
www.adwords-blog.com

The first message (which was working before my imap_header fix)

Return-Path: <adeyemisule@yahoo.com>
Delivered-To: nutzer-catchall@kaiserlos.de
Received: from srv3017vle.sicoobcoopere.coop.br (srv3017vle.sicoobcoopere.coop.br [186.226.184.2])
    by mail02.dd24.net (Postfix) with ESMTP id 5C97070CB7
    for <lingebrauchtmet@kaiserlos.de>; Fri, 22 Nov 2013 21:35:39 +0000 (GMT)
Received: from correio.sicoobcoopere.coop.br (localhost [127.0.0.1])
    by srv3017vle.sicoobcoopere.coop.br (Postfix) with ESMTP id 44AB5582BF4;
    Fri, 22 Nov 2013 17:34:33 -0200 (BRST)
Received: from 41.138.185.51
        (SquirrelMail authenticated user direx)
        by correio.sicoobcoopere.coop.br with HTTP;
        Fri, 22 Nov 2013 17:34:33 -0200
Message-ID: <5c5ed237e2dd573cd2c41cddb78a4297.squirrel@correio.sicoobcoopere.coop.br>
Date: Fri, 22 Nov 2013 17:34:33 -0200
Subject: 
From: "Mr. Kent B Miller" <adeyemisule@yahoo.com>
Reply-To: rickymasias33@gmail.com
User-Agent: SquirrelMail/1.4.20
MIME-Version: 1.0
Content-Type: text/plain;charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Priority: 3 (Normal)
Importance: Normal
To: undisclosed-recipients:;




I am Mr. Kent B Miller assistant manager of Financial Brokers and Business,
we currently offer Xmas loan to individuals and company investors at 2%
interest rate.

Email:adeyemisule1@gmail.com

Fill out the details below:

Full name:
Country:
Address:
State:
Zip code:
Amount
needed:
Duration:
Tel:
Reason:

Contact us by reply and we give you more response.

Contact Online Manager
Mr. Kent B Miller
Mr. Adeyemi Sule
Online department manager
adeyemisule1@gmail.com
rickymasias33@gmail.com

@xeoncross
Copy link

I can verify this problem exists for me too. Applying @kaiserlos patch fixes it.

@mbohlaender
Copy link

Please merge this fix and update bring out a new version

@xeoncross
Copy link

The pull request #29 fixes this issue

@pavlepredic
Copy link

Fix https://github.com/kaiserlos/imap/commit/83bc9813e646859a43dca8863bcd1fb09e5dacaa indeed seems to do the trick. What is the status of this patch? Do you plan to merge it? It's clearly broken the way it is now and even if it appears to work, it's probably fetching wrong emails all the time...

@DanyHenriquez
Copy link

Confirmed for me too. Can we merge so it is easy to get the fixed package with packagist?

@ysramirez
Copy link
Contributor

If you have
$result = $mailbox
->getMessages(new SearchExpression()) // get Messages work with UID
->current()
;
and then if you try to:
$result->getSubject()

you have poblems because the

      $headers = \imap_header($this->stream, $this->messageNumber);

are working with the number of the message not the UID

@ysramirez
Copy link
Contributor

Now is fixed with #44 thanks @ddeboer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants