SMTP.SERVER

  Smtp.Server is an ActiveX Component that you may use to Send Emails. It may be used in Excel, ASP, VB, Visual C++ and other ActiveX container applications. (Please read the write up below for details on how to use Smtp.Server).

  I made this component just for the fun of it. It is absolutely free, and like all free software it has no guarantee and/or liability.  Although I have tested it, but I do not make any guarantees and accept liabilities (just saving my neck J)

  Those who are interested in getting the source code of SMTP.Server, may drop me an email at kashifmanzoor@hotmail.com  (I do reserve the rights to give/not to give the source code)

  Please read the complete document (given below), before reporting any bug(s) or giving your feedback.

   SMTP.Server” has been tested on Windows 98 and Windows 2000. It may not work properly on Windows NT and/or Windows 95. If you successfully test it on Win95/NT please let me know and I’ll put your name in the credits J  

 

Installation Instructions

Step (1):

 Download SMTPServ.EXE (140 KB) for free

Step (2):

Once downloaded, double click SMTPServ.EXE. It is a self-extracting WinZip file. Unzip this file to the directory of your liking. Double Click the newly unzipped file (SMTP.EXE). You should see a dialog box similar to the one given below:

 

 

This indicates SMTP.Server has been successfully registered in the system Registry.

If you do not see this dialog box, please report the bug. (Remember that the application has not been tested on Win95/NT)

Step (3):

Now you are all set to use it in your Visual C++ applications (as CreateDispatch(“SMTP.Server”)),  ASP/Excel/VB applications (as Server.CreateObject(“SMTP.Server”)) .

Please go through the example code, and the methods/properties supported by SMTP.Server.

SMTP.Server Properties

*   LoginName

*   Password

*   MailTo

*   MailFrom

*  CcTo

*   Subject

*   Message

*   ReplyTo

*   SMTPServer

*   SenderIP

*   PortNumber

*   ServerVersion

*   EnableLog

*   LogFile

*   TimeOut

*   WMLOutput

SMTP.Server Methods

*   SendMail( )

   

Property : LoginName

Type:  String

Default Value: “guest”

Description:

Although the SMTP.Server does not require any user authentication, but this parameter is given just for the heck of it !. Its up to the user how he/she uses it. The only time when SMTP.Server uses this parameter is when it makes log entries. The LoginName will be written in the log entries so that you may identify the user whose mail was sent through the SMTP.Server. This may be a good tool for billing purposes.

In a perfect world the LoginName may be derived from MailFrom parameter.  (normally MailFrom = LoginName@some.server.com, but there may be aliases and other mumbo jumbo that renders this technique, of determining the user, useless.)

  Back to top  

Property: Password

Type: String

Default Value: “guest”

Description:

SMTP.Server does not use this entry at all. This entry has been put there for save keeping the password. Its up to you to decide how you use it.

Unlike LoginName the Password is not entered in the LogFile.  Why I put the Password at all ?, is a mystery even to me. Its just that, Login & Password are like twins, so when I put the Login there (and for good reasons too, see the LoginName description), I automatically made an entry for Password.

Back to top

Property: MailTo

Type: String

Default Value: null

Description:

This property holds the destination email address. Only ONE destination address should be given here. If you want the email to be sent to multiple destinations, then use the CcTo property to specify other email addresses. You MUST set this property to a valid address before calling SendMail( ) method.

Back to top

Property: MailFrom

Type: String

Default Value: null

Description:

This property should be set with the sender’s address.  If the sender’s address is not given SMTP.Server checks the ReplyTo property. If ReplyTo property contains an email address, it will be used as the sender address. In case neither MailFrom nor ReplyTo is set, the system returns with an error “Invalid Sender address”.

Back to top

Property: SenderIP

Type: String

Default Value: “kashif.SMTP.Server”

Description:

This property should be set to the IP address of the machine that runs SMTP.Server component. If you do not set this property it defaults to “Kashif.SMTP.Server”.

Back to top 

Property: PortNumber

Type: integer

Default Value: 25

Description:

The default SMTP listening port is 25. You should not change this unless you have good reasons to do so.

  Back to top

Property: ServerVersion

Type: integer           

Default Value: 1

Description:

  This is a read-only property. You cannot set its value. You can only retrieve it value.

Back to top

Property: SMTPServer

Type: String

Default Value: “mail.nexlinx.net.pk”

Description:

