email component

ANSMTP Developers Center > IIS SMTP Service

Important notice:* This product has integrated to EASendMail SMTP Component, Please use EASendMail SMTP Component instead of ANSMTP SMTP Component.

Related Links:
Send Email in Visual Basic with EASendMail SMTP Component
Send Email in Visual C++ with EASendMail SMTP Component
Send Email in Delphi with EASendMail SMTP Component
Send Email in VB.NET with EASendMail SMTP Component
Send Email in C# with EASendMail SMTP Component
Send Email in Managed C++ with EASendMail SMTP Component
Email Queue with EASendMail Service

We strongly recommand the developer use the ANSMTP 7.0 + EASendMail Service instead of IIS SMTP service.

Introduction

IIS SMTP Service is a high performance SMTP server on Windows NT/2000/XP. We can use it to send email easily with ANSMTP. This tutorial shows how to install IIS SMTP service and program with it.

Installation and Deployment

You should download the ansmtp installer and install it on your machine at first. If you want to distribute or deploy ansmtp without ansmtp installer, please click here to learn more.

Install IIS SMTP Service

You can install IIS on Windows 2000/XP as follows: "Control Panel->Add/Remove Programs->Windows Components->Internet Information Service->SMTP Service". For Windows NT user, you can install it from Option Pack 4.0 of Windows NT. After installed, you can start it from "Control Panel->Administrative Tools->Internet Information Service".

Send Email by IIS SMTP Service

Now you can send email by IIS SMTP Service with the following code:

[ASP]
<%
Set oSmtp = Server.CreateObject("AOSMTP.Mail")
oSmtp.ServerAddr = "127.0.0.1" 'computer ip address.
oSmtp.FromAddr = "test@adminsystem.net"
oSmtp.AddRecipient "Support Team", "support@adminsystem.net", 0

oSmtp.Subject = "Test"
oSmtp.BodyText = "Hello, this is a test...."
 
If oSmtp.SendMail() = 0 Then
  Response.Write "Message delivered!"
Else
  Response.Write oSmtp.GetLastErrDescription()
End If
%>

ESMTP authentication/Trusted IP Addresses

The default setting of IIS Smtp service may cause failure in sending email ("Error with sending recipient"). Here are two solutions to the problem.

Enable ESMTP authentication of IIS SMTP Service

1. "Control Panel->Administrative Tools->Internet Information Service->Default SMTP Virtual Server->Properties->Access->Authentication. ". Check the BASIC Authentication.

2. "Control Panel->Administrative Tools->Internet Information Service->Default SMTP Virtual Server->Properties->Access->Relay ". Check the "Allow all computers which successfully authentication to relay ..."

You also need to change your code like this:

[ASP]
<%
Set oSmtp = Server.CreateObject("AOSMTP.Mail")
oSmtp.ServerAddr = "127.0.0.1" 'computer ip address.
oSmtp.FromAddr = "test@adminsystem.net"
oSmtp.AddRecipient "Support Team", "support@adminsystem.net", 0

oSmtp.Subject = "Test"
oSmtp.BodyText = "Hello, this is a test...."

oSmtp.UserName = "administrator" 'any valid user of current machine.
oSmtp.Password = "ad1234" 'password of this user

If oSmtp.SendMail() = 0 Then
  Response.Write "Message delivered!"
Else
  Response.Write oSmtp.GetLastErrDescription()
End If
%>

Then your application can send email to any email address without error.

Trusted IP Addresses

If you don't want to do ESMTP authentication, you can add the IP address of your computer to Relay IP Addresses List of IIS SMTP Service.

"Control Panel->Administrative Tools->Internet Information Service->Default SMTP Virtual Server->Properties->Access->Relay" Check "Only the list below" and add your computer IP address to this list. Any email sent from this IP address will be accepted by IIS SMTP Service even without user authentication.

Send Email by Pickup Patch/Mail Queuing

After installed IIS SMTP Service, there is a directory named "Pickup" ("C:\Inetpub\mailroot\Pickup"). IIS SMTP Service keeps on monitoring this folder, once an email is saved in this directory, IIS SMTP Service will queue this email and send it automatically in background.

The following code demonstrates how to send email by pickup path of IIS SMTP Service.

[ASP]
Dim oSmtp, pickupPath
Set oSmtp = Server.CreateObject("AOSMTP.Mail")
pickupPath = "c:\inetpub\mailroot\pickup"

oSmtp.FromAddr = "test@msn.com"
oSmtp.AddRecipient "support team", "support@adminsystem", 0 
oSmtp.Subject = "test subject" 
oSmtp.BodyText = "test body"

If oSmtp.SaveMailEx( pickupPath ) = 0 Then
  Response.Write "Email queued"
Else
  Response.Write "SaveMailEx method failed"
End If

We strongly recommend you send email in ASP/ASP.NET application in this way.

Handle Undeliverable Email

How does IIS SMTP Service manage undeliverable emails? It saves those emails to specified folder ("C:\Inetpub\mailroot\Badmail"). If you want to receive  those undeliverable emails, you can add your email address in "Control Panel->Administrative Tools->Control Panel->Administrative Tools->Internet Information Service->Default SMTP Virtual Server->Properties->Messages"

More Summary

If an email couldn't be sent to specified email address in first trial, IIS SMTP Service would move it to "Queue" folder and IIS SMTP Service would keep on retrying later until expired. You can set expiration timeout of IIS SMTP Service in "Control Panel->Administrative Tools->Control Panel->Administrative Tools->Internet Information Service->Default SMTP Virtual Server->Properties->Delivery"

Free Email Support

Not enough? Please contact our technical support team.

Support@EmailArchitect.NET
VIP@EmailArchitect.NET(Registered User)

Remarks
We usually reply emails in 24hours. The reason for getting no response is likely that your smtp server bounced our reply. In this case, please try to use another email address to contact us. Your Hotmail or Yahoo email account is recommended.



2001-2011 © Copyright AdminSystem Software Limited. All rights reserved.   About us  Site Map                       Follow emailarchitect on Twitter