Создание  
  О компании  Программ Устройств   Linux    
  Контакты   Обучение  
    Инвестиционные проекты

LsoL

  Обслуживание    
  Продукция     Советы  
   

Модуль SMTP/POP3:


Contents:

Overview

Возможности:
  • Отправка письма через внешний SMTP сервер.
  • Прямая отправка письма на сервер адресата.
  • SMTP cервер приема сообщений (включается по усмотрению хост-программы)
  • Проверка хоста присылающего сообщения по DNSBL серверам.
  • Поддержка списков.
  • POP3 cервер доступа к сообщениям (включается по усмотрению хост-программы)
  • Проверка и прием сообщений с внешних POP3 ящиков.
  • Режимы синхронной и асинхроной загрузки.
  • Возможность загружать файлы через прокси.
  • Подключается как DLL.
    Заголовочный файл (хидер)      


  • Usage




    First type of usage is just send message.
    The 3 way of this action provided. You may send it immidiatle directly to SMTP of receptor, you may put message to queu and in this case server will try to send this message and if sucessless by not critical reason, it will try again up to 24 hours, and thrith way is send it through another SMTP server (e.g. server of your provider.)
    For it host program may call one of three functions: SRVInitSendMsgImidiatly, SRVInitSendMsgBackgaund or SRVInitSendMsgSMTP then call SRVSend or SRVprintf, and then call SRVEndOfMsg.
    Host program may receive info about state of message through callback function.


    Second type of usage is SMTP server.
    For it just call SetSMTPServer. The callback function will call when somebody try to send message to you.
    The host program may just return zero by this callback, and in this case the server will work with message.
    The host program may return the error code, and in ths case message may be declined.
    The host program may get message data with SRVRecv function. If after receiving the host program don't wan to
    store the message, it may return subzero value and message will be delate.


    Thrid type of is POP3 server.
    For it just call SetPOP3Server. Then server will can return to user message that has been stored before.
    The host program may control the users withhelp callback function.



    Functios








    type of stream
    ServerStream;



    SMTPReqCallback
    type for callback function that will call for each request, after request recived, before server do anything other.
    typedef int (* SMTPReqCallback)(ServerStream * stream, char * reqname, int action, ...);
    Parameters:
    The stream may be used by host program for next request.
    The reqname it is name of requested flie.
    The action defined there: ACTION_POP_LOGIN ACTION_POP_GETMSG ACTION_POP_DELMSG ACTION_SMTP_CONNECT ACTION_SMTP_SENDMSG
    Return value:
    If this callback return zero, the server will still work the request.
    If this callback return subzero the server understan that host program
    If this callback return value above zero, the server return it to client as error code and return error page.

    ALL_ACTIONS


    MsgCallback
    type for callback function that will call for each change state in send msg request.
    typedef void (* MsgCallback)(ServerStream * stream, void * usr_par, int state, int sent);
    Parameters:
    The stream -- may be used by host program for next request.
    The usr_par' -- . user s param
    The state defined there: STATE_SMTP_FINDHOST STATE_SMTP_CONNECTING STATE_SMTP_DIALOG STATE_SMTP_SENDING STATE_SMTP_DONE
    sent -- number of bytes that already sent.



    SRVInitSendMsgImidiatly
    To begin send message directly and immidiatle, to SMTP server of receptor use:
    ServerStream SRVInitSendMsgImidiatly(char * from, int * to, MsgCallback callback=NULL, void * callback_param);
    Parameters:
    From -- sender e-mail
    To -- Reception e-mail
    callback -- callback function that will call for each change of state.
    Return value:
    If sucess return.the pointer to Stream
    NULL if error.


    SRVInitSendMsgSMTP
    To begin send message throught an external SMTP server use:
    ServerStream SRVInitSendMsgSMTP(char * from, int * to, char * smtp_host, int port=25 , MsgCallback callback=NULL, void * callback_param=NULL);
    Parameters:
    From -- sender e-mail
    To -- Reception e-mail
    smtp_host -- the host of remote SMTP server to connect
    port -- port of remote.
    callback -- callback function that will call for each change of state.
    Return value:
    If sucess return.the pointer to Stream
    NULL if error.



    SRVInitSendMsgBackgaund
    To begin send message directly but throught background queu use:
    ServerStream SRVInitSendMsgBackgaund(char * from, int * to, MsgCallback callback=NULL, void * callback_param=NULL);
    Parameters:
    From -- sender e-mail
    To -- Reception e-mail
    callback -- callback function that will call for each change of state.
    Return value:
    If sucess return.the pointer to Stream
    NULL if error.


    SRVEndOfMsg
    After init sending you may put message date with SRVSend' or 'SRVprintf' and after it use 'SRVEndOfMsg to close the stream.
    void SRVEndOfMsg(ServerStream * stream);
    Parameters:
    The stream -- pointer to stream that was transfer to callback function.or return by SRVInitSendMsg*


    SetSMTPServer
    The host program must only call SetSMTPServerServer function, that create SMTP server thread
    int SetSMTPServer(SMTPReqCallback callback=NULL, int port=0, int mask=ALL_ACTIONS);
    Parameters:
    The callback -- callback function that will call for each request, after request recived, before server do anything other
    by default NULL -- int this case the server will just work with request.
    The port -- TCP/IP port. If used default value zero, the server use value from config, by default 21.
    mask -- the mask for action for that the server call callback
    Return value:
    Zero if sucess.
    Subzero if fail



    SetPOP3Server
    The host program must only call SetPOP3Server function, that create server thread
    int SetPOP3Server(SMTPReqCallback callback=NULL, int port=0, int mask=ALL_ACTIONS);
    Parameters:
    The callback -- callback function that will call for each request, after request recived, before server do anything other
    by default NULL -- int this case the server will just work with request.
    The port -- TCP/IP port. If used default value zero, the server use value from config, by default 21.
    mask -- the mask for action for that the server call callback
    Return value:
    Zero if sucess.
    Subzero if fail





    SRVSend
    The host program may send data to the client with next functions:
    int SRVSend(ServerStream * stream, void * bufer, int size);
    Parameters:
    The stream -- pointer to stream that was transfer to callback function.or return by SRVInitSendMsg*
    The bufer -- bufer to send
    The size -- size of bufer
    Return value:
    Number of bytes that has been send.
    Zero if error

    SRVprintf

    int SRVprintf(ServerStream * stream, char * format, ...);
    Parameters:
    The stream -- pointer to stream that was transfer to callback function.or return by SRVInitSendMsg*.
    The format -- format like in stdio printf
    ... params by format
    Return value:
    Number of bytes that has been send.
    Zero if error





    SRVRecv
    If you would like reveive the data st you may use SRVRecv:
    int SRVRecv(ServerStream * stream, void * bufer, int l);
    Parameters:
    The stream -- pointer to stream that was transfer to callback function.
    The bufer -- bufer to recive
    The size -- size of bufer
    Return value:
    Number of bytes that has been recive.
    Zero if error


    GetAUTHName
    To get info about POP3 autorization use next functions:
    char * GetAUTHName(ServerStream * stream);
    Parameters:
    The stream -- pointer to stream that was transfer to callback function.
    Return value:
    pointer to user name.
    GetAUTHPassw
    The NULL pointer if no control present.
    char * GetAUTHPassw(ServerStream * stream);
    Parameters:
    The stream -- pointer to stream that was transfer to callback function.
    Return value:
    pointer to password.
    The NULL pointer if no control present.



    GetRemoteIP
    Advanced info about connection you may get with next functions.
    ulong GetRemoteIP(ServerStream * stream);
    Parameters:
    The stream -- pointer to stream that was transfer to callback function.
    Return value:
    IP address of remote.

    GetRemoteAddr

    int GetRemoteAddr(ServerStream * stream, void * addr, int buflen);
    Parameters:
    The stream -- pointer to stream that was transfer to callback function.
    Return value:
    address of remote.in sockaddr struct
    GetSocket

    int GetSocket(ServerStream * stream);
    Parameters:
    The stream -- pointer to stream that was transfer to callback function.
    Return value:
    socket




    If you would like find MX records for domain use FindMX functiom:
    struct MailHostInfo
    {
    char name[64]; The hostname of MX
    int prior; MX priority
    ulong ip[12]; Array of IP if it was present in reply.
    FindMX
    };
    int FindMX(char * domain, MailHostInfo * ret, int size);
    Parameters:
    domain -- the domain name
    ret -- array of MailHostInfo where module will store data
    size -- size of array
    Return value:
    number of MX that has been found If Ok
    zero, if not found



    The host program may load all params for module from separate file,
    LoadConfig
    or my set required params directly, or use default values.
    int LoadConfig(char * filename="ftp.cfg");
    Parameters:
    The filename -- name of configuration file.
    Return value:
    Zero if sucess.
    Subzero if fail


    SetConfigParam
    You may set all params directly:
    void SetConfigParam(char * param, int val);
    Parameters:
    The param -- name of param
    val -- value.
    SetConfigParam

    void SetConfigParam(char * param, char * val);
    Parameters:
    The param -- name of param
    val -- value.

    To get current values of configuration params you may use next functions:
    GetConfigParamInt
    For integer params:
    int GetConfigParamInt(char * param);
    Parameters:
    The param -- name of param

    SetConfigParamStr
    For string params:
    char *SetConfigParamStr(char * param);
    Parameters:
    The param -- name of param


    Поставляется только на условии подписания письменного договора, регламентирующего не использование модуля для рассылки СПАМа.