SMTP.Server does not deliver the email directly to the destination address specified in MailTo, and CcTo properties. It passes on the email message to another server which in turn will send the message to the destination(s) on SMTP.Server’s behalf. It is similar to how other Email clients (like Eudora, Exchange etc.) handle email delivery. You should specify the Mail server’s IP address through the SMTPServer Property.  The server address could either be descriptive like “mail.nexlinx.net.pk” (my ISP’s mail server address) or an actual IP address like “202.59.64.7”. If you do not set this property it defaults to “mail.nexlinx.net.pk”. I strongly recommend that you set this property to your own ISP/company’s mail server, since “mail.nexlinx.net.pk” probably has a policy to reject requests originating from domains other than “*.nexlinx.net.pk”

  Back to top

 

Property: EnableLog

Type: boolean

Default Value: 0 (FALSE) i.e. logs will not be maintained.

Description:

This property indicates to the SMTP.Server whether it should keep a log of all the Send Mail requests or not. If this parameter is set then the server will log complete communication to and from the destination SMTPServer (as mentioned in the parameter SMTPServer).  You may use the log for billing purposes, to stop hacking, to debug the program etc. How you use it and why you need it, is completely up to you.

See Also: LogFile

Back to top

Property:  LogFile

Type: String

Default Value: “C:\SMTPLog.txt”.

Description:

When you set the EnableLog parameter to true. SMTP.Server attempts to open the file as determined by the “LogFile” parameter. Incase the file already exists, the server will start appending the log entries to it. If the file does not exist, the server will create a new file. Remember that the server only creates new file and not the directories. So if you have set LogFile to “C:\logs\Smtp.txt” then make sure that the directory “c:\logs\” exists. If it does not exist then the server will discard the entry and will start appending in the default “C:\SMTPLog.txt” file. In case the file name is invalid, or the server could not create a file it will start making log entries to the default file “C:\SMTPLog.txt”.

You may enable logging and have a look at the generated LogFile, to see the syntax, and the level of information that the file maintains. You may use customized parsing scripts/programs that would parse the LogFile and implement your billing system, or to prevent Spam, malicious emails etc.  However to make this meaningful, you should first set the LoginName parameter before Calling the SendMail() method. see Example.asp for details:

An excerpt from the Log File is given below:

BEGIN <Kashif>

Message intended for 4 addresses

HIM: 220 mail.nexlinx.net.pk ESMTP Nexlinx Sendmail 8.9.3/8.9.3; Thu, 31 May 2001 14:09:01 +0500

ME: HELO kashif.SMTP.Server

HIM:250 mail.nexlinx.net.pk Hello [202.59.64.117], pleased to meet you

ME: MAIL FROM: <kashifmanzoor@giki.edu.pk>

HIM:250 <kashifmanzoor@giki.edu.pk>... Sender ok

ME: RCPT TO: <kashifmanzoor@hotmail.com>

HIM:250 <kashifmanzoor@hotmail.com>... Recipient ok

ME: RCPT TO: <kashifmanzoor@yahoo.com>

HIM:250 <kashifmanzoor@yahoo.com>... Recipient ok

ME: RCPT TO: <00030022@lums.edu.pk>

HIM:250 <00030022@lums.edu.pk>... Recipient ok

ME: RCPT TO: <naveedarshad@yahoo.com>

HIM:250 <naveedarshad@yahoo.com>... Recipient ok

ME: DATA

HIM:354 Enter mail, end with "." on a line by itself

ME:

  Subject: This email comes to your courtesy of SMTP.Server

  Reply-To: kashifmanzoor@giki.edu.pk

  <55 bytes of message sent to the server>

  .

HIM:250 OAA04529 Message accepted for delivery

Message Successfully delivered

======== END ========

There you have it !. Use this log file as you please. The message sent by SMTP.Server start with the ME tag, and the messages that are received by SMTP.Server start with the HIM tag. Every new log entry starts with a BEGIN tag and ends with END tag; however if an error occurs while sending the mail, the END tag will not be present. So a missing END tag should indicate an error. To get the details of the error simply see the corresponding HIM: line

Back to top

Property: ReplyTo

Type: String

Default Value: null

Description:

This property should be set with the address at which you want the receiver to reply. If ReplyTo is not set, SMTP.Server automatically treats the address in MailFrom property as ReplyTo. This property is useful when the MailFrom address is different than ReplyTo; in case they are both the same you may safely ignore ReplyTo.

  Back to top

 

Property: TimeOut

Type: integer

Default Value: 180 seconds (3 minutes)

