BL2100: POP3 problems

Hello,

when executing the pop3 sampleprogram parse_extra.c in order to having the SBC receive mails and delete them from the POP3 mailserver, it seems that often mails are missing.

More detailed explanation: please see below. Thanks in advance for having a look at this issue I’m dealing with!!

Noël Willems

I did build in a small loop into the sample program so the mailbox is checked every 30secs, further no modifications.

No other program is accessing the mailbox.
It doesn’t happen when I perform the same with MSOutlook.

For testing and setting up this text I did send 11 mails, with the single charactar subjects a-b-c-d-e-f-g-h-i-j-k.
Chronological:

  1. The first mail with subj “a” is received correctly.
  2. 2nd mail with subj “b” is sent –> wait for checkkingmailbox –> no mail!
  3. Try to send 2 mails before the next mailboxcheck: 3rd & 4th mail with subj "c "and “d” are missing –> no mail!
  4. When I send again 2 mails before the next 30secs are passed and: these mails are received (“e”-“f”).
  5. “h” and “i”: missing
  6. “j” and “k”: OK

… see stdio output below.

When I switch of the deleting, it works better, but each time all the mails on the server are received which is not disered.

Is there something wrong with the pop3.lib? I couldn’t find any mistakes concerning pop_msgcount or pop_msgnum in it, so I guess it has to do with me :-).

What could be causing this? The mailserver?

below one can find the stdio output (dynC9.62) for sending a the above mails to the SBC’s mail adress.
I removed the sender’s e-mail out of the text.

Resolving name…
Calling pop3_getmail()…
Entering pop3_tick()…
RECEIVING MESSAGE <1>
From: =?iso-8859-1?Q?—
To:
Subject: a
POP was successful!
All done!


Resolving name…
Calling pop3_getmail()…
Entering pop3_tick()…
POP was successful!
All done!


Resolving name…
Calling pop3_getmail()…
Entering pop3_tick()…
POP was successful!
All done!


Resolving name…
Calling pop3_getmail()…
Entering pop3_tick()…
RECEIVING MESSAGE<2>
From: =?iso-8859-1?Q?—
To:
Subject: e
RECEIVING MESSAGE<3>
From: =?iso-8859-1?Q?—
To:
Subject: f
POP was
successful!
All done!


Resolving name…
Calling pop3_getmail()…
Entering pop3_tick()…
RECEIVING MESSAGE <1>
From: =?iso-8859-1?Q?—
To:
Subject: g
POP was
successful!
All done! *******************************************
Resolving name…
Calling pop3_getmail()…
Entering pop3_tick()…
POP was successful!
All done!


Resolving name…
Calling pop3_getmail()…
Entering pop3_tick()…
RECEIVING MESSAGE<2>
From: =?iso-8859-1?Q?—
To:
Subject: j
RECEIVING MESSAGE<3>
From: =?iso-8859-1?Q?—
To:
Subject: k
POP was successful!
All done!


Resolving name…
Calling pop3_getmail()…
Entering pop3_tick()…
POP was successful!
All done!


Resolving name…
Calling pop3_getmail()…
Entering pop3_tick()…
POP was successful!
All done!


Resolving name…
Calling pop3_getmail()…
Entering pop3_tick()…
POP was successful!
All done!


Make sure you are using the latest version of Dynamic C and also the latest patches. You can get both at this link

http://www.digi.com/support/productdetail?pid=5053&amp;type=documentation

1 Like

Hello, thx for the quick respons. I was using DynC 9.62, indeed without the latest patches for the lib-files. Unfortunately updating didn’t solve the problem. It looks that there’s something going wrong with the msgcount or msgnum: first mail is always received correctly. following mails can only be received if one sends more than 1 mail between two mailbox checks. From these multiple mails only the seoncd one & following is received, starting from message <2>… but it’s not Always exactly the same behaviour…

You state that you modified the program. Are you still calling pop3_tick() often enough? This function services the daemon and needs to be called often.

You should be able to get more information by uncommenting

#define POP_DEBUG

1 Like

Forget about the text below: issue is S O L V E D: since variable n was global it’s value had to be reset after each mailbox check!!! This reset wasn’t present so the message where n=num was never retrieved.

Digging deeper into the POP_DEBUG helped finding the cause…
So it had to do with me :-s. Sorry for that.

Thanks!!!

Hello & thx again for your effort! The pop3_tick() is called each loop cycle. I added it on some extra places without result.
I activated the POP_DEBUG, then the output shows that the missing message is detected on the server: POP_READ> ‘+OK 1 messages’ but for this particular message, no RECEIVING MESSAGE <1> occurs for some reason…

The program code can be found below followed by the stdio output with POP_DEBUG on. Maybe it has something to do with the costate?

/* I hope it turns out a bit readable & you can find the time to have a look at it. */

#class auto
#define TCPCONFIG 1
#define POP_HOST “in.telenet.be”
#define POP_USER “dumbanddumber”
#define POP_PASS “dummypassword”
#define POP_DEBUG
#define POP_PARSE_EXTRA
#memmap xmem
#use “dcrtcp.lib”
#use “pop3.lib”
int n;
int storemsg(int num, char *to, char *from, char *subject, char *body, int len)
{
#GLOBAL_INIT
{
n = -1;
}

if(n != num) {
	n = num;
	printf("RECEIVING MESSAGE &lt;%d&gt;

“, n);
printf(” From: %s
“, from);
printf(” To: %s
“, to);
printf(” Subject: %s
", subject);
}

// printf("MSG_DATA&gt; '%s'

", body);

return 0;

}

void main()
{

static long address;
static int retval;



sock_init();
// Wait for the interface to come up
while (ifpending(IF_DEFAULT) == IF_COMING_UP) {
	tcp_tick(NULL);
}

pop3_init(storemsg);

do {

costate // mailtest ivm problemen met ophalen na delete
{
printf("Resolving name…
");
address = resolve(POP_HOST);
printf("Calling pop3_getmail()…
");
pop3_tick();
pop3_getmail(POP_USER, POP_PASS, address);

printf("Entering pop3_tick()...

");
while((retval = pop3_tick()) == POP_PENDING)
continue;

if(retval == POP_SUCCESS)
	printf("POP was successful!

");
if(retval == POP_TIME)
printf("POP timed out!
");
if(retval == POP_ERROR)
printf("POP returned a general error!
");

printf("All done!

");
waitfor(DelaySec(30));
}
} while(1);

}