Smoke
Magiclamp Networks

MDaemon and ASP Dev Site



Featured Code: MDaemon/COM+ & ASP

MDaemon with ASP
Code Examples
From Angelo Bestetti
Implements a Control Panel for MDaemon Using MDaemon's COM+ Object in ASP
~ Site

 

Contact

Using CDONTS / FrontPage Forms with MDaemon:

Using CDONTS in ASP (or FrontPage forms) for sending email requires configuring a mail transport, similar to how Perl needs a sendmail config file to know that it should be using sendmail. CDONTS uses a built-in COM+/IIS object to send mail, and that IIS object is tied (hard coded I think) to the Microsoft SMTP service. So first you need to install and setup the MS/SMTP service:

  1. Start->Settings->CP->Add/Remove Programs->Add Windows Components
  2. Click IIS, then Details, then checkmark SMTP service, OK, OK, OK... (If the SMTP service is already check-marked, you should cancel out to the desktop)
  3. It should install without reboot, but the service will error on startup because MDaemon already has port 25

Next, we need to configure MS/SMTP to use a different port, and lock it down against relaying mail from outside connections:

  1. Start Internet Services Manager
  2. Right-click Default SMTP Virtual Server and select properties
  3. On the General tab, click Advanced, and change the TCP Port to "3025" or something semi-random (click edit if you are lost...), then Apply (but stay in Properties
  4. Under the Access Tab, go to Connection, and change to 'Only the list below' and add 127.0.0.1 and the main IP address(es) of the server
  5. Click the OK's until you are back at the main screen for Internet Services Manager
  6. Right-click Default SMTP Virtual Server and select Start

It turns out that MS/SMTP doesn't have a UI for changing the routing/relay for outbound mail, but that shouldn't be a problem, as presumably MS/SMTP will be sending to a domain hosted by MDaemon that is on the same server. They are both smart enough to figure out the rest...

Also, setting this up enables FrontPage users to send email with forms, but...
when you setup FrontPage for a virtual domain, and you enable the mail transport, it makes you enter a mail address for the WWW server. You need to make sure that the name you put in there is entered as a known good address on MDaemon (I just alias it to me). If you don't, MDaemon will reject the email, and debugging this is a pain in the butt. This of course is true only if you have your MDaemon SMTP locked down to not be an open relay.

A page posted on the MDaemon forums that has a few screen shots

See List Control zip file for samples on how to use CDONTS in ASP.

List Control With ASP

This zip file contains everything you need to setup a small functional site to allow users to subscribe and unsubscribe from a list.

The zip file contains

list.asp form handling and mail sender
mail_list.gif picture used for a button in subscribe.htm
subscribe.htm standard html file that sends its form data (subscribe and address) to list.asp using a GET
subscribe_thanks.htm list.asp redirects to this page after processing subscribe.htm
unsubscribe.htm standard html file that sends its form data (unsubscribe and address) to list.asp using a GET
unsubscribe_thanks.htm list.asp redirects to this page after processing unsubscribe.htm

You will need to edit:

  • list.asp => change domain names and list names!
  • subscribe_thanks.htm => change the meta-refresh to point to your base site
  • unsubscribe_thanks.htm => change the meta-refresh to point to your base site

It should work with the above 3 files modified, although you must have support for CDONTS on the server (see prior topic). This sample is highly extensible, allowing you to run all of the "mail building", formatting, and header creation in the asp file. That asp file can be put into a "Source Access" only folder on the web server, providing an extra layer of protection from "prying eyes". With additional If...Then or Case statements you can build in support for your other custom forms.

WebAdmin under IIS

Support for IIS & WebAdmin is limited at best. Alt-N officially says it doesn't work, but you can get it going. There are several drawbacks however. Enabling WebAdmin on IIS6 means you have to give full access to anonymous accounts (IUSR_ & IWAM_) which is not something I like to do if I don't have to. But the main reason you don't want to set this up is certain features do not work! If you are seriously considering implementing WebAdmin under IIS for a production server, do your homework on what is not supported in the current release. Join the WebAdmin list and talk to some people. My users need features that don't work under IIS, so I do not use WebAdmin under IIS in production, even though there are a number of reasons to do so.

I also want to point out that the WebAdmin/WorldClient web server is very robust, and the Alt-N team is very fast about fixing vulnerabilities. This, in my opinion, removes the argument that running WebAdmin under IIS is better for scalability or security (unless you are looking at clustering, and if you are running that many users through WebAdmin, you may want to build your own custom ASP interface (I'm working on one now...). 

If you still really want to do this, read through the WebAdmin list archives (search on WebAdmin.dll) and follow (generally) the WorldClient on IIS directions.

MDaemon & ASP Outside of COM+

Coming soon!

Troubleshooting

A word on errors: Troubleshooting ASP to MDaemon problems can be difficult, especially if you aren't paying attention to the error codes being reported ;) If you follow my instructions, and have problems, SCAN your logs. Most of the time, the object or service having the problem will report it somewhere. This is the single biggest time saver around! 

Disclaimer

Disclaimer: I am publishing this information, code, and tips AS-IS. I am holding no warranties, implied or otherwise. Most of what you will find here, I have put together while working with MDaemeon. A lot of the code here is used by people every day, and I am confident that you will find this information to be useful, but none of it has been through a full software quality cycle.

About This Site

MDaemon is one of the best mail servers out there, and I have used more than a couple. Flexibility, speed, and error handling that make bad mail servers cry. And the developers of MDaemon have listened to their customers. They published a COM object to allow us ASP developers to interface directly to MDaemon. But... using ASP and MDaemon isn't well documented, so this is my contribution to the MDaemon user community.


©2003/2004 Magiclamp Networks ~ All Right Reservered
Author: J S Robinson

Submission of code and documentation is always welcome!
__________________________________________________

 

Site Map Privacy Legal   ©2008 Magiclamp Networks -- All Rights Reserved