thank you - while i found another solution it's
always a good idea to understand the low-level
things more and more

Am 23.08.2013 11:49, schrieb Paul J Stevens:
> On 23-08-13 00:18, Reindl Harald wrote:
>> OK with fread($fp, 100000000); instead of fgets() that looks
>> different but these are only pieces of the message
> 
> Still not correct. You need to do something like
> 
> $readbuffer = "";
> while ($result = fread($fp, 4096)) {
>   $readbuffer .= $result;
> }
> 
> so basically: keep reading until there's nothing left to read.
> 
>> is there a simple IMAP and finally POP3 command to
>> retrieve a *complete* message as RAW source like
>> "view source" in thunderbird without implement
>> full RFC's and whatever parsing on the client?
> 
> x FETCH <msgid> RFC822
> 
> will retrieve the full message, period.
> 
> This will result in
> 
> * <msgid> FETCH (RFC822 {<octets>}
> <octets data>
> )
> x OK FETCH completed
> 
> so if you strip off the first line, and the last two lines you will have
> the complete message.
> 
> 
> For POP3, you can simply use the RETR command
> 
> client:
> RETR 1
> 
> server:
> +OK <octets> octets
> <octets data>
> ..
> 
> 
> so for POP3 you strip off the first line starting with +OK, and the last
> line which contains a single dot. For the remaining data inbetween, you
> need to convert double-dots at the start of a line to a single dot,
> since the POP3 protocol dictates that data send to the client ends with
> a single dot. Lines in a multi-line response that begin with a dot need
> to be byte-stuffed by pre-pending them with a dot.
> 
> http://tools.ietf.org/html/rfc1939#section-3
> 
>> Am 22.08.2013 23:54, schrieb Reindl Harald:
>>> i try do include a simple POP3/IMAP debug tool to get
>>> the RAW message source in our admin-backend but IMAP
>>> does not love me
>>>
>>> why do i not get any response after the "fetch" command
>>> while the debug-log shows something is retrieved from
>>> the DB which matches the message in question
>>>
>>> Aug 22 23:51:33 srv-rhsoft.rhso dbmail-imapd[16139]: [0x7f73edc4a4f0] 
>>> Debug:[imap] _fetch_headers(+725):
>>> [0x7f73edcb67c0] for 167205 [(Newsgroups Content-MD5 Content-Disposition 
>>> Content-Language Content-Location
>>> Followup-To References)]
>>> Aug 22 23:51:33 srv-rhsoft.rhso dbmail-imapd[16139]: [0x7f73edc4a4f0] 
>>> Debug:[imap] _send_headers(+652):
>>> [0x7f73edcb67c0] [(Newsgroups Content-MD5 Content-Disposition 
>>> Content-Language Content-Location Followup-To
>>> References)] [References: <4FD82EEA.7060609@
>>> ______________________________________________
>>>
>>> outputs of the PHP-fwrite()-commands below
>>>
>>> * OK [CAPABILITY IMAP4 IMAP4rev1 ACL RIGHTS=texk NAMESPACE CHILDREN SORT 
>>> QUOTA THREAD=ORDEREDSUBJECT UNSELECT IDLE
>>> STARTTLS AUTH=CRAM-MD5 AUTH=DIGEST-MD5 AUTH=LOGIN AUTH=PLAIN]
>>> 1 OK [CAPABILITY IMAP4 IMAP4rev1 ACL RIGHTS=texk NAMESPACE CHILDREN SORT 
>>> QUOTA THREAD=ORDEREDSUBJECT UNSELECT IDLE]
>>> User [email protected] authenticated
>>> * 8 EXISTS
>>> * 0 RECENT
>>> ______________________________________________-
>>>
>>>    if($msgid > 0)
>>>    {
>>>     echo '<div style="white-space:nowrap;">' . MY_LE;
>>>     switch($protocol)
>>>     {
>>>      case 'IMAP':
>>>        $fp = @fsockopen($dbmail->imap_hostname, 143, $errno, $errstr, 1);
>>>        if($fp)
>>>        {
>>>         echo fgets($fp) . '<br />' . MY_LE;
>>>         fwrite($fp, '1 login "' . $username . '" "' . 
>>> $user_data['password'] . '"' . "\n");
>>>         echo fgets($fp) . '<br />' . MY_LE;
>>>         fwrite($fp, '2 EXAMINE "INBOX"' . "\n");
>>>         echo fgets($fp) . '<br />' . MY_LE;
>>>         fwrite($fp, '3 fetch ' . $msgid . ' ALL' . "\n");
>>>         echo fgets($fp) . '<br />' . MY_LE;
>>>        }
>>>        echo '<br />' . MY_LE;
>>>        break;
>>>      case 'POP3':
>>>        break;
>>>     }
>>>     echo '</div>' . MY_LE;
>>>    }

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
DBmail mailing list
[email protected]
http://mailman.fastxs.nl/cgi-bin/mailman/listinfo/dbmail

Reply via email to