# BL2100: POP3 problems

**URL:** <https://forums.digi.com/t/bl2100-pop3-problems/13519>\
**Category:** Rabbit Software\
**Tags:** sbc, pop3, email, bl2100\
**Created:** [August 28, 2014, 8:12am UTC](https://forums.digi.com/t/bl2100-pop3-problems/13519 "2014-08-28T08:12:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nwillems](https://avatars.discourse-cdn.com/v4/letter/n/f07891/32.png) [@nwillems](https://forums.digi.com/u/nwillems)\
**Post date:** [August 28, 2014, 8:12am UTC](https://forums.digi.com/t/bl2100-pop3-problems/13519/1 "2014-08-28T08:12:39Z")

</div>

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!

* * *

---

<div class="post-metadata">

**Author:** ![trooper2](https://avatars.discourse-cdn.com/v4/letter/t/edb3f5/32.png) [@trooper2](https://forums.digi.com/u/trooper2)\
**Post date:** [August 28, 2014, 10:06am UTC](https://forums.digi.com/t/bl2100-pop3-problems/13519/2 "2014-08-28T10:06:03Z")

</div>

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](http://www.digi.com/support/productdetail?pid=5053&amp;type=documentation)

---

<div class="post-metadata">

**Author:** ![nwillems](https://avatars.discourse-cdn.com/v4/letter/n/f07891/32.png) [@nwillems](https://forums.digi.com/u/nwillems)\
**Post date:** [August 29, 2014, 8:25am UTC](https://forums.digi.com/t/bl2100-pop3-problems/13519/3 "2014-08-29T08:25:31Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![trooper2](https://avatars.discourse-cdn.com/v4/letter/t/edb3f5/32.png) [@trooper2](https://forums.digi.com/u/trooper2)\
**Post date:** [August 29, 2014, 9:35am UTC](https://forums.digi.com/t/bl2100-pop3-problems/13519/4 "2014-08-29T09:35:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nwillems](https://avatars.discourse-cdn.com/v4/letter/n/f07891/32.png) [@nwillems](https://forums.digi.com/u/nwillems)\
**Post date:** [August 31, 2014, 11:09pm UTC](https://forums.digi.com/t/bl2100-pop3-problems/13519/5 "2014-08-31T23:09:43Z")

</div>

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. \*/

---

<div class="post-metadata">

**Author:** ![nwillems](https://avatars.discourse-cdn.com/v4/letter/n/f07891/32.png) [@nwillems](https://forums.digi.com/u/nwillems)\
**Post date:** [August 31, 2014, 11:09pm UTC](https://forums.digi.com/t/bl2100-pop3-problems/13519/6 "2014-08-31T23:09:40Z")

</div>

#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);

}
