TOPIC: PopClient
PopClient 1 Year, 2 Months ago
I would like do an application witch could be able to read and treat email on a pop server. This application shoud be able to read permanently the pop server and treat the email when it arrive

How to get an event (new mail) from a pop server ?

I have got a look over timmer(), PopClient() unsuccesfully for the moment.

Thanks for the answer

Re:PopClient 1 Year, 2 Months ago
You have to "poll" - check every so often.

You can use Timer or Delayed or ScheduleControl, or just use an infinite loop with a Sleep. (It is bad to poll continuously because this puts a heavy load on the POP server.)

You could look at Mail_Processor for an example of using PopClient. (It is an abstract base class so it cannot be run by itself.)

The POP RFC is helpful:

We use PopClient often so ask any questions and I will try to help.
Re:PopClient 1 Year, 1 Month ago

Between the 3 solutions, witch one is the best for this kind of application ?

- Timer(block) ?

I dont see how to use Timer(), it can take only one parameter : the block to execute, how to indicate the interval between each execution ?

- Delayed ? Apparently it defined a delay to execute a function ?

- infinite loop with a Sleep ?

Had you a small sample please ?

Re:PopClient 1 Year, 1 Month ago
Sorry, the Timer function is not what you want. It simply returns how long some code takes to run.

The simplest is just to sleep, something like:

    pc = PopClient('', 'myuser', 'mypassword')
    if false isnt pc.GetMessage(1)
        Print('new messages')

Re:PopClient 1 Year, 1 Month ago
Thank you Andrew for teh script,

But for my application i think there is an other way,

Is it possible to execute suneido in a cgi directory on a web server (Apache) ?

So it could be "easy" in php to use something like that

exec(cgisuneido -client mylib anarray) is the remote PC server for the application sunéido.

anarray : is ann array of parameter from PHP Vars

mylib : is just a sunéido scrip to update a table from the database...

An alternative of this way, could be to use in PHP rexec()
r for remote to launch directely suneido on the remote PC server for the application sunéido.

If anybody can help me

Re:PopClient 1 Year, 1 Month ago
Yes, you can use Suneido with cgi. As long as it does not load too much library code then it is relatively quick. And if it is a client it does not need to open the database itself.

You can run a function from the command line like:

suneido MyFunc();Exit()

You need to make sure you call Exit() or suneido will still be running after the function finishes. You could call Exit from within your function to keep the command line simple.

I am not familiar with PHP so I can not help with that part.
Re:PopClient 1 Year, 1 Month ago
I have tried with the PHP function exec()

exec('c:myappsuneido.exe') or

I have the first window with the suneido logo and

a small window with Fatal Error in title and text
can't open: and ok button

Is anybody can help me please ?

Thanks by advance

Re:PopClient 1 Year, 1 Month ago
I am not sure what is happening.

One thing is that Suneido looks for the database file (suneido.db) in the current working directory. If the current directory is somewhere else it will not work. You can check this by doing System("cd") or if that does not pause you can make a batch file with pause.

If the current directory is wrong, you can either switch before running suneido, or make a batch file that does cd before running suneido.

I hope that helps.
Re:PopClient 1 Year, 1 Month ago
Thanks Andrew

I have found

For this kind of application it's necessary to be in client/server mode.

It's all right, you can even pass PHP var in your exec() command.

There is just a furtif black windows corresponding at


but it doesn't matter.

The next step is to place suneido on a web server in a CGI directory. to follow...

by by
Re:PopClient 1 Year, 1 Month ago
Hi you can get ride of the dos box windows with the following little c program


/* #define NOCRYPT */

/* #define NOSERVICE */

/* #define NOMCX */

/* #define NOIME */

#include <windows.h>

#include <windowsx.h>

#include <commctrl.h>

#include <tchar.h>

#include <shellapi.h>

#include <stdio.h>

/** Global variables ********************************************************/

//Handle to application

static HANDLE ghInstance;


 *                                                                           *

 * Function: WinMain                                                         *

 *                                                                           *

 * Purpose : start a program without resorting to cmd.exe                                           *

 *                                                                           *

 * History : Date      Reason                                                *

 *           00/00/00  Created                                               *
 * Notes   : This source can be compiled with PellesC (*

 *                                                                           *


int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)


    ghInstance = hInstance;

// Start the service execution creating a process



HWND hwndQemu;

// Standar good practice

   ZeroMemory( &si, sizeof(si) );

   si.cb = sizeof(si);

   ZeroMemory( &pi, sizeof(pi) );

//Build command line to start suneido server

char szCmdLine[MAX_PATH];
char szDir[MAX_PATH]

ZeroMemory(szCmdLine, sizeof(szCmdLine) );
ZeroMemory(szDir, sizeof(szCmdLine) );

//Set path and executable

strcpy(szDir, "c:\suneido\");  //set your proper dir here
strcpy(szCmdLine, "suneido.exe go.file"); //set your suneido start line to suit your purpouses


// Start the child process. 

   if(!CreateProcess( NULL,    // No module name (use command line). 

        szCmdLine,  // Command line. 

        NULL,              // Process handle not inheritable. 

        NULL,              // Thread handle not inheritable. 

        FALSE,             // Set handle inheritance to FALSE. 

        0,                 // No creation flags. 

        NULL,              // Use parent's environment block. 

        szDir,          // Use current directory

        &si,              // Pointer to STARTUPINFO structure.

        &pi )              // Pointer to PROCESS_INFORMATION structure.


    return 0;


To build this program get PellesC (, choose new windows project, paste the code in main.c, and compile
The program can be used to launch any program setting up command line parameter without resorting to cmd.exe, just change szCmdline accordingly.

Put this program in your cgi dir and call it instead of suneido.exe

Another, simpler, solution is to change the init member of stdin to
launch your process if no command line parameters are passed in, but be careful... you could get locked out of your suneido database.
If you modify Init and make a mistake suneido will not start the stdlib code... and you'll be kicked out of your database... in that case you can open suneido.db with an hex editor and attemp to fix it "from inside", be advised... make a backup copy before modifying init
Last Edit: 2009/07/09 23:29 By sanotto.
Re:PopClient 1 Year, 1 Month ago
Thank you Sanotto for your response

But before I have just a problem to solve.

In local with easyPHP it's all right !


$commande = 'C:mydirectorysuneido.exe -n -client CreerRvdClient('.escapeshellarg($nom).','.escapeshellarg($prenom).','.escapeshellarg($date).','.escapeshellarg($heure).')';



On a web serveur Linux it doesn't run.

Then the command is :


$commande = ' -n -client CreerRvdClient('.escapeshellarg($nom).','.escapeshellarg($prenom).','.escapeshellarg($date).','.escapeshellarg($heure).')';



The IP adress is the PC on witch one myapply suneido is running on server mode.

The IP adress is OK (ping)

The path is ok I have done a test with a file

The directory properties on cgi-bin are 755

Thank you for the response

Re:PopClient 1 Year, 1 Month ago

Try prefixing the comand with

wget http://



Linux does'nt know what to do with a bare url, you need some program to interpret it, like firefox or in this case "wget"

wget just reads a page from an url and drop it's content on stdout, I assume that is what you need.

wget should be allready installed if your distro is debian based (Ubuntu debian etc), if not... try your package manager

take a look at wget man page with man wget

You should take a look at suneido http server you can program it to react to requests like


The port (8080) could be any port you like, so you will not need to use it as a cgi program and the code to call it from windows and Unix will be the same