--------
OVERVIEW
--------

This documentation is in HTML format.  We plan to do a better more detailed
documentation in WinHelp format in the near future.  Watch http://www.altn.com
for details.


-----------------
TABLE OF CONTENTS
-----------------

Revision history

Integrating your custom applications with MDaemon
LoadMDUserDll()
FreeMDUserDll()

API Reference


----------------
REVISION HISTORY
----------------

v3.5.0.0
--------

  This version of the DLL adds several more functions to the DLL.  They all
  revolve around the new IMAP Mail Rules feature-set.  These functions are
  available in the PRO version only.
  
  The following functions have been added.
  --------------------------------------
  MD_FindFirstRule
  MD_FindNextRule
  MD_ReadRule
  MD_GetEditIMAPRules
  MD_SetEditIMAPRules
  MD_RuleStructToRuleString
  MD_RuleStringToRuleStruct
  MD_DeleteRule
  MD_AddRule
  MD_ChangeRule
  MD_MoveRuleUp
  MD_MoveRuleDown
  MD_GetIMAPFolders
  MD_CreateIMAPFolder

v3.1.0.0
--------

  This version of the DLL make changes to almost all the functions.  As a result,
  alot of your code will need to be updated.  These changes were needed to allow 
  for the future intregration of database functionality.
  
  The following functions have been changed
  -----------------------------------------
  MD_GetByEmail
  MD_GetByFullName
  MD_GetByMailbox
  MD_GetByMailDir
  MD_UserExists
  MD_GetFree (formerly called MD_FreeIndex)
  MD_GetByAlias (formerly called MD_TranslateUser)
  MD_FindFirst (formerly called MD_GetFirstUser)
  MD_FindNext (formerly called MD_GetNextUser)

  
  The following functions have been added
  --------------------------------------
  MD_FindClose
  MD_GetAutoRespInfo
  MD_SetAutoRespInfo
  MD_EraseAutoResp

  
  The following functions have been removed
  ----------------------------------------
  MD_FreeIndex
  MD_GetFirstUser
  MD_GetNextUser
  MD_TranslateUser
  MD_GetMaxDiskSpaceStr
  MD_SetMaxDiskSpaceStr
  MD_GetMaxMessageCountStr
  MD_SetMaxMessageCountStr
  MD_IsDynamicPassword
  MD_GetMaxUIDLCountStr
  MD_GetMaxMessageSizeStr

Back to Table of Contents


-------------------------------------------------
Integrating your custom applications with MDaemon
-------------------------------------------------

For the convenience of our customers with advanced programming capabilities
MDaemon includes MDUSER.DLL which contains several functions you can use
to better integrate your custom software applications with MDaemon.  These
functions are written in C++ and have been tested using Microsoft Visual
Studio 6.0 and Borland C++ 5.02.

The \DOCS\API\ directory off your root MDaemon directory contains the following
files:

MDUSERIMPORTS.H - C/C++ header file containing definitions and structures used
  by the functions documented here.

MDUSERIMPORTS.CPP - C/C++ source code file you can include in your project to
  integrate the API into your application.

MDUSERIMPORTS.CPP contains a function called LoadMDUserDll.  This function is
used to initialize and load MDUSER.DLL.  You must call this function before 
using any of the API functions documented here.  Similarly, MDUSERIMPORTS.CPP
contains a function called FreeMDUserDll which must be called prior to your
application being terminated.