Description:

This value specifies (in seconds) how long should the SMTP.Server take for a single email message. The timer starts when you call SendMail() method. If the SendMail() method does not return (with or without an error) with in TimeOut seconds, SMTP.Server will forcibly abort the mail message. This safeguards your container applications from blocking after a call to SendMail().

  Back to top

 

Property: Subject

Type: String

Default Value: “(no subject)”

Description:

This property holds the message subject. You can either set the mail subject through this property or during the call to SendMail() as an input parameter. (see SendMail() method description)

  Back to top

Property: Message

Type: String

Default Value: null

Description:

This property holds the actual message. You can either set the message through this property or during the call to SendMail() as an input parameter. (see SendMail() method description)

  Back to top

Property: CcTo

Type: String

Default Value: null

Description:

In case you email is destined to multiple addresses, you can specify them through this property. To enter multiple addresses, separate them with a “,” (comma) e.g. “abcd@efg.com, hij@klm.com, mno@pqr.com”

note that the every address except the last ends with a comma. SMTP.Server ignores any invalid addresses, and does not indicate any error. An invalid address could either be an address without an “@” in it, or an address not separated by “,”.  SMTP.Server, however does remove any leading/trailing spaces from the addresses.

  Back to top

 

Property: WMLOutput

Type: boolean

Default Value: 0 (FALSE) (i.e. output from SendMail() will not be compatible with the WML)

Description:

When you call SendMail() method it returns a string that indicates the success or failure of the operation. This string may be used verbatim by your program to report the outcome of send mail process. However if you are embedding SMTP.Server for sending email through a WAP (wireless Application Protocol) device (e.g. your mobile phones, Handheld PCs etc.) then you MUST set this parameter to “1”. The reason is, that the return message may contain illegal characters like angled brackets “<” or “>”.  Although an HTML page may overlook these, but a WML browser gets confused and tries to interpret it as a start/end of a WML tag, hence generating a serious “page cannot be displayed” error.

Setting this property to “1”, will ensure that the return message from SendMail() method is compatible with WML code (i.e. all the ambiguities are removed from the return string ), and you may output the SendMail() return string directly to a WAP device. See Example WML Code.

Back to top

SendMail (strCc, strSubject, strMessage, strAttachFile)

SMTP.Server supports only one method (life doesn’t get any easier than this !). The parameters are pretty self explanatory.

The method takes in the following parameters:

strCc :  A string that holds the comma separated destination email addresses (See CcTo property)

strSubject: A string that holds the Subject of the email message (See Subject property).

strMessage: A string that holds the actual message to be sent through Email (See Message property).

strAttachFile: At the moment SMTP.Server does not allow attachments to your messages. In the future versions I will implement this feature, at which time this parameter will take in the Attached file name. As of now, you may set it to an empty string or to any other value for that matter – SMTP.Server simply ignores it.

You can either pass on the Cc/Subject/Message information directly through the SendMail() method call, OR you can set these individually by accessing the properties directly. If you set these properties individually then make sure you call SendMail( ) method with empty strings as parameters. This is because the Subject/Cc/Message values passed directly as parameter to SendMail() call take precedence over any previously set values of Subject, CcTo, Message properties. (See Example ASP Code)

Return Value:

The function return a string that explains the outcome of the SendMail(). If the message is delivered successfully the return string will contain “Message Successfully delivered”; else it will contain a description of any error that might have occurred.

Back to top

Example Usage

Exmaple.asp    (native ASP code)

Example.wml (ASP code that incorporates WML)

ServerTest.xls  (file contains Macros, you must Enable them while running it)

 


User's Comments

Dear Kashif, 
I find your SMTP.Server written by you to be very useful, I have search high & low for such component and on the same time I try to develop SMTP server using Visual Basic but there is no reference site for SMTP Server written in Visual Basic. By the way, thanks for making your SMTP server component free. Thanks & Best Regards, 
Jason Lee
(Malaysia)

I searched for an SMTP ActiveX component and found the link to your site. I have downloaded the component, and am using it in my ASP code. The component works fine, and specially the log file it produces is very informative. I have parsed the log file for my purpose. Well done, and thankyou for your help. bye, Mario (Brazil) 

home

  All rights reserved © 2001, Kashif Manzoor This document and the software available on this web site is the intellectual property of Kashif Manzoor, and it may not be distributed without prior permission.

Send Bugs/feedback/criticism to: kashifmanzoor@hotmail.com