mailsvr

所属分类:Email服务器
开发工具:Visual C++
文件大小:219KB
下载次数:48
上传日期:2006-03-23 21:28:00
上 传 者ASTER
说明:  一个EMAIL服务器的源代码,共享给做这方面研究的朋友,大家一起研究研究!
(an email server source code sharing to do research in this area, friends together studies!)

文件列表:
mailsvr\AppDefines.h (1204, 2000-06-16)
mailsvr\Base64Enc.cpp (4507, 2000-06-16)
mailsvr\Base64Enc.h (1163, 2000-06-16)
mailsvr\BuffSock.cpp (7158, 2000-06-16)
mailsvr\BuffSock.h (1875, 2000-06-16)
mailsvr\CPUDefines.h (1091, 2000-06-16)
mailsvr\CTRLClient.cpp (12451, 2000-06-16)
mailsvr\ctrlclnt\ctrlclnt.dsp (5061, 2000-06-09)
mailsvr\ctrlclnt\ctrlclnt.plg (639, 2000-06-07)
mailsvr\ctrlclnt (0, 2003-04-05)
mailsvr\CTRLSvr.cpp (54649, 2000-06-16)
mailsvr\CTRLSvr.h (1474, 2000-06-16)
mailsvr\DNS.cpp (40492, 2000-06-16)
mailsvr\DNS.h (3317, 2000-06-16)
mailsvr\DynDNS.cpp (4532, 2000-06-16)
mailsvr\DynDNS.h (1155, 2000-06-16)
mailsvr\Errors.cpp (14438, 2000-06-16)
mailsvr\Errors.h (8040, 2000-06-16)
mailsvr\ExtAliases.cpp (18643, 2000-06-16)
mailsvr\ExtAliases.h (1914, 2000-06-16)
mailsvr\FINGSvr.cpp (18255, 2000-06-16)
mailsvr\FINGSvr.h (1401, 2000-06-16)
mailsvr\gpl.txt (18009, 2000-06-16)
mailsvr\MailConfig.cpp (1137, 2000-06-16)
mailsvr\MailConfig.h (996, 2000-06-16)
mailsvr\MailDomains.cpp (12071, 2000-06-16)
mailsvr\MailDomains.h (1540, 2000-06-16)
mailsvr\MailRoot\aliases.tab (202, 2000-06-16)
mailsvr\MailRoot\bin (0, 2003-04-05)
mailsvr\MailRoot\ctrl.ipmap.tab (30, 2000-06-16)
mailsvr\MailRoot\ctrlaccounts.tab (56, 2000-06-16)
mailsvr\MailRoot\custdomains\mirror.redir.tab (286, 2000-06-16)
mailsvr\MailRoot\custdomains\spool (0, 2003-04-05)
mailsvr\MailRoot\custdomains (0, 2003-04-05)
mailsvr\MailRoot\dnsroots (260, 2000-06-16)
mailsvr\MailRoot\domains.tab (13, 2000-06-16)
mailsvr\MailRoot\extaliases.tab (140, 2000-06-16)
mailsvr\MailRoot\filters\danger.net.tab (21, 2000-06-16)
mailsvr\MailRoot\filters\foo@danger.net.tab (21, 2000-06-16)
mailsvr\MailRoot\filters (0, 2003-04-05)
... ...

