IMAP не обновляет состояние папки

Я хочу читать письма с IMAP-сервера с curl (BashScript, который использует curl).

Моя проблема: после перемещения электронной почты IMAP-сервер не обновляется, так что, если я проверю почтовый ящик, IMAP-сервер покажет мне старое количество сообщений, содержащихся в почтовом ящике.

Чтобы устранить проблему, приведем пример-код:

function delete_mail_id() {
     curl --insecure 
          --url "${SERVER}/INBOX" 
          --user "${USER}:${PASSWD}" 
          -X "STORE 

I want to read E-Mails from an IMAP-Server with curl (BashScript, which is using curl).

My problem is: After moving an E-Mail the IMAP-Server does not update, so that, if I examine the inbox, the IMAP Server shows me the old amount of messages, containing in the INBOX.

To clear my problem, here is some example-Code:

function delete_mail_id() {
     curl --insecure 
          --url "${SERVER}/INBOX" 
          --user "${USER}:${PASSWD}" 
          -X "STORE ${1} +Flags Deleted" 1>/dev/null 2>/dev/null
}
function copy_mail_id_to() {
    curl --insecure 
         --url "${SERVER}/INBOX;UID=${1}" 
         --user "${USER}:${PASSWD}" 
         -X "COPY ${1} INBOX/${2}" 1>/dev/null 2>/dev/null
}
function move_mail_id_to() {
    copy_mail_id_to "${1}" "${2}"
    delete_mail_id "${1}"
}
function wait_for_mail_move(){
    TEMP=$( tempfile )
    while true; do
        fetch_first_mail > $TEMP
        if [ "$( grep 'Message-ID:' $TEMP )" != "${1}" ]; then
            break
        else
            sleep 1
        fi
    done
    rm $TEMP
}

Now after moving an E-Mail I wait for the mail to move, but it seems to be an endless loop. Now the funny part: If I look the mails manually through my webmailer the loop ends and the mails are moved one by one (I have a loop, so all the mails should be sorted in other Folders).

Somehow the IMAP only moves the Mails if I check it through the webmailer, but doesn't do it, if I don't check it. This should be automated, so, can anyone explain to me, why this is happening and what I can do about it?

+Flags Deleted" 1>/dev/null 2>/dev/null
}
function copy_mail_id_to() {
curl --insecure
--url "${SERVER}/INBOX;UID=

I want to read E-Mails from an IMAP-Server with curl (BashScript, which is using curl).

My problem is: After moving an E-Mail the IMAP-Server does not update, so that, if I examine the inbox, the IMAP Server shows me the old amount of messages, containing in the INBOX.

To clear my problem, here is some example-Code:

function delete_mail_id() {
     curl --insecure 
          --url "${SERVER}/INBOX" 
          --user "${USER}:${PASSWD}" 
          -X "STORE ${1} +Flags Deleted" 1>/dev/null 2>/dev/null
}
function copy_mail_id_to() {
    curl --insecure 
         --url "${SERVER}/INBOX;UID=${1}" 
         --user "${USER}:${PASSWD}" 
         -X "COPY ${1} INBOX/${2}" 1>/dev/null 2>/dev/null
}
function move_mail_id_to() {
    copy_mail_id_to "${1}" "${2}"
    delete_mail_id "${1}"
}
function wait_for_mail_move(){
    TEMP=$( tempfile )
    while true; do
        fetch_first_mail > $TEMP
        if [ "$( grep 'Message-ID:' $TEMP )" != "${1}" ]; then
            break
        else
            sleep 1
        fi
    done
    rm $TEMP
}

Now after moving an E-Mail I wait for the mail to move, but it seems to be an endless loop. Now the funny part: If I look the mails manually through my webmailer the loop ends and the mails are moved one by one (I have a loop, so all the mails should be sorted in other Folders).

Somehow the IMAP only moves the Mails if I check it through the webmailer, but doesn't do it, if I don't check it. This should be automated, so, can anyone explain to me, why this is happening and what I can do about it?

"
--user "${USER}:${PASSWD}"
-X "COPY

I want to read E-Mails from an IMAP-Server with curl (BashScript, which is using curl).

My problem is: After moving an E-Mail the IMAP-Server does not update, so that, if I examine the inbox, the IMAP Server shows me the old amount of messages, containing in the INBOX.

To clear my problem, here is some example-Code:

function delete_mail_id() {
     curl --insecure 
          --url "${SERVER}/INBOX" 
          --user "${USER}:${PASSWD}" 
          -X "STORE ${1} +Flags Deleted" 1>/dev/null 2>/dev/null
}
function copy_mail_id_to() {
    curl --insecure 
         --url "${SERVER}/INBOX;UID=${1}" 
         --user "${USER}:${PASSWD}" 
         -X "COPY ${1} INBOX/${2}" 1>/dev/null 2>/dev/null
}
function move_mail_id_to() {
    copy_mail_id_to "${1}" "${2}"
    delete_mail_id "${1}"
}
function wait_for_mail_move(){
    TEMP=$( tempfile )
    while true; do
        fetch_first_mail > $TEMP
        if [ "$( grep 'Message-ID:' $TEMP )" != "${1}" ]; then
            break
        else
            sleep 1
        fi
    done
    rm $TEMP
}

Now after moving an E-Mail I wait for the mail to move, but it seems to be an endless loop. Now the funny part: If I look the mails manually through my webmailer the loop ends and the mails are moved one by one (I have a loop, so all the mails should be sorted in other Folders).

Somehow the IMAP only moves the Mails if I check it through the webmailer, but doesn't do it, if I don't check it. This should be automated, so, can anyone explain to me, why this is happening and what I can do about it?

INBOX/" 1>/dev/null 2>/dev/null
}
function move_mail_id_to() {
copy_mail_id_to "

I want to read E-Mails from an IMAP-Server with curl (BashScript, which is using curl).

My problem is: After moving an E-Mail the IMAP-Server does not update, so that, if I examine the inbox, the IMAP Server shows me the old amount of messages, containing in the INBOX.

To clear my problem, here is some example-Code:

function delete_mail_id() {
     curl --insecure 
          --url "${SERVER}/INBOX" 
          --user "${USER}:${PASSWD}" 
          -X "STORE ${1} +Flags Deleted" 1>/dev/null 2>/dev/null
}
function copy_mail_id_to() {
    curl --insecure 
         --url "${SERVER}/INBOX;UID=${1}" 
         --user "${USER}:${PASSWD}" 
         -X "COPY ${1} INBOX/${2}" 1>/dev/null 2>/dev/null
}
function move_mail_id_to() {
    copy_mail_id_to "${1}" "${2}"
    delete_mail_id "${1}"
}
function wait_for_mail_move(){
    TEMP=$( tempfile )
    while true; do
        fetch_first_mail > $TEMP
        if [ "$( grep 'Message-ID:' $TEMP )" != "${1}" ]; then
            break
        else
            sleep 1
        fi
    done
    rm $TEMP
}

Now after moving an E-Mail I wait for the mail to move, but it seems to be an endless loop. Now the funny part: If I look the mails manually through my webmailer the loop ends and the mails are moved one by one (I have a loop, so all the mails should be sorted in other Folders).

Somehow the IMAP only moves the Mails if I check it through the webmailer, but doesn't do it, if I don't check it. This should be automated, so, can anyone explain to me, why this is happening and what I can do about it?

" ""
delete_mail_id "

I want to read E-Mails from an IMAP-Server with curl (BashScript, which is using curl).

My problem is: After moving an E-Mail the IMAP-Server does not update, so that, if I examine the inbox, the IMAP Server shows me the old amount of messages, containing in the INBOX.

To clear my problem, here is some example-Code:

function delete_mail_id() {
     curl --insecure 
          --url "${SERVER}/INBOX" 
          --user "${USER}:${PASSWD}" 
          -X "STORE ${1} +Flags Deleted" 1>/dev/null 2>/dev/null
}
function copy_mail_id_to() {
    curl --insecure 
         --url "${SERVER}/INBOX;UID=${1}" 
         --user "${USER}:${PASSWD}" 
         -X "COPY ${1} INBOX/${2}" 1>/dev/null 2>/dev/null
}
function move_mail_id_to() {
    copy_mail_id_to "${1}" "${2}"
    delete_mail_id "${1}"
}
function wait_for_mail_move(){
    TEMP=$( tempfile )
    while true; do
        fetch_first_mail > $TEMP
        if [ "$( grep 'Message-ID:' $TEMP )" != "${1}" ]; then
            break
        else
            sleep 1
        fi
    done
    rm $TEMP
}

Now after moving an E-Mail I wait for the mail to move, but it seems to be an endless loop. Now the funny part: If I look the mails manually through my webmailer the loop ends and the mails are moved one by one (I have a loop, so all the mails should be sorted in other Folders).

Somehow the IMAP only moves the Mails if I check it through the webmailer, but doesn't do it, if I don't check it. This should be automated, so, can anyone explain to me, why this is happening and what I can do about it?

"
}
function wait_for_mail_move(){
TEMP=$( tempfile )
while true; do
fetch_first_mail > $TEMP
if [ "$( grep 'Message-ID:' $TEMP )" != "

I want to read E-Mails from an IMAP-Server with curl (BashScript, which is using curl).

My problem is: After moving an E-Mail the IMAP-Server does not update, so that, if I examine the inbox, the IMAP Server shows me the old amount of messages, containing in the INBOX.

To clear my problem, here is some example-Code:

function delete_mail_id() {
     curl --insecure 
          --url "${SERVER}/INBOX" 
          --user "${USER}:${PASSWD}" 
          -X "STORE ${1} +Flags Deleted" 1>/dev/null 2>/dev/null
}
function copy_mail_id_to() {
    curl --insecure 
         --url "${SERVER}/INBOX;UID=${1}" 
         --user "${USER}:${PASSWD}" 
         -X "COPY ${1} INBOX/${2}" 1>/dev/null 2>/dev/null
}
function move_mail_id_to() {
    copy_mail_id_to "${1}" "${2}"
    delete_mail_id "${1}"
}
function wait_for_mail_move(){
    TEMP=$( tempfile )
    while true; do
        fetch_first_mail > $TEMP
        if [ "$( grep 'Message-ID:' $TEMP )" != "${1}" ]; then
            break
        else
            sleep 1
        fi
    done
    rm $TEMP
}

Now after moving an E-Mail I wait for the mail to move, but it seems to be an endless loop. Now the funny part: If I look the mails manually through my webmailer the loop ends and the mails are moved one by one (I have a loop, so all the mails should be sorted in other Folders).

Somehow the IMAP only moves the Mails if I check it through the webmailer, but doesn't do it, if I don't check it. This should be automated, so, can anyone explain to me, why this is happening and what I can do about it?

" ]; then
break
else
sleep 1
fi
done
rm $TEMP
}

Теперь после перемещения электронной почты я жду, когда почта переместится, но это кажется бесконечной петлей. Теперь смешная часть: если я смотрю письма вручную через мой веб-Мейлер, цикл заканчивается, и письма перемещаются один за другим (у меня есть цикл, поэтому все письма должны быть отсортированы в других папках).

Каким-то образом IMAP перемещает почту, только если я проверяю ее через веб-Мейлер, но не делает этого, если я не проверяю ее. Это должно быть автоматизировано, поэтому, может кто-нибудь объяснить мне, почему это происходит и что я могу сделать?

1 ответ

  1. Сообщения не удаляются, пока кто-то не отправит EXPUNGEкоманду. В то же время, они просто помечены как удаленное сообщение. Другие клиенты или системы веб-почты отправилиEXPUNGE, поэтому вы видите изменения.

    Причина такого поведения заключается в том, что порядковые номера сообщений изменяются при EXPUNGEобработке: когда сообщение 3 удаляется из почтового ящика, сообщение 4 становится сообщением 3, а сообщение 5 становится сообщением 4 и т. д. Это также позволяет пользователям потенциально восстановить сообщения.

    Скорее всего, вы захотите подождать, пока не завершите все операции перемещения сообщений, а затем вызвать удаление, чтобы ваши порядковые номера сообщений не менялись, когда вы этого не ожидаете.