bool LoadMDUserDll( int& Result // buffer to store error result code char* Path // path to MDUSER.DLL file bool LoadUsers // TRUE if account information should be loaded bool IgnoreFail // TRUE if errors loading DLL should be ignored ) This function initialized MDUSER.DLL for use with your application and maps all the API functions into your application's address space. Parameters Result - if an error occurs this variable will have the result code returned from the Win32 API function GetLastError. Path - optional path to the MDUSER.DLL file. LoadUsers - TRUE if account information should be loaded into memory once the DLL has been successfully initialized. IgnoreFail - Normally when a pointer to each known function within the DLL cannot be obtained the DLL will be unloaded and this function will return FALSE. Setting this function to TRUE prevents the unloading of the DLL in such cases (although this function will still return FALSE). This allows you to use the most recent version of MDUSERIMPORTS.CPP/MDUSERIMPORTS.H even with older versions of the DLL. Return values This function returns TRUE if MDUSER.DLL was successfully loaded and all the API functions were mapped into your application's address space without error. Otherwise it returns FALSE. Remarks This function is located within MDUSERIMPORTS.CPP. To use this function your application must include MDUSERIMPORTS.CPP as part of the project or work- space. If this function returns FALSE Result will contain the Win32 API numerical error code which can be used to determine the reason for the failure. Path can be NULL in which case MDUSER.DLL is assumed to be in the same directory as your application. Example // it is assumed that MDUSERIMPORTS.CPP is a part of the example workspace int Result; if (!LoadMDUserDll(Result, NULL, false)) // handle error else // proceed Back to Table of Contents
void FreeMDUserDll() This function frees MDUSER.DLL. Parameters none Return values none Remarks This function is located within MDUSERIMPORTS.CPP. To use this function your application must include MDUSERIMPORTS.CPP as part of the project or work- space. Your application should call this function before it terminates. Back to Table of Contents ------------- API Reference ------------- The API contains functions which are divided into the following groups: APPLICATION LEVEL FUNCTIONS MD_RegisterWindow MD_UnregisterWindow MD_GetSharedUserInfo MD_ReloadUsers MD_SetIsMDConfig DATABASE FUNCTIONS MD_GetAppDir MD_GetDBPath MESSAGE HANDLING FUNCTIONS MD_MessageInfo structure MD_InitMessageInfo MD_VerifyMessageInfo MD_SpoolMessage DOMAIN RELATED FUNCTIONS MD_GetDomainNames MD_GetDomainCount MD_GetDomainNameUsingIP ACCOUNT MANAGEMENT FUNCTIONS MD_UserInfo structure MD_InitUserInfo MD_GetUserInfo MD_SetUserInfo MD_VerifyUserInfo MD_AddUser MD_ChangeUser MD_DeleteUser MD_FindFirst MD_FindNext MD_FindClose MD_GetByEmail MD_GetByFullName MD_GetByMailbox MD_GetByMailDir MD_GetByAlias MD_GetFree MD_UserExists MD_UserCount MD_ValidateUser MD_LogonUser MD_FilterString MD_FilterUserInfo MD_GetEmail MD_GetMailbox MD_SetMailbox MD_GetDomain MD_SetDomain MD_GetFullName MD_SetFullName MD_GetMailDir MD_SetMailDir MD_GetPassword MD_SetPassword MD_GetAutoDecode MD_SetAutoDecode MD_GetIsForwarding MD_SetIsForwarding MD_GetAllowAccess MD_SetAllowAccess MD_GetAllowChangeViaEmail MD_SetAllowChangeViaEmail MD_GetKeepForwardedMail MD_SetKeepForwardedMail MD_GetHideFromEveryone MD_SetHideFromEveryone MD_GetEncryptMail MD_SetEncryptMail MD_GetApplyQuotas MD_SetApplyQuotas MD_GetEnableMultiPOP MD_SetEnableMultiPOP MD_GetLocalOnly MD_SetLocalOnly MD_GetMaxDiskSpace MD_SetMaxDiskSpace MD_GetMaxMessageCount MD_SetMaxMessageCount MD_GetForwardingInfo MD_SetForwardingInfo MD_GetAutoRespInfo MD_SetAutoRespInfo MD_EraseAutoResp MD_GetMailFormat MD_SetMailFormat MD_GetFileCount MD_GetDirSize MD_GetWebConfigBit MD_SetWebConfigBit MD_GetAccessWorldClient MD_SetAccessWorldClient MD_GetAccessWebConfig MD_SetAccessWebConfig MD_GetIsAdmin MD_SetIsAdmin MD_GetEditFullName MD_SetEditFullName MD_GetEditPassword MD_SetEditPassword MD_GetEditMailDir MD_SetEditMailDir MD_GetEditFwd MD_SetEditFwd MD_GetEditAdvFwd MD_SetEditAdvFwd MD_GetEditEncrypt MD_SetEditEncrypt MD_GetEditEveryone MD_SetEditEveryone MD_GetEditLocalOnly MD_SetEditLocalOnly MD_GetEditQuotas MD_SetEditQuotas MD_GetEditMultiPOP MD_SetEditMultiPOP MD_GetEditAutoResponder MD_SetEditAutoResponder MD_GetEditEmailChanges MD_SetEditEmailChanges MD_GetEditIMAPRules MD_SetEditIMAPRules MD_IsDynamicPasswordStr MD_GetMaxUIDLCount MD_SetMaxUIDLCount MD_GetMaxMessageSize MD_SetMaxMessageSize IMAP FOLDER AND RULE MANAGEMENT FUNCTIONS MD_FindFirstRule MD_FindNextRule MD_GetEditIMAPRules MD_SetEditIMAPRules MD_ReadRule MD_RuleStructToRuleString MD_RuleStringToRuleStruct MD_DeleteRule MD_AddRule MD_ChangeRule MD_GetIMAPFolders MD_CreateIMAPFolder --------------------------- APPLICATION LEVEL FUNCTIONS --------------------------- The following functions allow you to load the API and register and unregister your application's main window handle with MDUSER.DLL. Various actions performed by applications using the DLL generate notifications which are sent to all registered applications. For example, if you wish your application to be notified that someone has removed an account via the MDaemon GUI you need to register your window handle with the DLL. MDUSER.DLL uses SendMessage to inform each registered application that an important event has taken place. Because each application is notified via a call to SendMessage rather than PostMessage your application's event handler must process these messages as quickly as possible. Lengthy processing should not be performed in your applications event loop. Rather, set a flag and perform the lengthy processing later - after your application has returned control back to MDUSER.DLL. MDUSER.DLL will send the WM_MDUSERDLL_MSG message to all registered windows whenever an important event occurs. The WPARAM value will be determined by the type of event that has taken place: WM_MDUSERDLL_LOADING - Some accounts have just been loaded from USERLIST.DAT. The number of accounts loaded will be passed in LPARAM. WM_MDUSERDLL_ADDSEM - New account added via semaphore file WM_MDUSERDLL_CHANGESEM - Account modified via semaphore file WM_MDUSERDLL_DELETESEM - Account deleted via semaphore file WM_MDUSERDLL_ADD - New account added via MD_AddUser() function WM_MDUSERDLL_CHANGE - Account modified via MD_ChangeUser() function WM_MDUSERDLL_DELETE - Account deleted via MD_DeleteUser() function
bool MD_RegisterWindow( HWND Handle // window handle to send notifications to ) This function is used to register a window handle with MDUSER.DLL. Parameters Handle - this is the window handle that MDUSER.DLL will send notification messages to. Return values This function returns TRUE if the handle was registered. Otherwise it returns FALSE which means that MDUSERDLL_MAXHANDLES applications have already been registered. Remarks This function should be called to register the window handle within your application which should receive notifications of various events which occur such as adding accounts, deleting accounts, or reloading accounts. MDUSER.DLL will call SendMessage to inform Handle of these events. See the discussion at the start of this section for details. Example HWND Handle = GetMainWindow(); if (MD_RegisterWindow(Handle)) // ok to proceed else // handle error Back to API reference
bool MD_UnregisterWindow( HWND Handle // window handle to stop notifications to ) This function is used to unregister a window handle with MDUSER.DLL. Parameters Handle - this is the window handle to unregister. Return values This function returns TRUE if the handle was unregistered. Otherwise it returns FALSE which means that Handle was not previously registered. Example HWND Handle = GetMainWindow(); if (MD_UnregisterWindow(Handle)) // ok to proceed else // handle error Back to API reference
MD_UserInfo* MD_GetSharedUserInfo() This function is used to aquire information on an account that has just been added, deleted, or changed. Parameters none Return values This function returns a pointer to an MD_UserInfo structure that is owned by the DLL. Remarks The structure returned by this function must never be altered in any way or freed. This structure is shared by all applications using the DLL and is freed automatically when the DLL is unloaded from memory by the operating system. This function can be used by your application during processing of a WM_MDUSERDLL_ADDSEM, WM_MDUSERDLL_CHANGESEM, WM_MDUSERDLL_DELETESEM, WM_MDUSERDLL_ADD, WM_MDUSERDLL_CHANGE, or WM_MDUSERDLL_DELETE message. The structure returned will contain complete details on the account which was added, deleted, or changed. When using this function along with a WM_MDUSERDLL_CHANGESEM or WM_MDUSERDLL_CHANGE event the returned structure will contain the values the account had BEFORE the changes were applied. The UserDefined member of the structure will contain the new email address for the account. This email address can then be used in a followup call to MD_GetUserInfo() to retrieve the new account details. The values within the returned structure are only good until the next event occurs. Therefore, do not perform operations with this structure directly. Rather, copy it to your own MD_UserInfo structure and use that. Example MD_UserInfo MyUserInfo; switch (WPARAM) { case WM_MDUSERDLL_ADD: case WM_MDUSERDLL_ADDSEM: { memcpy(&MyUserInfo, MD_GetUserInfo(), sizeof(MD_UserInfo)); char WorkBuffer[256]; sprintf(WorkBuffer, "Account added for: %s", MyUserInfo.FullName); break; } } Back to API reference
void MD_ReloadUsers() This function causes the DLL to completely reload it's internal storage of account information. Parameters none Return values none Remarks This function is used internally. You can call it yourself if you need to force the DLL to completely reload all account information. Example MD_ReloadUsers(); Back to API reference
void MD_SetIsMDConfig( bool IsMDConfig // TRUE if app using DLL is MDConfig ) This function is reserved for use with MDConfig. It is not available for other applications. Back to API reference
char* MD_GetAppDir( char* Buffer // buffer to receive path int BufLen // maximum length of Buf ) This function retrieves the path to the MDaemon APP directory and places it in Buffer. Parameters Buffer - character pointer that will receive the path to MDaemon's APP directory BufLen - maximum length of Buffer Return values The function returns Buffer which will contain a complete path to the MDaemon APP directory. Remarks Buffer should be at least MAX_PATH+1 chars long. Example char AppPath[MAX_PATH+1]; MD_GetAppDir(AppPath, MAX_PATH); Back to API reference
bool MD_GetDBPath( char* Buffer // buffer to receive path int Flag // integer specifying which database to get ) This function retrieves the complete path to any one of MDaemon's several configuration files. Parameters Buffer - character pointer that will receive the path to the specified configuration file. Buffer must be at least MAX_PATH+1 chars long. Flag - integer constant which determines which configuration file is returned. Valid values are: MDUSERDLL_MDAEMONINIDB - returns path to MDaemon.ini file MDUSERDLL_USERLISTDB - returns path to account database MDUSERDLL_DOMAINPOPDB - returns path to DomainPOP settings database MDUSERDLL_DOMAINDB - returns path to the domain database MDUSERDLL_HELPDB - returns path to the default help file MDUSERDLL_DELWARNDB - returns path to the delivery warning file MDUSERDLL_DELERRDB - returns path to the delivery error file MDUSERDLL_RECEIPTDB - returns path to the receipt confirmation file MDUSERDLL_NOCOMMANDDB - returns path to the 'no valid command' file MDUSERDLL_NOSUCHUSERDB - returns path to the 'no such user' file MDUSERDLL_ACCTINFODB - returns path to the account info file MDUSERDLL_WELCOMEDB - returns path to new account welcome file MDUSERDLL_UIDLDB - returns path to UIDL database MDUSERDLL_MIMETYPEDB - returns path to MIMETYPE database MDUSERDLL_ALIASDB - returns path to address alias database MDUSERDLL_TRANSLATEDB - returns path to the header translation database MDUSERDLL_TRANSEXCPTDB - returns path to translation exception database MDUSERDLL_WEBACCESSDB - returns path to webconfig access rights database MDUSERDLL_RFC822TMPDB - returns path to rfc822 MBF file MDUSERDLL_DIGESTTMPDB - returns path to digest MBF file MDUSERDLL_IPSHIELDDB - returns path to IP shielding database MDUSERDLL_FWDDB - returns path to account forwarding database MDUSERDLL_SIGDB - returns path to signature database MDUSERDLL_MAILFORMATDB - always returns path to mail format database MDUSERDLL_AUTORESPDB - returns path to auto responder database MDUSERDLL_GATEWAYDB - returns path to gateway domains database MDUSERDLL_REFUSALDB - returns path to message refusal file MDUSERDLL_LOCALONLYDB - returns path to local only message file MDUSERDLL_MULTIPOPDB - returns path to account MultiPOP database MDUSERDLL_IPCACHEDB - returns path to IP cache database MDUSERDLL_MXCACHEDB - returns path to MX cache database MDUSERDLL_NOCACHEDB - returns path to no cache database MDUSERDLL_PRIORITYDB - returns path to priority mail database MDUSERDLL_EXCEPTIONDB - returns path to priority mail exceptions database MDUSERDLL_DELUNLESSDB - returns path to 'delete unless' database MDUSERDLL_FWDUNLESSDB - returns path to 'forward unless' database MDUSERDLL_DVUNLESSDB - returns path to 'deliver unless' database MDUSERDLL_MSGIDDB - returns path to Message-ID database MDUSERDLL_LANDOMAINDB - returns path to lan domain database MDUSERDLL_IPSCREENDB - returns path to IP screening database MDUSERDLL_RELAYDB - returns path to mail relaying database MDUSERDLL_AUTHDB - returns path to outstanding sub/unsub auth database MDUSERDLL_SPAMBLOCKERDB - returns path to spam blocker database MDUSERDLL_SPAMEXCEPTDB - returns path to spam blocker exception database MDUSERDLL_SPAMCACHEDB - returns path to spam blocker cache database MDUSERDLL_LDAPDB - returns path to LDAP configuration file Return values This function returns TRUE if the specified database exists. Otherwise it returns FALSE. Remarks Use this function when you want to get the complete path to one of MDaemon's configuration files. Example char MDaemonIniFile[MAX_PATH+1]; if (MD_GetDBFile(MDaemonIniFile, MDUSERDLL_MDAEMONINIDB)) // do something with file else // handle error Back to API reference -------------------------- MESSAGE HANDLING FUNCTIONS -------------------------- What follows is a description of the message sending support built into the MDUSER.DLL file. These functions work by taking information from your program and using it to generate a RAW format message which MDaemon in turn processes and delivers. For complete details on the RAW message sub-system please consult the MDaemon manual. The following functions make use of the MD_MessageInfo structure to send an email message. Sending a message involves declaring one of these structure variables, initializing it, filling in the structure members, and calling the function which actually spools the message. Since the entire process depends on the MD_MessageInfo structure we will describe that first and then proceed to document the functions which use the structure. #define MDUSERDLL_MAXMSGTO_LEN 128 #define MDUSERDLL_MAXMSGFROM_LEN 128 #define MDUSERDLL_MAXMSGSUBJECT_LEN 128 #define MDUSERDLL_MAXMSGBODY_LEN 2048 struct MD_MessageInfo { char To[MDUSERDLL_MAXMSGTO_LEN+1]; char From[MDUSERDLL_MAXMSGFROM_LEN+1]; char Subject[MDUSERDLL_MAXMSGSUBJECT_LEN+1]; char MessageBody[MDUSERDLL_MAXMSGBODY_LEN+1]; char BodyFilePath[MAX_PATH+1]; char AttachmentFilePath[MAX_PATH+1]; bool RemoveAttachment; int Priority; }; Fields To - this field contains the name of the recipient of the email message. It can contain any value which MDaemon allows within the TO header of a RAW format message (see MDaemon manual for details) From - this field contains the name of the sender of the email message. It can contain any value which MDaemon allows within the FROM header of a RAW format message (see MDaemon manual for details) Subject - this field contains the subject of the email message. MessageBody - this field contains the text of the message body. BodyFilePath - this field contains the path to a text file that should be used as the message body. AttachmentFilePath - this field contains the path to a single file on disk which should be encoded and attached to the message. RemoveAttachment - if TRUE the file specified in AttachmentFilePath will be removed from disk once the message has been converted for sending by MDaemon. Priority - this field specifies the relative importance of this message. Remarks The MessageBody field has a maximum length of MDUSERDLL_MAXMSGBODY_LEN chars. If this is not enough space the text should be placed in a separate disk file and the BodyFilePath field should be used. Note that both can be used in the same structure. So, you can specify up to MDUSERDLL_MAXMSGBODY_LEN chars in the MessageBody field and place the rest in a text file for use with the BodyFilePath field. Only a single file can be specified in the AttachmentFilePath field. The RemoveAttachment field does not cause the attached file to be removed immediately. The file is removed by MDaemon once the RAW message is converted and fully prepared for delivery. This is done by MDaemon when the RAW queue is processed. The Priority field can contain any one of the following values: MD_PRECEDENCE_URGENT // an extremely important message MD_PRECEDENCE_HIGH // a message that is more important than normal MD_PRECEDENCE_NORMAL // this is the default for normal mail MD_PRECEDENCE_LOW // some system or robot generated mail MD_PRECEDENCE_BULK // default mailing list mail MD_PRECEDENCE_RETRY // messages in the retry queue Back to API reference
void MD_InitMessageInfo( MD_MessageInfo* MessageInfo // pointer to MD_MessageInfo struct ) The MD_InitMessageInfo structure initializes an MD_MessageInfo structure in preparation for sending an email message using MD_SpoolMessage. Parameters MessageInfo - pointer to an MD_MessageInfo structure. This members of this structure are cleared and the priority member is set to MD_PRECEDENCE_NORMAL. Remarks You should call this function immediately after declaring an MD_MessageInfo structure. Example MD_MessageInfo MessageInfo; MD_InitMessageInfo(&MessageInfo); Back to API reference
int MD_VerifyMessageInfo( MD_MessageInfo* MessageInfo // pointer to MD_MessageInfo struct ) The MD_VerifyMessageInfo structure verifies the content of the MessageInfo structure that is passed. This will insure that your message is valid for sending. Parameters MessageInfo - pointer to an MD_MessageInfo structure. The members of this structure are verified. Return values MDDLLERR_NOERROR - returned if the structure is valid. MDDLLERR_MISSINGTO - returned if the structure is missing the TO field. MDDLLERR_MISSINGFROM - returned if the structure is missing the FROM field. MDDLLERR_MISSINGBODY - returned if the structure is missing a message body and the BodyFilePath member of the passed structure is not provided. MDDLLERR_MISSINGBODYFILE - returned if the structure contains a file in the BodyFilePath member which doesn't exist. MDDLLERR_MISSINGATTACHMENTFILE - returned if the structure contains a file in the AttachmentFilePath member which doesn't exist. Remarks This function should be called when the MessgeInfo structure needs to be verified. This function is called from MD_SpoolMessage automatically. Example MD_MessageInfo* MessageInfo; MD_InitMessageInfo(&MessageInfo); // copy information into the MessageInfo members if (MD_VerifyMessageInfo(&MessageInfo) == MDDLLERR_NOERROR) // spool message else // handle error Back to API reference
int MD_SpoolMessage( MD_MessageInfo* MessageInfo // pointer to MD_MessageInfo structure ) The MD_SpoolMessage function creates the message and places it into MDaemon's mail queue. Parameters MessageInfo - pointer to an MD_MessageInfo structure. The data contained in this structure will be used to generate a mail message which MDaemon will queue and send. Return values (see MD_VerifyMessageInfo - any of those values could be returned) MDDLLERR_MISSINGRAWPATH - returned if the RAWFILES path could not be read from the MDaemon.ini file. MDDLLERR_CANTGENRAWFILENAME - returned if a new file name for the message could not be generated. MDDLLERR_CANTLOCKRAWFILE - returned if the new file name could not be locked. MDDLLERR_CANTCREATERAWFILE - returned if the new message file could not be created. MDDLLERR_CANTACCESSBODYFILE - returned if the MessageInfo specifies a body file which can't be accessed. Remarks The first thing this function does is call MD_VerifyMessageInfo passing the MessageInfo parameter to it. If an error results MD_SpoolMessage returns that error. MD_SpoolMessage attempts to generate a new RAW message file name, lock the file, create the RAW message, unlock the file, and return. If successful a new message in MDaemon's RAW message format will be placed into MDaemon's RAW message queue directory. MDaemon will then process and send the message at the next scheduled queue run. Example MD_MessageInfo MessageInfo; MD_InitMessageInfo(&MessageInfo); // copy information into the MessageInfo members if (MD_SpoolMessage(&MessageInfo) == MDDLLERR_NOERROR) // the message was successfully spooled else // handle error Back to API reference
int MD_GetDomainCount() This function returns the total number of domains currently being used. It includes the primary domain and all secondary domains. Return values This function returns the total number of domains currently being used. Back to API reference
void MD_GetDomainNames( char* Buffer // buffer to receive domain list int BufLen // length of buffer ) This function places all domain names into Buffer without exceeding BufLen. Parameters Buffer - this is the buffer which will receive the domain list BufLen - this is the maximum length of Buffer Remarks Buffer will contain a NULL separated list of all MDaemon domain names. The end of the string will be double NULL terminated. For example, the resulting string might look like this: "altn.com\0arvel.altn.com\0arvelh.com\0\0" If Buffer is not long enough to contain all the data then as many domain names as will fit will be placed into Buffer. To be sure that the size of Buffer is allocated with enough space you can do something like this: int Size = MD_GetDomainCount() * DOMAIN_LEN; char* Buffer = new char[Size + 1]; MD_GetDomainNames(Buffer, Size); char* ptr = Buffer; while (*ptr != '\0') { sprintf(Str, "Domain Name: %s", ptr); ptr += strlen(ptr)+1; } The primary domain is always the first domain in the returned list. Back to API reference
char* MD_GetDomainNameUsingIP( const char* IP // IP to match to a domain name char* Buffer // buffer to store domain name int BufLen // maximum length of Buffer ) This function attempts to find a domain name which matches a given IP address and return the result in Buffer. Parameters IP - This is the IP address of the domain you wish to find Buffer - When a domain is found it is placed in this field BufLen - maximum size of Buffer Return values If IP contains an IP address the function returns the first domain that is found which is using that IP address. If IP is blank or no match is found then the primary domain is returned. Remarks One way to get the primary domain name is to call this function and specify an empty string as the IP address. This function does not guarantee that the IP address you pass is in use by one of MDaemon's domains. If a match cannot be made the primary domain is returned. Back to API reference ---------------------------- ACCOUNT MANAGEMENT FUNCTIONS ---------------------------- The bulk of the functions within MDUSER.DLL pertain to account management. Several of these functions require an MD_UserInfo structure. So, we will begin by describing that. The MD_UserInfo structure is used to both set and retrieve user information. For example, when calling MD_GetUserInfo an MD_UserInfo structure is filled in with account details. When calling MD_SetUserInfo the MD_UserInfo structure is used to set account details and so must be filled in by your program prior to being used. For the following discussion the terms 'account' and 'user' are the same thing. #define DOMAIN_LEN 45 #define MAILBOX_LEN 30 #define FULLNAME_LEN 30 #define MAILDIR_LEN 90 #define PASSWORD_LEN 20 #define MAXMESSAGECOUNT_LEN 4 #define MAXDISKSPACE_LEN 6 #define EMAIL_LEN MAILBOX_LEN+DOMAIN_LEN+1 #define FWDADDR_LEN 256 #define FWDHOST_LEN 64 #define FWDSENDAS_LEN 128 #define FWDPORT_LEN 8 #define USERDEFINED_LEN 256 struct MD_UserInfo { char Email[EMAIL_LEN+1]; char Mailbox[MAILBOX_LEN+1]; char Domain[DOMAIN_LEN+1]; char FullName[FULLNAME_LEN+1]; char MailDir[MAILDIR_LEN+1]; char Password[PASSWORD_LEN+1]; bool AutoDecode; bool IsForwarding; bool AllowAccess; bool AllowChangeViaEmail; bool KeepForwardedMail; bool HideFromEveryone; bool EncryptMail; bool ApplyQuotas; bool EnableMultiPOP; bool LocalOnly; long MaxMessageCount; long MaxDiskSpace; int WebConfig; char FwdAddress[FWDADDR_LEN+1]; char FwdHost[FWDHOST_LEN+1]; char FwdSendAs[FWDSENDAS_LEN+1]; char FwdPort[FWDPORT_LEN+1]; char NTAccount[MAILBOX_LEN+1]; char MailFormat[MBXFORMAT_LEN+1]; char AutoRespScript[MAX_PATH+1]; char AutoRespProcess[MAX_PATH+1]; char AutoRespExclude[AUTORESPEXCLUDE_LEN+1]; char AddToList[EMAIL_LEN+1]; char RemoveFromList[EMAIL_LEN+1]; bool PassMessageToProcess; long MaxUIDLCount; long MaxMessageSize; char UserDefined[USERDEFINED_LEN+1]; }; Fields Email - this field contains the full email address for the account. Mailbox - this field contains the mailbox for the account. Domain - this field contains the domain the account belongs to. FullName - this field contains the user's full name. MailDir - this field contains the full path to the user's root mail dir. Password - this field contains the account's password. AutoDecode - TRUE if account is configured to auto-extract attachments. IsForwarding - TRUE if account is forwarding mail. AllowAccess - TRUE if account can access mailbox via POP/IMAP. AllowChangeViaEmail - TRUE if account can change settings via email. KeepForwardedMail - TRUE if account retains local copy of forwarded mail. HideFromEveryone - TRUE if account is hidden 'Everyone' mailing list. EncryptMail - TRUE if account is storing mail in an encrypted state. ApplyQuotas - TRUE if quotas are applied to account. EnableMultiPOP - TRUE if MultiPOP collection for account is active. LocalOnly - TRUE if account can only send to local addresses. MaxMessageCount - number of message account is allowed to store. MaxDiskSpace - number (in bytes) account's mail store can consume. WebConfig - bitmask specifying which WebConfig access rights are allowed. FwdAddress - the last known address the account is/was forwarding mail to. FwdHost - the last known host the account is/was forwarding mail thru. FwdSendAs - the last known HELO/EHLO value the account is/was using. FwdPort - the last known port the account was forwarding mail on. NTAccount - NT account name. MailFormat - mailbox storage format (MBF) file account is using. AutoRespScript - this is the full path to the account's auto responder script file. AutoRespProcess - this is the full path to a program the auto responder will execute. AutoRespExclude - this is a double null terminated list of addresses that are exempt from receiving the AutoRespScript file. AddToList - this is the mailing list the auto responder will sign people up to. RemoveFromList - this is the mailing list the auto responder will remove people from. PassMessageToProcess - TRUE if the message file triggering the auto responder should be passed to the AutoRespProcess program. MaxUIDLCount - max UIDL's to store for account's MultiPOP collection. MaxMessageSize - max message size MultiPOP collection will honor. UserDefined - user defined. Remarks When retrieving account information all these structure members will be filled in by MDaemon. When setting account information your application must fill in these data fields. The Password field contains the account's password in an unencrypted state. The WebConfig field is a bitmask that controls which access rights the account may have. Value masks are: MDUSERDLL_ACCESSWORLDCLIENT // account can access WorldClient MDUSERDLL_ACCESSWEBCONFIG // account can access WebConfig MDUSERDLL_ISADMIN // account has admin level access MDUSERDLL_EDITFULLNAME // account can change full name MDUSERDLL_EDITPASSWORD // account can change password MDUSERDLL_EDITMAILDIR // account can change mail directory MDUSERDLL_EDITFWD // account can change forwarding settings MDUSERDLL_EDITADVFWD // account can change adv. forwarding settings MDUSERDLL_EDITENCRYPT // account can change mail encryption flag MDUSERDLL_EDITEVERYONE // account can change hide from everyone flag MDUSERDLL_EDITLOCALONLY // account can change local only flag MDUSERDLL_EDITQUOTAS // account can change quota settings MDUSERDLL_EDITMULTIPOP // account can change multipop data MDUSERDLL_EDITAUTORESPONDER // account can change autoresponder settings MDUSERDLL_EDITEMAILCHANGES // account can change setting via email MDUSERDLL_EDITIMAPRULES // account can change IMAP mail rules via email The NTAccount field is only used by MDaemon during an import from the NT database operation. This field is not maintained by MDaemon. Its content is only valid during an import operation. IMAP rules are only available in the PRO version of MDaemon. The MaxDiskSpace and MaxMessageSize fields are values specified in BYTES. Back to API reference
int MD_UserCount() This function returns the total number of accounts in the account database. Parameters none Return value This function returns the total number of accounts in the account database. Example int Count = MD_UserCount(); Back to API reference
MD_FINDHANDLE MD_FindFirst( MD_HANDLE* hUser ) This function starts an iteration across the entire account database. Parameters hUser - pointer to an MD_HANDLE that receives the handle of the first account. Return values This function returns MD_BADFINDHANDLE if there are no accounts defined. Otherwise, it returns a valid MD_FINDHANDLE and sets hUser to a handle to the first account. Remarks This function is used to begin an iteration process. It is used in conjunction with MD_FindNext to perform operations on all accounts. The find handle that is returned by this function must be released by calling MD_FindClose. The account handle is released by MD_FindNext. If you do not call MD_FindNext, you should call MD_GetFree to release it. Example MD_HANDLE hUser; MD_FINDHANDLE hFind = MD_FindFirst(&hUser); if (hFind != MD_BADFINDHANDLE) { do { MD_UserInfo UserInfo; MD_GetUserInfo(hUser, &UserInfo); // do something useful with UserInfo } while (MD_FindNext(hFind, &hUser)); MD_FindClose(hFind); } Back to API reference
bool MD_FindNext( MD_FINDHANDLE hFind // find handle from MD_FindFirst MD_HANDLE* hUser // account handle from a previous call // to MD_FindFirst or MD_GetNextUser ) This function increments the search index to the next account. Parameters hFind - find handle returned by MD_FindFirst. hUser - pointer to an MD_HANDLE that receives the handle of the next account. The current handle that it points to is released Return values This function returns TRUE if there was another account, otherwise FALSE. Remarks The MD_FindFirst and MD_FindNext functions should be used when you need to iterate across every account in the database. The account handle is released by the next call to MD_FindNext. If you do not call MD_FindNext again, you should call MD_GetFree to release it. Example MD_HANDLE hUser; MD_FINDHANDLE hFind = MD_FindFirst(&hUser); if (hFind != MD_BADFINDHANDLE) { do { MD_UserInfo UserInfo; MD_GetUserInfo(hUser, &UserInfo); // do something useful with UserInfo } while (MD_FindNext(hFind, &hUser)); MD_FindClose(hFind); } Back to API reference
void MD_FindClose( MD_FINDHANDLE hFind // find handle from MD_FindFirst ) This function releases the find handle returned from MD_FindFirst. Parameters hFind - find handle returned by MD_FindFirst. Return values none Remarks Not calling this function can cause a memory leak. Do not attempt to use the find handle again after releasing it. Example MD_HANDLE hUser; MD_FINDHANDLE hFind = MD_FindFirst(&hUser); if (hFind != MD_BADFINDHANDLE) { do { MD_UserInfo UserInfo; MD_GetUserInfo(hUser, &UserInfo); // do something useful with UserInfo } while (MD_FindNext(hFind, &hUser)); MD_FindClose(hFind); } Back to API reference
MD_HANDLE MD_GetByEmail( const char* Email // email address of account to find ) This function searches the account database and returns the handle of the account which matches Email. Parameters Email - email address of account to look for Return values This function returns the database handle of the account which matches Email. It returns MD_BADHANDLE if no matching account is present. Remarks Use this function to retrieve the database handle of an account record when you know the email address of the account. The handle must be released after you're finished using it by calling MD_GetFree. Example MD_HANDLE hUser = MD_GetByEmail("arvel@altn.com"); if (hUser != MD_BADHANDLE) { MD_UserInfo UserInfo; MD_GetUserInfo(hUser, &UserInfo); // do something with UserInfo MD_GetFree(hUser); } else // handle error Back to API reference
MD_HANDLE MD_GetByFullName( const char* FullName // full name of account to find const char* Domain // domain to search ) This function searches the account database records for the Domain domain and returns the handle of the account which matches FullName. Parameters FullName - full name to search for Domain - domain to search for record matching FullName Return values This function returns the database handle of the account which is a member of Domain and which matches FullName. It returns MD_BADHANDLE if no matching account is present. Remarks Use this function to retrieve the database handle of an account record when you know the full name of the account. Since users with the same full name can be present across multiple different domains you must also specify the domain the search should be restricted to. The handle must be released after you're finished using it by calling MD_GetFree. Example MD_HANDLE hUser = MD_GetByFullName("Arvel Hathcock", "altn.com"); if (hUser != MD_BADHANDLE) { MD_UserInfo UserInfo; MD_GetUserInfo(hUser, &UserInfo); // do something with UserInfo MD_GetFree(hUser); } else // handle error Back to API reference
MD_HANDLE MD_GetByMailbox( const char* Mailbox // mailbox of account to find const char* Domain // domain to search ) This function searches the account database records for the Domain domain and returns the handle of the account which matches Mailbox. Parameters Mailbox - mailbox to search for Domain - domain to search for record matching Mailbox Return values This function returns the database handle of the account which is a member of Domain and which matches Mailbox. It returns MD_BADHANDLE if no matching account is present. Remarks Use this function to retrieve the database handle of an account record when you know the mailbox of the account. Since users with the same mailbox can be present across multiple different domains you must also specify the domain the search should be restricted to. Ordinarily this function is not useful since if you know the mailbox and the domain you know the email address and can simply call MD_GetByEmail. The handle must be released after you're finished using it by calling MD_GetFree. Example MD_HANDLE hUser = MD_GetByMailbox("arvel", "altn.com"); if (hUser != MD_BADHANDLE) { MD_UserInfo UserInfo; MD_GetUserInfo(hUser, &UserInfo); // do something with UserInfo MD_GetFree(hUser); } else // handle error Back to API reference
MD_HANDLE MD_GetByMailDir( const char* MailDir // mail directory of account to find const char* Domain // domain to search ) This function searches the account database records for the Domain domain and returns the handle of the account which matches MailDir. Parameters MailDir - Mail directory to search for Domain - domain to search for record matching MailDir Return values This function returns the database handle of the account which is a member of Domain and which matches MailDir. It returns MD_BADHANDLE if no matching account is present. Remarks Use this function to retrieve the database handle of an account record when you know the mail directory of the account. Since users with the same mail directory can be present across multiple different domains (although this is highly discouraged) you must also specify the domain the search should be restricted to. It is sometimes useful to share the same mail directory for multiple accounts but not often. The handle must be released after you're finished using it by calling MD_GetFree. Example MD_HANDLE hUser = MD_GetByMailDir("C:\\mdaemon\\users\\arvel\\", "altn.com"); if (hUser != MD_BADHANDLE) { MD_UserInfo UserInfo; MD_GetUserInfo(hUser, &UserInfo); // do something with UserInfo MD_GetFree(hUser); } else // handle error Back to API reference
MD_HANDLE MD_GetByAlias( char* Email // email address to translate const char* IP // optional IP address ) This function translates Email into a valid account if it is an alias. Parameters Email - pointer to buffer containing an email address. If Email matches an alias the counterpart to the alias is copied into Email. IP - optional pointer to buffer containing an IP address Return values If Email is an address alias the counterpart of that alias is copied into Email. This functions returns the database handle of the account which matches Email. It returns MD_BADHANDLE if no matching account is present. The handle must be released after you're finished using it by calling MD_GetFree. Remarks Take care to note that if Email matches a valid address alias it will be changed. Email must be at least EMAIL_LEN+1 chars long. The optional IP parameter is used only rarely. If Email does not contain a full email address (if it is a mailbox value only) an IP address in dotted decimal form can be passed. MDUSER.DLL will then perform a lookup into MDaemon's configuration files to determine which domain the IP belongs to. If a match is found then that is the domain that will be assumed to pertain to Email. If a match is NOT found the the primary domain will be used. The handle must be released after you're finished using it by calling MD_GetFree. Example Assume an alias exists within MDaemon: arvel@altn.com = frank@thomas.com char Email[EMAIL_LEN+1]; strcpy(Email, "arvel@altn.com"); MD_HANDLE hUser = MD_GetByAlias(Email, ""); // Email will now be equal to 'frank@thomas.com' if (hUser != MD_BADHANDLE) { // 'frank@thomas.com' is a local account! MD_GetFree(hUser); } else // 'frank@thomas.com' is NOT a local account. Back to API reference
void MD_GetFree( MD_HANDLE hUser // account handle to free ) This function frees internal memory associated with an account handle. Parameters hUser - Account handle to free. Account handles are returned by the MD_GetByXXX functions and MD_FindFirst/MD_FindNext. Return values none Remarks Not calling this function can cause a memory leak. Do not attempt to use the account handle again after releasing it. Example MD_HANDLE hUser = MD_GetByEmail("arvel@altn.com"); MD_GetFree(hUser); Back to API reference
bool MD_UserExists( const char* address // email address to look for ) This function returns TRUE if address is a local email account, is an alias for a local email account, or is a mailing list name. Parameters address - email address to look for Return value TRUE if the address is found, otherwise FALSE. Example if (MD_UserExists("arvel@altn.com")) // do something useful Back to API reference
void MD_InitUserInfo( MD_UserInfo* UserInfo // pointer to MD_UserInfo structure ) The MD_InitUserInfo structure is used to initialize all the members of the UserInfo structure to the correct defaults. Parameters UserInfo - pointer to an MD_UserInfo structure Return values None Remarks This function should be called immediately after declaring an MD_UserInfo variable. It is used to initialize all the members within the structure to the defaults for new accounts you have specified within MDaemon. Example MD_UserInfo UserInfo; MD_InitUserInfo(&UserInfo); Back to API reference
int MD_VerifyUserInfo( MD_UserInfo* UserInfo // pointer to MD_UserInfo structure int Level // bit-mask specifying verification level ) This function verifies the integrity of UserInfo. Parameters UserInfo - pointer to an MD_UserInfo structure containing the details of an account which need to be verified. Level - bit-masked integer used to specify how detailed a verification should be performed on UserInfo. Valid masks are: MDUSERDLL_VRFYACCOUNT - The Domain, Mailbox, FullName, and Password members within UserInfo will be checked for syntactical errors and use of reserved names. MDUSERDLL_VRFYMAILDIR - The MailDir member within UserInfo will be checked for syntactical errors. MDUSERDLL_VRFYFWD - The FwdAddress and IsForwarding members within UserInfo are verified. MDUSERDLL_VRFYQUOTAS - The MaxMessageCount and MaxDiskSpace members within UserInfo are verified. MDUSERDLL_VRFYOPTIONS - reserved MDUSERDLL_VRFYWEBCONFIG - reserved MDUSERDLL_VRFYMULTIPOP - reserved MDUSERDLL_VRFYALL - Verifies all the above elements. Return values MDDLLERR_NOERROR - no errors are present within UserInfo. MDDLLERR_INVALIDMAILBOX - returned if the Domain or Mailbox member within UserInfo is missing, contains a syntax error, or is set to a reserved value such as 'ListServ' or 'ProcNow'. MDDLLERR_POSTMASTER - returned if the Mailbox or FullName members within UserInfo is set to 'Postmaster'. The Postmaster account must be an alias. MDDLLERR_MBXHASDOMAIN - returned if the Mailbox member within UserInfo contains an '@' character. MDDLLERR_INVALIDFULLNAME - returned if the FullName member within UserInfo is missing, contains a syntax error, or is set to a reserved value such as 'MDaemon', 'ProcNow', etc. MDDLLERR_INVALIDPASSWORD - returned if the Password member within the UserInfo structure is missing, contains a syntax error, or is longer than 12 characters. MDDLLERR_INVALIDMAILDIR - returned if the MailDir member within the UserInfo structure is missing or contains a syntax error. Remarks This function should be called whenever the integrity of the data within UserInfo needs to be verified. MD_AddUser() automatically calls this function to verify UserInfo before adding new accounts. If Level includes MDUSERDLL_VRFYACCOUNT then the Domain, Mailbox, FullName, and Password members of the UserInfo structure are checked to make sure they are not missing. The Mailbox member is checked to ensure that it doesn't contains an '@' symbol. The 12 character limitation on the Password member within UserInfo is required due to the nature of the encryption method used upon it. This method is a 3 for 2 substitution algorithm which means a 20 byte space within the user record can only contain a 12 character value. This limitation is not imposed on dynamic password. Those may use the full length of the password field. if Level includes MDUSERDLL_VRFYMAILDIR the value of MailDir within the UserInfo structure will be certain to have a trailing backslash. if Level includes MDUSERDLL_VRFYFWD and the FwdAddress member within the UserInfo structure is missing the IsForwarding member will be set to FALSE. if Level includes MDUSERDLL_VRFYQUOTAS the MaxDiskSpace and MaxMessageCount members within UserInfo will be certain to contain valid values. When calling this function set Level to MDUSERDLL_VRFYALL to verify all the members of the UserInfo structure. Example MD_UserInfo UserInfo; MD_InitUserInfo(&UserInfo); // Check account related members only if (MD_VerifyUserInfo(&UserInfo, MDUSERDLL_VRFYACCOUNT) == MDDLLERR_NOERROR) // do whateverr else // handle error // Check account and forwarding members only if (MD_VerifyUserInfo(&UserInfo, MDUSERDLL_VRFYACCOUNT | MDUSERDLL_VRFYFWD) == MDDLLERR_NOERROR) // do whateverr else // handle error // Check all members if (MD_VerifyUserInfo(&UserInfo, MDUSERDLL_VRFYALL) == MDDLLERR_NOERROR) // do whateverr else // handle error Back to API reference
int MD_AddUser( MD_UserInfo* UserInfo // pointer to MD_UserInfo structure int Flags // reserved, must be 0 ) This function adds a new account to MDaemon's account database. Parameters UserInfo - pointer to an MD_UserInfo structure containing the details of the new account Flags - reserved, must be 0 Return values This function calls MD_VerifyUserInfo() passing MDUSERDLL_VRFYALL and will return any error returned from that function. MDUSERDLL_TOOMANYACCOUNTS - returned if adding the new account would exceed the maximum allowed. MDUSERDLL_USEREXISTS - retured if the new account would conflict with an existing account. Remarks This function will add a new account to MDaemon's account database. After successfully adding the account, MDUSER.DLL will send the WM_MDUSERDLL_MSG message passing WM_MDUSERDLL_ADD as the WPARAM argument to all registered applications (see MD_RegisterWindow). Example MD_UserInfo UserInfo; // Copy new account defaults into structure MD_InitUserInfo(&UserInfo); // copy data into UserInfo members strcpy(UserInfo.FullName, "Arvel Hathcock"); strcpy(UserInfo.Domain, "altn.com"); strcpy(UserInfo.Mailbox, "arvel"); strcpy(UserInfo.MailDir, "c:\\mdaemon\\users\\arvel\\"); if (MD_AddUser(&UserInfo, 0) == MDDLLERR_NOERROR) // account added ok else // handle error Back to API reference
bool MD_DeleteUser( char* Email // email address of account to be deleted int Flags // bit-mask specifying deletion level ) This function deletes an account from MDaemon's account database and from any associated database (such as auto responder, forwarding, etc..) Parameters Email - the complete email address of the account to be deleted Flags - bit-mask specifying the level of deletion that should be performed on Email. Valid values are: MDUSERDLL_DUSERLISTDB - remove the account from the account database. MDUSERDLL_DAUTORESPDB - remove the account's auto responder database entries. MDUSERDLL_DFWDDB - remove the account's mail forwarding database entries. MDUSERDLL_DMAILFORMATDB - remove the account's mail format database entry. MDUSERDLL_DWEBACCESSDB - remove the account's webconfig access rights database entry. MDUSERDLL_DMULTIPOPDB - remove the account's MultiPOP database entries. MDUSERDLL_DALIASDB - remove the account's address alias database entries. MDUSERDLL_DREMOVEDIR - remove the account's mail directory and delete all mail. MDUSERDLL_DDELETEALL - removes all of the above items completely deleting the account. Return values This function returns TRUE if the delete operation was successful, otherwise returns FALSE. If Flags includes MDUSERDLL_DUSERLISTDB and the operation is successful MDUSER.DLL will send the WM_MDUSERDLL_MSG message passing WM_MDUSERDLL_DELETE as the WPARAM argument to all registered applications (see MD_RegisterWindow). Remarks Use this function to delete an entry either in part or in whole. This function should not be called from within MD_FindNext loop. Example // Delete the account's alias entries if (MD_DeleteUser("arvel@altn.com", MDUSERDLL_DALIASDB)) // do whateverr else // handle error // Delete the account's MultiPOP entries and auto responder if (MD_DeleteUser("arvel@altn.com", MDUSERDLL_DMULTIPOPDB | MDUSERDLL_DAUTORESPDB)) // do whateverr else // handle error // Completely delete the account - bye bye if (MD_DeleteUser("arvel@altn.com", MDUSERDLL_DDELETEALL)) // do whateverr else // handle error Back to API reference
void MD_ChangeUser( MD_UserInfo* UserInfo // old pre-change account information char* NewEmail // email address post change bool UpdateMailDir // update mail location? ) This function updates database files to reflect new account information. Parameters UserInfo - pointer to MD_UserInfo structure which contains the old account settings prior to any changes. NewEmail - pointer to the new email address AFTER all changes have been made. UpdateMailDir - TRUE if account's mail should be moved to a new location when a domain used in a mail directory has been changed. Return values none Remarks This function is not normally and should not normally be called from your application. Applications should use MD_SetUserInfo to properly commit account changes to disk. This function is only provided for cases in which an application makes direct disk edits to the account database and needs to reflect those changes to other databases. Example MD_UserInfo OldUserInfo; MD_GetUserInfo(hUser, &OldUserInfo); // make your direct edits to MDaemon configuration files here MD_ChangeUser(&OldUserInfo, "newmailbox@domain.com", FALSE); Back to API reference
MD_UserInfo* MD_GetUserInfo( MD_HANDLE hUser // handle of account record to retrieve MD_UserInfo* UserInfo // structure which will retain account info ) This function retrieves a complete account record. Parameters hUser - handle of account record to retrieve. UserInfo - pointer to MD_UserInfo structure which will be filled with account data. Return values This function returns UserInfo. Remarks If hUser is invalid, UserInfo will be initialized to default settings (see MD_InitUserInfo). Otherwise, UserInfo is filled with the settings associated with the account specified by hUser. Use one of the search functions to retrieve the handle for a specific account. Example MD_UserInfo UserInfo; MD_HANDLE hUser = MD_GetByEmail("arvel@altn.com"); if (hUser != MD_BADHANDLE) { MD_GetUserInfo(hUser, &UserInfo); // do something with UserInfo MD_GetFree(hUser); } else // handle error Back to API reference
bool MD_SetUserInfo( MD_HANDLE hUser // handle of account record to store MD_UserInfo* UserInfo // structure which will contain account info ) This function commits a complete account record to disk. Parameters hUser - handle of account record to store. UserInfo - pointer to MD_UserInfo structure which must contain valid account data. Return values This function returns TRUE if hUser points to a valid account, FALSE otherwise. Remarks This function commits changes made to an account record to disk. Each member of UserInfo is updated to disk. It is important that the data be correct and verified using MD_VerifyUserInfo. MDUSER.DLL will send the WM_MDUSERDLL_MSG message passing WM_MDUSERDLL_CHANGE as the WPARAM argument to all registered applications (see MD_RegisterWindow). Example MD_HANDLE hUser = MD_GetByEmail("arvel@altn.com"); if (hUser != MD_BADHANDLE) { MD_UserInfo UserInfo; MD_GetUserInfo(hUser, &UserInfo); strcpy(UserInfo.Mailbox, "frank"); strcpy(UserInfo.Domain, "thomas.com"); if (MD_VerifyUserInfo(&UserInfo, MDUSERDLL_VRFYALL) == MDDLLERR_NOERROR) MD_SetUserInfo(hUser, &UserInfo); else // handle error MD_GetFree(hUser); } else // handle error Back to API reference
bool MD_LogonUser( char* Email // email address const char* Password // password const char* IP // optional IP address ) This function performs a logon attempt. Parameters Email - pointer to buffer containing an email address. If Email matches an alias the counterpart to the alias is copied into Email. Password - pointer to buffer containing an account password. IP - optional pointer to buffer containing an IP address Return values This function returns true if Password matches the password for Email. In other words if Email and Password correspond to a valid local account this function returns TRUE. It otherwise returns FALSE. Remarks If Email is an address alias the counterpart of that alias is copied into Email. After which a check is made to see if Email is a valid local account. If so, then that accounts password is compared to Password and the result is returned. Take care to note that if Email matches a valid address alias it will be changed. Email must be at least EMAIL_LEN+1 chars long. The optional IP parameter is used only rarely. If Email does not contain a full email address (if it is a mailbox value only) an IP address in dotted decimal form can be passed. MDUSER.DLL will then perform a lookup into MDaemon's configuration files to determine which domain the IP belongs to. If a match is found then that is the domain that will be assumed to pertain to Email. If a match is NOT found the the primary domain will be used. If Email matches to a local account and that account is configured for dynamic Windows NT authentication then MDUSER.DLL attempts to verify the Password by attempting a logon to the NT domain the account is configured to use. If the logon is successful the function returns TRUE otherwise FALSE. This function actually calls MD_ValidateUser to perform most of the work. Example Assume 'arvel@altn.com' is a local account with password 'ALTN' char Email[EMAIL_LEN+1]; strcpy(Email, "arvel@altn.com"); if (MD_LogonUser(Email, "ALTN", "")) // account is local and 'ALTN' is the correct password else // incorrect password or Email is not local Back to API reference
bool MD_ValidateUser( MD_HANDLE hUser // handle to a valid account database record const char* Password // password ) This function performs a logon attempt. Parameters hUser - handle of the account database record about to be verified. Password - pointer to buffer containing an account password. Return values This function returns true if Password matches the password for the account pointed to by hUser. It otherwise returns FALSE. Remarks Unlike MD_LogonUser, this function does not perform any address alias translation and requires a valid handle to an account record. It is therefore only applicable in situation where you already have a valid account handle and are only interested in determining the validity of the account's password. Normally, you should ALWAYS use MD_LogonUser. Example MD_HANDLE hUser = MD_GetByEmail("arvel@altn.com"); if (hUser != MD_BADHANDLE) { if (MD_ValidateUser(hUser, "ALTN")) // the password is correct for this account MD_GetFree(hUser); } Back to API reference
void MD_FilterUserInfo( MD_UserInfo* UserInfo // UserInfo structure containing account details ) This function takes the members of UserInfo that are given and expands the default Mailbox, Password, and MailDir templates. It also fills in the full name field if it is missing. Parameters UserInfo - pointer to MD_UserInfo structure which will be updated with new values for the Mailbox, Password, and MailDir members. Return value none Remarks This function takes a UserInfo structure that contains empty Mailbox, Password, and MailDir members and expands them according to the new account default settings within MDaemon. For example, if the MailDir template for new accounts is set to: C:\MDaemon\Users\$DOMAIN$\$MAILBOX$\ then this function can be called to expand that template and place the result into the MailDir member. The Mailbox, Password, and MailDir members must be empty or they will not be altered. If the Full Name field is empty the Mailbox field content will be copied into the Full Name field. MD_FilterUserInfo filters each string by passing it to MD_FilterString. Example Assume the following template values for new accounts are configured within MDaemon: MailBox: $USERFIRSTINITIAL$$USERLASTNAME$ Password: Pass-$USERFIRSTNAME$ MailDir: C:\MDaemon\Users\$DOMAIN$\$MAILBOX$\ MD_UserInfo UserInfo; MD_InitUserInfo(&UserInfo); // at this point UserInfo.Mailbox, UserInfo.Password, and UserInfo.MailDir // will be empty strings. strcpy(UserInfo.FullName, "Arvel Hathcock"); strcpy(UserInfo.Domain, "altn.com"); MD_FilterUserInfo(&UserInfo); // at this point UserInfo.Mailbox will be 'AHathcock', UserInfo.Password // will be 'Pass-Arvel', and UserInfo.MailDir will be // 'C:\MDaemon\Users\altn.com\AHathcock\' Back to API reference
char* MD_FilterString( char* Buffer // buffer containing macros to be filtered int BufLen // maximum length of buffer MD_UserInfo* UserInfo // account settings ) This function takes data from UserInfo using it to replace macros contained in Buffer. Parameters Buffer - pointer to string containing macros to be filtered (expanded). BufLen - the maximum length of Buffer. UserInfo - structure containing user data. This data is used to expand macros found in Buffer. Return values This function returns the filtered (expanded) string. Remarks This function is used to transform a string with macros into a string with real data. For example, if Buffer was equal to 'C:\MDaemon\Users\$DOMAIN$\ $MAILBOX$\' data from UserInfo would be taken to fill the $DOMAIN$ and $MAILBOX$ macros. For a complete list of macros available for use with this function consult the MDaemon manual. Example char MyTemplate[256]; strcpy(MyTemplate, "New account for $DOMAIN$ added, mailbox = $MAILBOX$"); MD_UserInfo UserInfo; MD_GetUserInfo(hUser, &UserInfo) FilterString(MyTemplate, 255, &UserInfo); Back to API reference
char* MD_GetEmail( MD_HANDLE hUser // handle to a valid account record char* Buffer // buffer to contain new data ) This function gets the email address for the account specified by hUser. Parameters hUser - handle to a valid account record. Buffer - buffer to retrieve account data. Return values This function returns Buffer or '\0' if hUser does not point to a valid account. Remarks Buffer must be at least EMAIL_LEN+1 chars long. Example char Buffer[EMAIL_LEN+1]; MD_GetEmail(hUser, Buffer); Back to API reference
char* MD_GetMailbox( MD_HANDLE hUser // handle to a valid account record char* Buffer // buffer to contain new data ) This function gets the mailbox for the account specified by hUser. Parameters hUser - handle to a valid account record. Buffer - buffer to retrieve account data. Return values This function returns Buffer or '\0' if hUser does not point to a valid account. Remarks Buffer must be at least MAILBOX_LEN+1 chars long. Example char Buffer[MAILBOX_LEN+1]; MD_GetMailbox(hUser, Buffer); Back to API reference
void MD_SetMailbox( MD_HANDLE hUser, // handle to a valid account record const char* Buffer // buffer containing new data ) This function sets the mailbox for the account specified by hUser. Parameters hUser - handle to a valid account record. Buffer - buffer containing new account data. Return values none Remarks Care should be taken to ensure setting mailbox to Buffer will not cause a conflict with another account. MD_SetUserInfo is the recommended method of setting account data because it has error checking. Example MD_SetMailbox(hUser, "newmailbox"); Back to API reference
char* MD_GetDomain( MD_HANDLE hUser // handle to a valid account record char* Buffer // buffer to contain new data ) This function gets the domain for the account specified by handle. Parameters hUser - handle to a valid account record. Buffer - buffer to retrieve account data. Return values This function returns Buffer or '\0' if hUser does not point to a valid account. Remarks Buffer must be at least DOMAIN_LEN+1 chars long. Example char Buffer[DOMAIN_LEN+1]; MD_GetDomain(hUser, Buffer); Back to API reference
void MD_SetDomain( MD_HANDLE hUser // handle to a valid account record const char* Buffer // buffer containing new data ) This function sets the domain for the account specified by handle. Parameters hUser - handle to a valid account record. Buffer - buffer containing new account data. Return values none Remarks Care should be taken to ensure setting domain to Buffer will not cause a conflict with another account. MD_SetUserInfo is the recommended method of setting account data because it has error checking. Example MD_SetDomain(hUser, "altn.com"); Back to API reference
char* MD_GetFullName( MD_HANDLE hUser // handle to a valid account record char* Buffer // buffer to contain new data ) This function gets the full name for the account specified by hUser. Parameters hUser - handle to a valid account record. Buffer - buffer to retrieve account data. Return values This function returns Buffer or '\0' if hUser does not point to a valid account. Remarks Buffer must be at least FULLNAME_LEN+1 chars long. Example char Buffer[FULLNAME_LEN+1]; MD_GetFullName(hUser, Buffer); Back to API reference
void MD_SetFullName( MD_HANDLE hUser // handle to a valid account record const char* Buffer // buffer containing new data ) This function sets the full name for the account specified by hUser. Parameters hUser - handle to a valid account record. Buffer - buffer containing new account data. Return values none Remarks Care should be taken to ensure setting full name to Buffer will not cause a conflict with another account. MD_SetUserInfo is the recommended method of setting account data because it has error checking. Example MD_SetFullName(hUser, "Frank Thomas"); Back to API reference
char* MD_GetMailDir( MD_HANDLE hUser // handle to a valid account record char* Buffer // buffer to contain new data ) This function gets the mail directory for the account specified by hUser. Parameters hUser - handle to a valid account record. Buffer - buffer to retrieve account data. Return values This function returns Buffer or '\0' if hUser does not point to a valid account. Remarks Buffer must be at least MAILDIR_LEN+1 chars long. Example char Buffer[MAILDIR_LEN+1]; MD_GetMailDir(hUser, Buffer); Back to API reference
void MD_SetMailDir( MD_HANDLE hUser // handle to a valid account record const char* Buffer // buffer containing new data ) This function sets the mail directory for the account specified by hUser. Parameters hUser - handle to a valid account record. Buffer - buffer containing new account data. Return values none Remarks Care should be taken to ensure setting domain to Buffer will not cause a conflict with another account. MD_SetUserInfo is the recommended method of setting account data because it has error checking. Example MD_SetMailDir(hUser, "C:\MDaemon\App\Altn\Arvel\"); Back to API reference
char* MD_GetPassword( MD_HANDLE hUser // handle to a valid account record char* Buffer // buffer to contain new data ) This function gets the password for the account specified by hUser. Parameters hUser - handle to a valid account record. Buffer - buffer to retrieve account data. Return values This function returns Buffer or '\0' if hUser does not point to a valid account. Remarks Buffer must be at least PASSWORD_LEN+1 chars long. Example char Buffer[PASSWORD_LEN+1]; MD_GetPassword(hUser, Buffer); Back to API reference
void MD_SetPassword( MD_HANDLE hUser // handle to a valid account record const char* Buffer // buffer containing new data ) This function sets the password for the account specified by hUser. Parameters hUser - handle to a valid account record. Buffer - buffer containing new account data. Return values none Remarks The password is encrypted and stored. If it is more than 12 characters long the password will be truncated. MD_SetUserInfo is the recommended method of setting account data because it has error checking. Example MD_SetPassword(hUser, "ALTN"); Back to API reference
bool MD_GetWebConfigBit( MD_HANDLE hUser // handle to a valid account record int Bit // bit-mask specifying which bit to retrieve ) This function returns a specific WebConfig access right for an account. Parameters hUser - handle to a valid account record. Bit - bit-mask specifying which WebConfig access right is being queried. Valid values are: MDUSERDLL_ACCESSWORLDCLIENT - query the Access WorldClient right. MDUSERDLL_ACCESSWEBCONFIG - query the Access WebConfig right. MDUSERDLL_ISADMIN - query the Is Admin Level access right. MDUSERDLL_EDITFULLNAME - query the Edit Full Name right. MDUSERDLL_EDITPASSWORD - qeury the Edit Password right. MDUSERDLL_EDITMAILDIR - query the Edit Mail Directory right. MDUSERDLL_EDITFWD - query the Edit Forwarding Info right. MDUSERDLL_EDITADVFWD - query the Edit Advanced Forwarding right. MDUSERDLL_EDITENCRYPT - query the Edit Encryption right. MDUSERDLL_EDITEVERYONE - query the Edit Everyone right. MDUSERDLL_EDITLOCALONLY - query the Edit Local Only right. MDUSERDLL_EDITQUOTAS - query the Edit Quotas right. MDUSERDLL_EDITMULTIPOP - query the toggle MultiPOP right. MDUSERDLL_EDITAUTORESPONDER - query the Edit Auto Responder right. MDUSERDLL_EDITEMAILCHANGES - query the Edit Allow Email Changes right. MDUSERDLL_EDITIMAPRULES - query the Edit IMAP rules right. For details on what these specific rights mean consult the MDaemon manual in the section related to creating/editing accounts. Return values This function returns TRUE if the specified access bit is enabled. Otherwise if returns FALSE. Remarks This function should not normally be used by your application. Instead use one of the following predefined macros: MD_GetAccessWorldClient MD_GetAccessWebConfig MD_GetIsAdmin MD_GetEditFullName MD_GetEditPassword MD_GetEditMailDir MD_GetEditFwd MD_GetEditAdvFwd MD_GetEditEncrypt MD_GetEditEveryone MD_GetEditLocalOnly MD_GetEditQuotas MD_GetEditMultiPOP MD_GetEditAutoResponder MD_GetEditEmailChanges MD_GetEditIMAPRules Each of these macros calls MD_GetWebConfigBit with the appropriate bit-mask values. Example int hUser = MD_GetFirstUser(); if (MD_GetWebConfigBit(Index, MDUSERDLL_ACCESSWORLDCLIENT)) // do something useful if (MD_GetAccessWorldClient(hUser)) // do something useful Back to API reference
void MD_SetWebConfigBit( MD_HANDLE hUser // handle to a valid account record int Bit // bit-mask specifying which bit to set bool Value // value to set bit to ) This function sets a specific WebConfig access right for an account. Parameters hUser - handle to a valid account record. Bit - bit-mask specifying which WebConfig access right is being set. Valid values are: MDUSERDLL_ACCESSWORLDCLIENT - set the Access WorldClient right. MDUSERDLL_ACCESSWEBCONFIG - set the Access WebConfig right. MDUSERDLL_ISADMIN - set the Is Admin Level access right. MDUSERDLL_EDITFULLNAME - set the Edit Full Name right. MDUSERDLL_EDITPASSWORD - set the Edit Password right. MDUSERDLL_EDITMAILDIR - set the Edit Mail Directory right. MDUSERDLL_EDITFWD - set the Edit Forwarding Info right. MDUSERDLL_EDITADVFWD - set the Edit Advanced Forwarding right. MDUSERDLL_EDITENCRYPT - set the Edit Encryption right. MDUSERDLL_EDITEVERYONE - set the Edit Everyone right. MDUSERDLL_EDITLOCALONLY - set the Edit Local Only right. MDUSERDLL_EDITQUOTAS - set the Edit Quotas right. MDUSERDLL_EDITMULTIPOP - set the toggle MultiPOP right. MDUSERDLL_EDITAUTORESPONDER - set the Edit Auto Responder right. MDUSERDLL_EDITEMAILCHANGES - set the Edit Allow Email Changes right. MDUSERDLL_EDITIMAPRULES - set the Edit IMAP Rules right. For details on what these specific rights mean consult the MDaemon manual in the section related to creating/editing accounts. Return values none Remarks This function should not normally be used by your application. Instead use one of the following predefined macros: MD_SetAccessWorldClient MD_SetAccessWebConfig MD_SetIsAdmin MD_SetEditFullName MD_SetEditPassword MD_SetEditMailDir MD_SetEditFwd MD_SetEditAdvFwd MD_SetEditEncrypt MD_SetEditEveryone MD_SetEditLocalOnly MD_SetEditQuotas MD_SetEditMultiPOP MD_SetEditAutoResponder MD_SetEditEmailChanges MD_SetEditIMAPRules Each of these macros calls MD_SetWebConfigBit with the appropriate bit-mask values. Example MD_SetWebConfigBit(hUser, MDUSERDLL_ACCESSWORLDCLIENT, false); MD_SetAccessWorldClient(hUser, false); Back to API reference
bool MD_GetAutoDecode( MD_HANDLE hUser // handle to a valid account record ) This function gets the state of the auto decode flag for the account specified by hUser. Parameters hUser - handle to a valid account record. Return values This function returns TRUE if the account is set to auto decode attachments. Otherwise it returns FALSE. Remarks none Example if (MD_GetAutoDecode(hUser)) // do something useful Back to API reference
void MD_SetAutoDecode( MD_HANDLE hUser // handle to a valid account record bool Value // new value ) This function sets the state of the auto decode flag for the account specified by hUser. Parameters hUser - handle to a valid account record. Value - buffer containing new account data. Return values none Remarks MD_SetUserInfo is the recommended method of setting account data because it has error checking. Example MD_SetAutoDecode(hUser, false); Back to API reference
bool MD_GetIsForwarding( MD_HANDLE hUser // handle to a valid account record ) This function gets the state of the forwarding flag for the account specified by hUser. Parameters hUser - handle to a valid account record. Return values This function returns TRUE if the account is set to forward mail. Otherwise it returns FALSE. Remarks none Example if (MD_GetIsForwarding(hUser)) // do something useful Back to API reference
void MD_SetIsForwarding( MD_HANDLE hUser // handle to a valid account record bool Value // new value ) This function sets the state of the forwarding flag for the account specified by hUser. Parameters hUser - handle to a valid account record. Value - buffer containing new account data. Return values none Remarks Be sure to also set a forwarding address using the MD_SetForwardingInfo function if you enable forwarding using this function. MD_SetUserInfo is the recommended method of setting account data because it has error checking. Example MD_SetIsForwarding(hUser, false); Back to API reference
bool MD_GetAllowAccess( MD_HANDLE hUser // handle to a valid account record ) This function gets the state of the allow access flag for the account specified by hUser. Parameters hUser - handle to a valid account record. Return values This function returns TRUE if the account is set to allow access. Otherwise it returns FALSE. Remarks none Example if (MD_GetAllowAccess(hUser)) // do something useful Back to API reference
void MD_SetAllowAccess( MD_HANDLE hUser // handle to a valid account record bool Value // new value ) This function sets the state of the allow access flag for the account specified by hUser. Parameters hUser - handle to a valid account record. Value - buffer containing new account data. Return values none Remarks MD_SetUserInfo is the recommended method of setting account data because it has error checking. Example MD_SetAllowAccess(hUser, true); Back to API reference
bool MD_GetAllowChangeViaEmail( MD_HANDLE hUser // handle to a valid account record ) This function gets the state of the allow change via email flag for the account specified by hUser. Parameters hUser - handle to a valid account record. Return values This function returns TRUE if the account is set to allow changes via email. Otherwise it returns FALSE. Remarks none Example if (MD_GetAllowChangeViaEmail(hUser)) // do something useful Back to API reference
void MD_SetAllowChangeViaEmail( MD_HANDLE hUser // handle to a valid account record bool Value // new value ) This function sets the state of the allow change via email flag for the account specified by hUser. Parameters hUser - handle to a valid account record. Value - buffer containing new account data. Return values none Remarks MD_SetUserInfo is the recommended method of setting account data because it has error checking. Example MD_SetAllowChangeViaEmail(hUser, false); Back to API reference
bool MD_GetKeepForwardedMail( MD_HANDLE hUser // handle to a valid account record ) This function gets the state of the keep forwarded mail flag for the account specified by hUser. Parameters hUser - handle to a valid account record. Return values This function returns TRUE if the account is set to keep copies of forwarded mail. Otherwise it returns FALSE. Remarks none Example if (MD_GetKeepForwardedMail(hUser)) // do something useful Back to API reference
void MD_SetKeepForwardedMail( MD_HANDLE hUser // handle to a valid account record bool Value // new value ) This function sets the state of the keep forwarded mail flag for the account specified by hUser. Parameters hUser - handle to a valid account record. Value - buffer containing new account data. Return values none Remarks MD_SetUserInfo is the recommended method of setting account data because it has error checking. Example MD_SetKeepForwardedMail(hUser, false); Back to API reference
bool MD_GetHideFromEveryone( MD_HANDLE hUser // handle to a valid account record ) This function gets the state of the hide from everyone flag for the account specified by hUser. Parameters hUser - handle to a valid account record. Return values This function returns TRUE if the account is set to hide from the everyone lists. Otherwise it returns FALSE. Remarks none Example if (MD_GetHideFromEveryone(hUser)) // do something useful Back to API reference
void MD_SetHideFromEveryone( MD_HANDLE hUser // handle to a valid account record bool Value // new value ) This function sets the state of the hide from everyone flag for the account specified by hUser. Parameters hUser - handle to a valid account record. Value - buffer containing new account data. Return values none Remarks MD_SetUserInfo is the recommended method of setting account data because it has error checking. Example MD_SetHideFromEveryone(hUser, false); Back to API reference
bool MD_GetEncryptMail( MD_HANDLE hUser // handle to a valid account record ) This function gets the state of the encrypt mail flag for the account specified by hUser. Parameters hUser - handle to a valid account record. Return values This function returns TRUE if the account is set to encrypt mail. Otherwise it returns FALSE. Remarks none Example if (MD_GetEncryptMail(hUser)) // do something useful Back to API reference
void MD_SetEncryptMail( MD_HANDLE hUser // handle to a valid account record bool Value // new value ) This function sets the state of the encrypt mail flag for the account specified by hUser. Parameters hUser - handle to a valid account record. Value - buffer containing new account data. Return values none Remarks MD_SetUserInfo is the recommended method of setting account data because it has error checking. Example MD_SetEncryptMail(hUser, false); Back to API reference
bool MD_GetApplyQuotas( MD_HANDLE hUser // handle to a valid account record ) This function gets the state of the apply quotas flag for the account specified by hUser. Parameters hUser - handle to a valid account record. Return values This function returns TRUE if the account is set subject to quota restrictions. Otherwise it returns FALSE. Remarks none Example if (MD_GetApplyQuotas(hUser)) // do something useful Back to API reference
void MD_SetApplyQuotas( MD_HANDLE hUser // handle to a valid account record bool Value // new value ) This function sets the state of the apply quotas flag for the account specified by hUser. Parameters hUser - handle to a valid account record. Value - buffer containing new account data. Return values none Remarks If you call this function with a Value of TRUE you should also make certain that there are valid quota values by calling MD_SetMaxMessageCount and/or MD_SetMaxDiskSpace. MD_SetUserInfo is the recommended method of setting account data because it has error checking. Example MD_SetApplyQuotas(hUser, false); Back to API reference
bool MD_GetEnableMultiPOP( MD_HANDLE hUser // handle to a valid account record ) This function gets the state of the enable MultiPOP flag for the account specified by hUser. Parameters hUser - handle to a valid account record. Return values This function returns TRUE if MultiPOP collection for the account is active. Otherwise it returns FALSE. Remarks none Example if (MD_GetEnableMultiPOP(hUser)) // do something useful Back to API reference
void MD_SetEnableMultiPOP( MD_HANDLE hUser // handle to a valid account record bool Value // new value ) This function sets the state of the enable MultiPOP flag for the account specified by hUser. Parameters hUser - handle to a valid account record. Value - buffer containing new account data. Return values none Remarks This function only turns MultiPOP on or off. It does not configure individual MultiPOP account entries. MD_SetUserInfo is the recommended method of setting account data because it has error checking. Example MD_SetEnableMultiPOP(hUser, false); Back to API reference
bool MD_GetLocalOnly( MD_HANDLE hUser // handle to a valid account record ) This function gets the state of the local only flag for the account specified by hUser. Parameters hUser - handle to a valid account record. Return values This function returns TRUE if the local only flag for the account is set. Otherwise it returns FALSE. Remarks none Example if (MD_GetLocalOnly(hUser)) // do something useful Back to API reference
void MD_SetLocalOnly( MD_HANDLE hUser // handle to a valid account record bool Value // new value ) This function sets the state of the local opnly flag for the account specified by hUser. Parameters hUser - handle to a valid account record. Value - buffer containing new account data. Return values none Remarks MD_SetUserInfo is the recommended method of setting account data because it has error checking. Example MD_SetLocalOnly(hUser, false); Back to API reference
char* MD_GetMailFormat( MD_HANDLE hUser // handle to a valid account record char* Buffer // buffer which receives account info ) This function gets the name of the MBF file or the account specified by hUser. Parameters hUser - handle to a valid account record. Buffer - buffer to received account data. Return values This function returns Buffer. Remarks Buffer should be at least MAX_PATH+1 chars long. Example char MBF[MAX_PATH+1]; MD_GetMailFormat(hUser, MBF); Back to API reference
void MD_SetMailFormat( MD_HANDLE hUser // handle to a valid account record const char* Value // new value ) This function sets the MBF file the account is using to Value. Parameters hUser - handle to a valid account record. Value - buffer containing new account data. Return values none Remarks This function sets the MBF file the account is using to Value. Value must be the name of an MBF file located within MDaemon's APP directory. The file must exist. Since 'RFC822.MBF' is the default mail format for all accounts calling this function with an argument of 'RFC822.MBF' is ignored. When specifying Value, specify only the file name - not a complete path. The file must be located in MDaemon's APP directory. MD_SetUserInfo is the recommended method of setting account data because it has error checking. Example MD_SetMailFormat(hUser, "RFC822.MBF"); Back to API reference
long MD_GetMaxDiskSpace( MD_HANDLE hUser // handle to a valid account record ) This function gets the maximum disk space quota for an account. Parameters hUser - handle to a valid account record. Return values This function returns the maximum disk space quota (in BYTES). Remarks none Example long Max = MD_GetMaxDiskSpace(hUser); // do something useful Back to API reference
void MD_SetMaxDiskSpace( MD_HANDLE hUser // handle to a valid account record long Value // new value ) This function sets the maximum disk space quota for an account. Parameters hUser - handle to a valid account record. Value - new maximum disk space quota (in BYTES). Return values none Remarks Specify a value of 0 and there will be no limit to disk space usage. MD_SetUserInfo is the recommended method of setting account data because it has error checking. Example MD_SetMaxDiskSpace(hUser, 500000); Back to API reference
long MD_GetMaxMessageCount( MD_HANDLE hUser // handle to a valid account record ) This function gets the maximum message count quota for an account. Parameters hUser - handle to a valid account record. Return values This function returns the maximum message count quota. Remarks none Example long Max = MD_GetMaxMessageCount(hUser); // do something useful Back to API reference
void MD_SetMaxMessageCount( MD_HANDLE hUser // handle to a valid account record long Value // new value ) This function sets the maximum message count quota for an account. Parameters hUser - handle to a valid account record. Value - new maximum message count quota. Return values none Remarks Specify a value of 0 and there will be no limit to the number of messages. MD_SetUserInfo is the recommended method of setting account data because it has error checking. Example MD_SetMaxMessageCount(hUser, 500); Back to API reference
long MD_GetMaxUIDLCount( MD_HANDLE hUser // handle to a valid account record ) This function gets the maximum UIDL count associated with MultiPOP mail for an account. Parameters hUser - handle to a valid account record. Return values This function returns the maximum number of unique UIDLs that will be stored for an account. Remarks UIDLs are checked when MultiPOP mail is collected and the 'Leave messages on server' option is enabled. Once this limit has been reached messages can no longer be left on the MultiPOP servers. Example long Max = MD_GetMaxUIDLCount(Index); // do something useful Back to API reference
void MD_SetMaxUIDLCount( MD_HANDLE hUser // handle to a valid account record long Value // new value ) This function sets the maximum UIDL count associated with MultiPOP mail for an account. Parameters hUser - handle to a valid account record. Value - new max UIDL count. Return values none Remarks MD_SetUserInfo is the recommended method of setting account data because it has error checking. Example MD_SetMaxUIDLCount(hUser, 500); Back to API reference
long MD_GetMaxMessageSize( MD_HANDLE hUser // handle to a valid account record ) This function gets the maximum message size collectable with MultiPOP mail. Parameters hUser - handle to a valid account record. Return values This function returns the maximum size of a message which is collectable via MultiPOP (in KB). Remarks If a message exceeds this size the MultiPOP engine will not download it. Specify a value of 0 and there will be no limit to the size of a downloadable message. Example long Max = MD_GetMaxMessageSize(Index); // do something useful Back to API reference
void MD_SetMaxMessageSize( MD_HANDLE hUser // handle to a valid account record long Value // new value ) This function sets the maximum size of a message collectable via MultiPOP. Parameters hUser - handle to a valid account record. Value - buffer containing new account data. Return values none Remarks This function uses a numerical representation of the maximum size setting. MD_SetUserInfo is the recommended method of setting account data because it has error checking. Example MD_SetMaxMessageSize(hUser, 500); Back to API reference
long MD_GetFileCount( MD_HANDLE hUser // handle to a valid account record ) This function retrieves the total number of message files located in an account's mailbox. Parameters hUser - handle to a valid account record. Return values This function returns the total number of message files located in the account's mailbox. Remarks All files within the mailbox are counted. If the following MDaemon.ini switch is set the file counting process will include all files in all sub-directories of the root mailbox: [Special] StrictQuotas=Yes (or No) If the following MDaemon.ini switch is set the file counting process will include hidden files: [Special] CountHiddenFiles=Yes (or No) Back to API reference
long MD_GetDirSize( MD_HANDLE hUser // handle to a valid account record ) This function retrieves the total number of bytes of disk storage currently being used by an account's mailbox. Parameters hUser - handle to a valid account record. Return values This function returns the total number of bytes of disk storage currently being used by an account's mailbox. Remarks All files within the mailbox are counted. If the following MDaemon.ini switch is set the byte counting process will include all files in all sub-directories of the root mailbox: [Special] StrictQuotas=Yes (or No) If the following MDaemon.ini switch is set the byte counting process will include hidden files: [Special] CountHiddenFiles=Yes (or No) Back to API reference
bool MD_IsDynamicPasswordStr( char* Password // pointer to buffer containing password ) This function tests Password to see if it is an NT dynamic password or not. Parameters Password - pointer to string buffer containing the password to test. Return values This function returns TRUE if Password is a dynamic NT authentication type. Remarks Dynamic passwords are those which contain two leading slash characters followed by the domain name of an NT domain. Example MD_UserInfo UserInfo; if (MD_IsDynamicPasswordStr(UserInfo.Password)) // do something useful Back to API reference
void MD_GetForwardingInfo( MD_HANDLE hUser // handle to a valid account record char* Address // buffer to receive forwarding address char* Host // buffer to receive forward to host char* SendAs // buffer to receive the HELO/EHLO value char* Port // buffer to receive the port ) This function retrieves all the forwarding address information for an account. Parameters hUser - handle to a valid account record. Address - buffer to receive the forwarding address. Host - buffer to receive the host to use when forwarding mail. SendAs - buffer to receive the HELO/EHLO value used when forwarding mail. Port - buffer to receive the port to use when forwarding mail. Return values none Remarks Address must be at least FWDADDR_LEN+1 chars long. Host must be at least FWDHOST_LEN+1 chars long. SendAs must be at least FWDSENDAS_LEN+1 chars long. Port must be at least FWDPORT_LEN+1 chars long. If the account is using the advanced forwarding options then the Host, SendAs, and Port values will be filled with the advanced forwarding data. This information can be retrieved even if the account is not currently set to forward mail. For example, an account can be storing a forwarding address even thought they are not currently forwarding mail to it. To know if an account is actively forwarding mail use the MD_GetIsForwarding function. Example MD_HANDLE hUser = MD_GetByEmail("arvel@altn.com"); if (MD_GetIsForwarding(hUser)) { char Address[FWDADDR_LEN+1]; char Host[FWDHOST_LEN+1]; char SendAs[FWDSENDAS_LEN+1]; char Port[FWDPORT_LEN+1]; MD_GetForwardingInfo(hUser, Address, Host, SendAs, Port); } MD_GetFree(hUser); Back to API reference
bool MD_SetForwardingInfo( MD_HANDLE hUser // handle to a valid account record char* Address // forwarding address char* Host // forward to host char* SendAs // HELO/EHLO value char* Port // forwarding port ) This function sets all the forwarding address information for an account. Parameters hUser - handle to a valid account record. Address - buffer containing the forwarding address. Host - buffer containing the host to use when forwarding mail. SendAs - buffer containing the HELO/EHLO value used when forwarding mail. Port - buffer containing the port to use when forwarding mail. Return values This function returns TRUE if the forwarding information was able to be stored. Otherwise it returns FALSE. The reason for a FALSE return would be if Address, Host, SendAs, or Port exceeds their maximum length (see Remarks). Remarks Address cannot be greater than FWDADDR_LEN+1 chars long. Host cannot be greater than FWDHOST_LEN+1 chars long. SendAs cannot be greater than FWDSENDAS_LEN+1 chars long. Port cannot be greater than FWDPORT_LEN+1 chars long. If the account is using the advanced forwarding options then the Host, SendAs, and Port values will be filled with the advanced forwarding data. Example MD_HANDLE hUser = MD_GetByEmail("arvel@altn.com"); MD_SetForwardingInfo(hUser, "arvel@arvelh.com", "myisp.com", "altn.com", "25"); MD_GetFree(hUser); Back to API reference
void MD_GetAutoRespInfo( MD_HANDLE hUser // handle to a valid account record char* Script // full path to auto responder script file char* Process // full path to auto responder program to run char* AddToList // add-to mailing list name char* RemoveFromList // remove-from mailing list name char* Exclude; // auto resp script list of excluded address bool& PassMessageToProcess // pass message to Process program? ) This function retrieves all the auto responder information for an account. Parameters hUser - handle to a valid account record. Script - complete path to the auto responder script file. Process - complete path to the program the auto responder will execute. AddToList - name of mailing list auto responder will join people to. RemoveFromList - name of mailing list auto responder will remove people from. Exclude - double null terminated list of address which are exempt from receiving the Script file. Return values none Remarks Script, Process, AddToList, and RemoveFromList must be at least MAX_PATH+1 chars long. Exclude must be at least AUTORESPEXCLUDE_LEN+1 bytes in length. Process can include the macro $MESSAGE$ which will be replaced with the path to the message file when the process is executed. Exclude will contain a NULL separated list of email address that are exempt from receiving the auto responder script file. In other words, messages from addresses found in Exclude will not trigger an auto response script. The end of this string will be double NULL terminated. For example, the resulting string might look like this: "arvel@altn.com\0arvel@arvel.altn.com\0arvel@arvelh.com\0\0" Example MD_HANDLE hUser = MD_GetByEmail("arvel@altn.com"); if (hUser != MD_BADHANDLE) { char Script[MAX_PATH+1]; char Process[MAX_PATH+1]; char AddToList[MAX_PATH+1]; char RemoveFromList[MAX_PATH+1]; char Exclude[AUTORESPEXCLUDE_LEN+1]; bool PassMessageToProcess; MD_GetAutoRespInfo(hUser, Script, Process, AddToList, RemoveFromList, Exclude, PassMessageToProcess); } MD_GetFree(hUser); Back to API reference
bool MD_SetAutoRespInfo( MD_HANDLE hUser // handle to a valid account record const char* Script // full path to auto responder script file const char* Process // full path to auto responder program to run const char* AddToList // add-to mailing list name const char* RemoveFromList // remove-from mailing list name const char* Exclude; // auto resp script list of excluded address bool PassMessageToProcess // pass message to Process program? ) This function sets all the auto responder information for an account. Parameters hUser - handle to a valid account record. Script - complete path to the auto responder script file. Process - complete path to the program the auto responder will execute. AddToList - name of mailing list auto responder will join people to. RemoveFromList - name of mailing list auto responder will remove people from. Exclude - double null terminated list of addresses which are exempt from receiving the Script file. Return values This function returns TRUE if the auto responder information was able to be stored. Otherwise it returns FALSE. Remarks Process can include the macro $MESSAGE$ which will be replaced with the path to the message file when the process is executed. Exclude must contain a NULL separated list of email address that are exempt from receiving the auto responder script file. In other words, messages from addresses found in Exclude will not trigger the return of an auto response script. The end of this string will be double NULL terminated. For example, the string might look like this: "arvel@altn.com\0arvel@arvel.altn.com\0arvel@arvelh.com\0\0" Example MD_HANDLE hUser = MD_GetByEmail("arvel@altn.com"); if (hUser != MD_BADHANDLE) { char Script[MAX_PATH+1]; strcpy(Script, "c:\\mdaemon\\app\\loconly.rsp"); char Process[MAX_PATH+1]; strcpy(Process, "c:\\mdaemon\\app\\dbimport.exe /a /b /i=$MESSAGE$"); char AddToList[MAX_PATH+1]; strcpy(AddToList, "add-list@altn.com") char RemoveFromList[MAX_PATH+1]; strcpy(RemoveFromList, "remove-list@altn.com"); char Exclude[AUTORESPEXCLUDE_LEN+1]; memset(Exclude, 0, AUTORESPEXCLUDE_LEN); char* ptr = &Exclude[0]; strcpy(ptr, "arvel@altn.com"); ptr += strlen(ptr); *ptr = '\0'; ptr++; strcpy(ptr, "arvel@arvelh.com"); ptr += strlen(ptr); *ptr = '\0'; bool PassMessageToProcess = true; MD_SetAutoRespInfo(hUser, Script, Process, AddToList, RemoveFromList, Exclude, PassMessageToProcess); MD_GetFree(hUser); } Back to API reference
bool MD_EraseAutoResp( MD_HANDLE hUser // handle to a valid account record ) This function erases the auto responder settings for an account. Parameters hUser - handle to a valid account record Return values This function returns TRUE if the auto responder information was erased. Otherwise it returns FALSE. Remarks None. Back to API reference ----------------------------------------- IMAP FOLDER AND RULE MANAGEMENT FUNCTIONS ----------------------------------------- The following functions allow you to create IMAP folders for accounts and manage the mail rules that move messages into those folders. A 'rule' is a set of criteria which decide which IMAP folder (if any) a message should be moved into. Rules are encapsulated in the following structure and use the following defines: #define HEADER_LEN 128 #define MATCHTEXT_LEN 128 struct MD_Rule { char Header[HEADER_LEN+1]; char MatchText[MATCHTEXT_LEN+1]; char Folder[MAX_PATH+1]; int Relation; }; The Relation member can be one of these values: #define MDUSERDLL_ISEQUALTO 1 #define MDUSERDLL_ISNOTEQUALTO 2 #define MDUSERDLL_CONTAINS 3 #define MDUSERDLL_DOESNOTCONTAIN 4
MD_RULEHANDLE MD_FindFirstRule( MD_HANDLE hUser // handle to valid account MD_Rule* Rule // pointer to rule structure ) This function retrieves the first IMAP mail rule and places it in 'Rule'. Parameters hUser - handle to a valid user account Rule - pointer to MD_Rule structure to be filled in by this function. Return values The function returns a handle to the first rule in the accounts list of IMAP mail rules. If no rules are defined for an account or some other error occurs the function returns MD_BADRULEHANDLE. Remarks Use this function to begin iteration of all the existing IMAP mail rules for an account. The handle that is returned does not need to be explicitly freed with some other function call. The returned handle should be used in calls to MD_FindNextRule to iterate across the account's rule-set. Example MD_Rule Rule; MD_HANDLE hUser = MD_GetByEmail("user@domain.com"); MD_RULEHANDLE hRule = MD_FindFirstRule(hUser, &Rule); do { // Do something useful with Rule char Buf[256]; MD_RuleStructToRuleString(&Rule, Buf, 255); cout << Buf << endl; MD_RuleStringToRuleStruct(Buf, &Rule); cout << Rule.Header << endl << Rule.MatchText << endl; } while (MD_FindNextRule(hUser, hRule, &Rule)); Back to API reference
bool MD_FindNextRule( MD_HANDLE hUser // handle to valid account MD_RULEHANDLE* hRule // handle to previous rule MD_Rule* Rule // pointer to rule structure ) This function retrieves the next IMAP mail rule and places it in 'Rule'. Parameters hUser - handle to a valid user account hRule - handle to rule as allocated by MD_FindFirstRule Rule - pointer to MD_Rule structure to be filled in by this function. Return values This function returns TRUE if the next IMAP mail rule was read and placed in 'Rule.' If there are no more rules the function returns FALSE. Remarks Use this function to continue iteration of the existing IMAP mail rules for an account. hRule is the handle allocated by a call to MD_FindFirstRule. Example MD_Rule Rule; MD_HANDLE hUser = MD_GetByEmail("user@domain.com"); MD_RULEHANDLE hRule = MD_FindFirstRule(hUser, &Rule); do { // Do something useful with Rule char Buf[256]; MD_RuleStructToRuleString(&Rule, Buf, 255); cout << Buf << endl; MD_RuleStringToRuleStruct(Buf, &Rule); cout << Rule.Header << endl << Rule.MatchText << endl; } while (MD_FindNextRule(hUser, hRule, &Rule)); Back to API reference
bool MD_ReadRule( MD_HANDLE hUser // handle to valid account int Index // integer index to rule MD_Rule* Rule // structure filled in with rule details ) This function reads the specified rule from disk and places it in Rule. Parameters hUser - handle to a valid user account Index - integer index to the rule to read (starting at 0) Rule - MD_Rule structure to contain the rule data Return values This function returns TRUE if the rule was read. Otherwise it returns FALSE. Remarks This function is used internally by several other functions in the API to read rule data from disk and store it into the Rule structure provided. Although provided as an integer Index can be safely cast to MD_RULEHANDLE. Rules are stored in the users HIWATER.MRK file and indexed starting with 0. So, the first rule has an index of 0 and subsequent rules increment this by 1. Example MD_HANDLE hUser = MD_GetByEmail("user@domain.com"); MD_Rule Rule; int Index = 0; if (MD_ReadRule(hUser, Index, &Rule)) { strcpy(Rule.Folder, "DIFFERENT FOLDER"); MD_ChangeRule(hUser, (MD_RULEHANDLE)Index, &Rule); } Back to API reference
bool MD_RuleStructToRuleString( MD_Rule* Rule // handle to valid MD_Rule struct char* Buffer // buffer to receive the rule in string form int BufLen // max length of Buffer ) This function takes a rule in structure format and translates it into string format. Parameters Rule - MD_Rule structure which contains the rule information Buffer - character pointer to receive the rule in string format. BufLen - maximum number of characters Buffer can hold. Return values This function returns TRUE if the rule was translated into string form and stored in Buffer. Otherwise it returns FALSE. Remarks Use this function to transform a rule into string format for storage in a user's configuration file. When rules are stored in the account's HIWATER.MRK file they are stored in string format. Example MD_Rule Rule; MD_HANDLE hUser = MD_GetByEmail("user@domain.com"); MD_RULEHANDLE hRule = MD_FindFirstRule(hUser, &Rule); do { // Do something useful with Rule char Buf[256]; MD_RuleStructToRuleString(&Rule, Buf, 255); cout << Buf << endl; MD_RuleStringToRuleStruct(Buf, &Rule); cout << Rule.Header << endl << Rule.MatchText << endl; } while (MD_FindNextRule(hUser, hRule, &Rule)); Back to API reference
bool MD_RuleStringToRuleStruct( char* Buffer // rule in string format MD_Rule* Rule // structure to receive rule in struct format ) This function takes a rule in string format and translates it into structure format. Parameters Buffer - character pointer containing a rule in string format. Rule - MD_Rule structure which receives the rule in structure format. Return values This function returns TRUE if the rule was translated into structure form. Otherwise it returns FALSE. Remarks Use this function to transform a rule into structure format. Most of these API functions working with rules require it to be provided in structure format. Example MD_Rule Rule; MD_HANDLE hUser = MD_GetByEmail("user@domain.com"); MD_RULEHANDLE hRule = MD_FindFirstRule(hUser, &Rule); do { // Do something useful with Rule char Buf[256]; MD_RuleStructToRuleString(&Rule, Buf, 255); cout << Buf << endl; MD_RuleStringToRuleStruct(Buf, &Rule); cout << Rule.Header << endl << Rule.MatchText << endl; } while (MD_FindNextRule(hUser, hRule, &Rule)); Back to API reference
bool MD_DeleteRule( MD_HANDLE hUser // handle to valid account MD_RULEHANDLE* hRule // handle to valid rule ) This function deletes a specific rule for an account. Parameters hUser - handle to a valid user account hRule - handle to a valid user account rule Return values This function returns TRUE if the rule was deleted. Otherwise it returns FALSE. Remarks Use this function to delete a specific rule within the context of a user account. Do not use this function within loops which depend on MD_FindFirstRule and MD_FindNextRule. Example int Index = 1; MD_HANDLE hUser = MD_GetByEmail("user@domain.com"); MD_DeleteRule(hUser, (MD_RULEHANDLE)Index); Back to API reference
bool MD_AddRule( MD_HANDLE hUser // handle to valid account MD_Rule* Rule // valid rule structure ) This function adds a rule to an account. Parameters hUser - handle to a valid user account Rule - valid MD_Rule structure filled in with rule information Return values This function returns TRUE if the rule was added. Otherwise it returns FALSE. Remarks Use this function to add a new rule within the context of a user account. The Rule structure must contain valid members and be constructed properly. Example MD_Rule Rule; strcpy(Rule->Folder, "MY FOLDER"); strcpy(Rule->Header, "SUBJECT"); strcpy(Rule->MatchText, "Match me"); Rule->Relation = MDUSERDLL_CONTAINS; MD_HANDLE hUser = MD_GetByEmail("user@domain.com"); MD_AddRule(hUser, &Rule); Back to API reference
bool MD_ChangeRule( MD_HANDLE hUser // handle to valid account MD_RULEHANDLE hRule // handle to valid rule MD_Rule* Rule // valid rule structure ) This function adds a rule to an account. Parameters hUser - handle to a valid user account hRule - handle to valid rule which will be changed Rule - valid MD_Rule structure filled in with rule information Return values This function returns TRUE if the rule was changed. Otherwise it returns FALSE. Remarks Use this function to change a rule within the context of a user account. The Rule structure must contain valid members and be constructed properly. The rule pointed to by hRule will be updated to the values specified in the Rule structure. Example MD_HANDLE hUser = MD_GetByEmail("user@domain.com"); MD_Rule Rule; int Index = 0; if (MD_ReadRule(hUser, Index, &Rule)) { strcpy(Rule.Folder, "DIFFERENT FOLDER"); MD_ChangeRule(hUser, (MD_RULEHANDLE)Index, &Rule); } Back to API reference
bool MD_MoveRuleUp( MD_HANDLE hUser // handle to valid account MD_RULEHANDLE hRule // handle to valid rule ) This function moves the specified rule up one position in the rule processing sequence. Parameters hUser - handle to a valid user account hRule - handle to valid rule which will be moved up Return values This function returns TRUE if the rule was moved up. Otherwise it returns FALSE. Remarks Rules are processed in sequence starting with the first rule and continuing until a match is found. Sometimes the sequence of rules are relevant to this process. You can move the specified rule up in the processing order by using this function. You should not use this function within loops which are iterating over all rules. Example MD_HANDLE hUser = MD_GetByEmail("user@domain.com"); MD_Rule Rule; int Index = 0; if (MD_ReadRule(hUser, Index, &Rule)) { MD_MoveRuleUp(hUser, (MD_USERHANDLE)Index); } Back to API reference
bool MD_MoveRuleDown( MD_HANDLE hUser // handle to valid account MD_RULEHANDLE hRule // handle to valid rule ) This function moves the specified rule down one position in the rule processing sequence. Parameters hUser - handle to a valid user account hRule - handle to valid rule which will be moved down Return values This function returns TRUE if the rule was moved down. Otherwise it returns FALSE. Remarks Rules are processed in sequence starting with the first rule and continuing until a match is found. Sometimes the sequence of rules are relevant to this process. You can move the specified rule down in the processing order by using this function. You should not use this function within loops which are iterating over all rules. Example MD_HANDLE hUser = MD_GetByEmail("user@domain.com"); MD_Rule Rule; int Index = 0; if (MD_ReadRule(hUser, Index, &Rule)) { MD_MoveRuleDown(hUser, (MD_USERHANDLE)Index); } Back to API reference
bool MD_GetIMAPFolders( MD_HANDLE hUser // handle to valid account char* Buffer // buffer to contain folder names int BufLen // maximum length of Buffer ) This function returns the names of all user created IMAP folders for an account. Parameters hUser - handle to a valid user account Buffer - buffer which will received folder names BufLen - maximum number of characters Buffer can hold. Return values This function returns TRUE if the folders names were successfully read and placed in Buffer. Otherwise it returns FALSE. Remarks Buffer will contain a NULL separated list of all user created IMAP folders which exist for the accounts specified in hUser. The end of the string will be double NULL terminated. For example, the resulting string might look like this: "FOLDER1\0FOLDER1\SUBFOLDER1\0FOLDER2\0\0" To iterate across this string you can use code like this: char* ptr = Buffer; while (*ptr != '\0') { sprintf(Str, "Folder Name: %s", ptr); ptr += strlen(ptr)+1; } System generated IMAP folders such as DRAFTS and SENT ITEMS are not included in the folder list generated by this function. The actual location of the folder on disk can be obtained by prepending the account's root mail directory with the folder name and then appending ".IMAP". For example, if the folder is called "FOLDER1" and the account's root mail directory is "C:\MDAEMON\USERS\ARVEL\" then this IMAP folder's full path on disk would be "C:\MDAEMON\USERS\ARVEL\FOLDER1.IMAP". Note that the string returned from this function can contain embedded folders like this: "FOLDER1\SUB-FOLDER1". The actual path to this sub- folder would be "FOLDER1.IMAP\SUB-FOLDER1.IMAP". Example MD_HANDLE hUser = MD_GetByEmail("user@domain.com"); char Buffer[256]; char MailDir[MAILDIR_LEN+1]; MD_GetMailDir(hUser, MailDir); MD_GetIMAPFolders(hUser, Buffer, 256); char* ptr = Buffer; while (*ptr != '\0') { char Str[256]; sprintf(Str, "Folder Name: %s", ptr); strcpy(Str, ptr); str::replace(Str, "\\", ".IMAP\\", 255); sprintf(FullFolderPath, "Full Folder Path: %s%s.IMAP", MailDir, Str); ptr += strlen(ptr)+1; } Back to API reference
bool MD_CreateIMAPFolder( MD_HANDLE hUser // handle to valid account char* Root // root IMAP folder char* Folder // new IMAP folder ) This function creates a new IMAP folder for an account. Parameters hUser - handle to a valid user account Root - root IMAP folder which will contain Folder Folder - new IMAP folder name Return values This function returns TRUE if the folder was created successfully. Otherwise it returns FALSE. Remarks The folder which is created will always be within the base mail directory for the account specified by hUser. Root is used when you wish to create an IMAP folder as a subfolder of another IMAP folder. When you wish to create an IMAP folder directly off the users mail directory you can specify NULL for the Root parameter. For example, suppose you wish to create a new IMAP folder called "FOLDER1". You can do so using this code: MD_CreateIMAPFolder(hUser, NULL, "FOLDER1"); Now suppose you wish to create a folder called "SUBFOLDER1" which should exist within the "FOLDER1" folder you just created. Do that with this sort of code: MD_CreateIMAPFolder(hUser, "FOLDER1", "SUBFOLDER1"); Also, you could directly specify the full path like this: MD_CreateIMAPFolder(hUser, NULL, "FOLDER1\SUBFOLDER1"); Example MD_HANDLE hUser = MD_GetByEmail("user@domain.com"); char* NewIMAPFolder[60]; char* RootIMAPFolder[60]; strcpy(RootIMAPFolder, "FOLDER1"); strcpy(NewIMAPFolder, "SUBFOLDER1"); MD_CreateIMAPFolder(hUser, RootIMAPFolder, NewIMAPFolder); Back to API reference