< XMail Server > Version : 0.51 ( Beta-4 ) Release type : Gnu Public License http://www.gnu.org Date : 01-06-2000 Project by : "Davide Libenzi" davidel@maticad.it http://www.maticad.it/davide/xmail.asp Contrib by : History : Date 11-10-1999 Initial Revision. Date 13-01-2000 Bug Fixes. Date 18-01-2000 Bug Fixes. Date 26-01-2000 Bug Fixes. Date 31-01-2000 Bug Fixes, some code rewrite and added NT service startup. Date 05-02-2000 Some code rewrite and SMTP RARP check added. Date 07-02-2000 Some code rewrite. Now if there are no MX records for destination domain, it'll be tried an SMTP connection to that domain directly. Date 15-02-2000 Some code rewrite. Improved DNS search for MX records ( bug fix ). Date 16-02-2000 Added DNSROOTS file to avoid to repeat queries for roots domains. Date 16-02-2000 Fixed a bug that can lead to a infinite loop under DNS queries. Date 18-02-2000 Log locking and some code rewrite. Date 22-02-2000 Fixed a Linux compilation bug and implemented controller protocol for remote admin. Date 23-02-2000 Fixed a bug caused by a case sensitive compare in domain and users names. Improved controller protocol for remote admin. Date 24-02-2000 Added controller login check. Date 25-02-2000 Fixed a bug that prevent XMail POP3 server to handle multiple domains if there are more nic-names over a single IP address. Improved controller protocol. Added RBL maps check option (rbl.maps.vix.com). Added "spammers.tab" file that control SMTP client connections. Date 27-02-2000 Added UDP DNS query support when searching MX records. This fixes a bug that makes XMail unable to send its mails if it deals with name servers that works only in UDP. Date 28-02-2000 "SmartDNSHost" option added to redirect all DNS queries to a list of DNS hosts. This option can be used to avoid MSProxyServer-WS2_32.DLL bug that not allow to send UDP packets out of the local net. User mailbox size check has been added. Date 29-02-2000 Fixed a compilation bug under certain distributions of Linux. The ability to make a dynamic DNS registration has been added with the "DynDnsSetup" configuration option in SERVER.TAB. Date 01-03-2000 Added VRFY SMTP command. Coded a better Service exit under Windows NT. Added MAILPROC.TAB that enable custom processing of user messages. Date 03-03-2000 Added "poplnkenable" controller command. Added RSS maps check option (relays.mail-abuse.org). Date 06-03-2000 Fixed a bug that can cause XMail to fall in a long CPU eating loop. Added a delay to bad POP3 logins to prevent POP3 mailboxes attacks. Added the option to shutdown the connection in a bad POP3 login case. Fixed a bug that makes XMail ( as NT service ) shutdown at user logoff. Fixed a bug that makes XMail unable to work with machine that are unable to RARP its own socket addresses. Fixed some possible points of buffer overflow attacks. Date 08-03-2000 Added UIDL POP3 server command to make XMail work with clients that needs that feature. Fixed a bug that prevent to send mail introduced with the previous version. Date 10-03-2000 Fixed other possible points of buffer overflow attacks. My Co. XMail server has reached 100000 messages exchanged without a single crash ! Custom domain mail processing has been added. MAIL_CMD_LINE environment ( or registry ) has been added to give XMail a way to get a command line even when it's started as service. Command line option -?I xxx.yyy.zzz.www has been added to bind to specified server interfaces. Date 13-03-2000 Added "POP3Domain" configuration variable that gives the possibility to set the default ( primary ) POP3 domain. Users of such domain can log to the server using only the name part of their email address. Enached daemon ( or service ) mode with no messages printed onto console. A -Md flag has been added to activate the debug mode that will restore verbose behaviour. Error messages, in daemon mode, will be now printed to syslog() ( Linux ) or to EventViewer ( NT ). Improved semaphore handling in Linux that prevent from allocation a great number of semaphores. SysV semaphore array capability of Linux is used to reduce the number of allocated semaphores. Code rewrite. Date 16-03-2000 Fixed a bug in new Linux semaphore code. Date 18-03-2000 Linux daemon startup code has been added. Modified the means of "smtprelay.tab" and "spammers.tab" with the introduction of a netmask ( MODIFY YOUR FILES EVEN IF FOR NOW THE OLD VERSION IS STILL SUPPORTED ! ). Service threads limit has been added to POP3 and SMTP servers. Date 21-03-2000 IP access control has been added to POP3, SMTP and CTRL servers ( pop3.ipmap.tab , smtp.ipmap.tab , ctrl.ipmap.tab ). I suggest You to setup at least ctrl.ipmap.tab. Permanent SMTP error detect has been added to avoid to send N times a message that will be always rejected. Some code rewrite. Date 04-04-2000 A @@TMPFILE macro has been added to MAILPROC.TAB syntax as long as to custom domain processing syntax. It will create a temporary file which hold the copy of the message. It's external program resposibility to delete such file when it has finished its processing. Messages generated as response to a delivery failure has target address remapped with the meanings of the file EXTALIASES.TAB. Fixed a bug that makes XMail write a bad "Received: ..." message tag. This error cause mail readers to display bad message's datetimes. Added "uservars" command to the controller protocol to list user defined variables. Added "uservarsset" command to the controller protocol to set user defined variables. Date 26-04-2000 ********************************************************************************** * WARNING * The spool file format is changed ! * In order to use this new version You MUST flush the spool before starting the * new version of XMail. ********************************************************************************** Modified SysRename() to MscMoveFile() to avoid errors in all cases where files are positioned on differents mount points ( Unixes versions ). Added log files rotate function as long as a new command line parameter ( -Mr ndays ) to specify the rotate delay. Added message-id to SMAIL and SMTP log file. Added @@MSGID macro in custom mail processing ( external commands ). Added @@MSGREF macro in custom mail processing ( external commands ). Now messages coming from external POP3 links are pushed into the spool and not directly into the target user mailbox - this enable custom user mail processing also on this kind of messages. Added "lredirect" command to MAILPROC.TAB that makes XMail to impersonate the local domain when redirect messages. Added "lredirect" command to custom domain mail processing that makes XMail to impersonate the local domain when redirect messages. Date 08-05-2000 Fixed a bug in SysDepLinux.cpp in function SysMakeDir() - permission mask changed to 0700. Improved external programs execution behaviour under NT ( no console is displayed ). Added the option to setup domain message filters with external programs exection ( remember to add the filters subdirectory if You're upgrading an existing XMail ). This can help to filter messages based on its content to avoid mail worms and viruses that travel in attachments with given dangerous extensions. Date 21-05-2000 Added the way to specify a default domain filter with the presence of the file defaultfilter.tab into the filters subdirectory. Improved PSYNC error handling. Improved shutdown condition sensing ( read Server Shutdown section ). Date 24-05-2000 Closed mailing lists has been added ( "ClosedML" variable in USER.TAB ). The concept of filtering as message content testing has been extended to a message processing ( address rewriting, attachment purging, etc ... ). Now message filtering can have a "per user" processing to give a more fine grained control. Date 26-05-2000 Added CtrlClnt to give a access to remote administration of XMail ( see CtrlClnt section ). This permit You to add, delete, list users as long as many other administration procedures ( see XMail controller protocol ). Date 27-05-2000 CtrlClnt improved in error control and bug fixes. Changes in controller protocol for commands that has output. The command "userpasswd" has been added in controller server to allow user password changes. Bug fixes in controller server. Added wildchar ( * ? ) compare in aliases that allow to give a default processing to group of users ( ie users that does not have an account ). XMail init.d startup script has been added ( xmail ). Date 29-05-2000 Bug fixes in controller server and in PSYNC server. Added --install-auto to install XMail as an autostart service ( NT ). Better reliability in custom domain processing has been coded ( REMEMBER to add the spool directory inside custdomains ). Improved delivery error logs for a better problem understanding and fix. Some code rewrites. Date 01-06-2000 Correct handling of mail routing through "RCPT TO: <>" has been added ( see Mail Routing Through Addresses section ). Added wildcard matching and complex mail routing in SMTPGW.TAB. Fixed a bug in PSYNC server that makes XMail to test for "+OK " response instead that for "+OK" ( and "-ERR " for "-ERR" ). Added configuration steps in Part 7 of this doc. The ability to handle custom ( external ) POP3 authentication procedures has been added ( see section External Authentication ). Date 06-06-2000 Fixed a SERIOUS bug in custom ( external ) POP3 authentication procedures, it always give auth :(( APOP POP3 authentication has been added to POP3 server as long as to PSYNC server ( POP3 client ). PSYNC server configuration file ( POP3LINKS.TAB ) IS CHANGED to enable APOP authentication ( watch at POP3LINKS.TAB section ). The command "poplnkadd" of CTRL server has been extended to another parameter that store authentication method to be used. Date 07-06-2000 0.50 MD5 authentication has been added to CTRL server to enforce server security ( watch at XMail admin protocol section ). Users of CTRL protocol are ancouraged to use this new authentication mode. POP3 TOP command has been implemented. Date 12-06-2000 0.51 Added "aliaslist" command to controller server. Wildcard matching has been added in "userlist" and "aliaslist" controller server commands. Fixed a SERIOUS bug in SysExec() on Linux port - upgrade asap Your version. Part 0 License This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Part 1 Overview This server born due to the need of having a free and stable Mail Server to be used inside my company, which at least now, use a Windows Network. I don't like to reinvent the wheel but the need of some special features drive me to start a new project. Probably if I could use a Linux server on my net, I would be able to satisfy my needs without write code, but this is not my case. It should be also portable to other OSs, like Linux and other Unixes. Another reason that drove me to write XMail is the presence of the same steps in setting up a typical mail server, ie : sendmail + qpopper + fetchmail if one needs SMTP, POP3 and external syncronization, or : sendmail + qpopper for only SMTP and POP3 ( I've quoted sendmail, qpopper and fetchmail, but there are many other packages You can use to reach these needs ). With XMail You get an all-in-one package with a central administration that can simplify the above common steps. The first code of XMail Server is started on Windows NT ( my work OS, at least for now ) and Linux ( my home OS ). I plan to use Visual C++ on NT and gcc on Linux. Note : This documentation is still in alpha release. Part 2 Features 1) SMTP server 2) POP3 server 3) Finger server 4) Multiple domains 5) Users don't need a real system account 6) SMTP relay checking 7) SMTP RBL maps check (rbl.maps.vix.com) 8) SMTP RSS maps check (relays.mail-abuse.org) 9) SMTP protection over spammers 10) POP3 account syncronizer with external POP3 accounts 11) Aliases 12) Mailing lists 13) Custom mail processing 14) Remote administration 15) Custom mail exchangers 16) Logging 17) Multi platform 18) Domain message filters 19) Custom ( external ) POP3 authentication Part 3 Porting status Part 4 Requirements Any version of Linux. Windows NT with ws2_32.dll correctly installed. A working DNS and gateway to the internet ( if You plan to use it ). To build for Linux You need any version of gcc and libc or glibc ( better ) installed. To build for Windows You need MS Visual C++ ( for which I give the project ) or any other working compiler that give support for Win32 SDK. Part 5 Getting sources You can download sources from ftp://ftp.maticad.it/pub/misc/mailsvr.tar.gz for Linux and other terminated OSs and from ftp://ftp.maticad.it/pub/misc/mailsvr.crlf.zip for NT ( terminated ). Do not mix files coz bad line termination is the most common cause of XMail failures ! Part 6 Build In Windows NT I give You a project that can be loaded from Visual C++ while in Linux ( and other Unixes ) I give You a Makefile.lnx ( for now ). As soon as the project reach a higher maturity I plan to supply a configure script. Under Linux an init.d startup script is supplied ( xmail ) to allow You to run XMail as a standard rc? daemon. You must put it into /etc/init.d ( it depends on which distro You're using ) directory and then create K??xmail - S??xmail links into the proper directories. Under Windows NT You can uncomment the statement "#define SERVICE" in MainWin.cpp to build an executable that can run as a service. Then You can run : mailsvr --install to install XMail as a manual startup service or : mailsvr --install-auto to install XMail as an automatic startup service. If You run --install and You want XMail to run at NT boot You must go in ControlPanel->Services and edit the startup options of XMail. Once You have the service version of XMail You can run it in a "normal" way by executing : mailsvr --debug [options] Part 7 Configuration [ Linux ] 1) Build XMail 2) Log as root 3) Copy the supplied MailRoot directory where You want it resides ( I suppose /var ) 4) Strip XMail executables if You want to reduce its sizes ( strip filename ) 5) Copy XMail executables to /var/MailRoot/bin 6) If You've inetd installed You must comment out the lines of /etc/inetd.conf that involves SMTP POP3 Finger and restart inetd ( kill -HUP ... ) 7) Setup server.tab configuration option after a well read to the rest of this doc 8) Add Your users and domains ( after a well read to the rest of this doc ) 9) Change all files permissions inside /var/MailRoot to 600 ( except bin/* to 700 ) 10) Change or comment out ( # ) the example account in ctrlaccounts.tab 11) Copy xmail startup script to Your init.d directory ( it's position depends on Your distro ). If You've setup XMail to work in a subdirectory other then /var/MailRoot You must edit xmail startup script to customize its boot 12) If You're smart enough You can create Your S??xmail and K??xmail links, otherwise You can use a module configuration tool like the one supplied with KDE 13) To start XMail without reboot You can run ( from root ): xmail start otherwise reboot Your machine [ NT ] 1) Build XMail 2) Copy the supplied MailRoot directory where You want it resides ( I suppose C:\MailRoot ) 3) Copy XMail executables to C:\MailRoot\bin 4) With regedit create GNU key inside HKEY_LOCAL_MACHINE\SOFTWARE\ and then XMail key inside HKEY_LOCAL_MACHINE\SOFTWARE\GNU 5) Create a new string value named MAIL_ROOT inside HKEY_LOCAL_MACHINE\SOFTWARE\GNU\XMail\ with value C:\MailRoot 6) Optionally create a new string value named MAIL_CMD_LINE inside HKEY_LOCAL_MACHINE\SOFTWARE\GNU\XMail\ to store Your command line options ( read well the rest of this doc ) 7) Open an NT console ( command prompt ) 8) Go inside C:\MailRoot\bin and run : mailsvr --install for a manual startup, or : mailsvr --install-auto for an automatic startup 9) If You've other services that gives the same functionalities of XMail, that is SMTP POP3 or Finger servers, You must stop these services 10) Setup server.tab configuration option after a well read to the rest of this doc 11) Add Your users and domains ( after a well read to the rest of this doc ) 12) Setup file permissions of C:\MailRoot directory to grant access only SYSTEM and Domain Adminis 13) Change or comment out ( # ) the example account in ctrlaccounts.tab 14) To start XMail without reboot You can go to : ControlPanel -> Services -> XMail server and start the service, otherwise reboot Your machine If You want to start XMail as a simple test You must setup an environment variable MAIL_ROOT that point to the XMail Server root directory. Linux : export MAIL_ROOT=/var/XMailRoot Windows NT : set MAIL_ROOT=C:\MailRoot Mail root directory contain this files : aliases.tab domains.tab dnsroots extaliases.tab mailusers.tab message.id pop3links.tab server.tab smtpgw.tab smtprelay.tab userdef.tab ctrlaccounts.tab spammers.tab pop3.ipmap.tab smtp.ipmap.tab ctrl.ipmap.tab this directories : bin custdomains spool filters logs pop3linklocks spool errors locks logs userauth pop3 and for each domain "domain" handled a directory : domain inside which reside, for each account "account" : account user.tab mlusers.tab [ mailing list case ] mailproc.tab [ optional ] mailbox TAB files are text files ( in the sense meant by OS : for NT and for Linux ) with this format : "value1"[TAB]"value2"[TAB]...[NEWLINE] Examine now the means of this files. ALIASES.TAB : "domain"[TAB]"alias"[TAB]"realaccount"[NEWLINE] Ex : "maticad" "davidel" "dlibenzi" define "davidel" as alias for "dlibenzi" in "maticad" domain. "maticad" "foo*bog" "dlibenzi" define an alias for all users whose name start with foo and end with bog. "maticad" "??trips" "travels" define an alias for all users whose name start with any two chars and end with trips. DOMAINS.TAB : "domain"[NEW ... ...

近期下载者

相关文件


收藏者