DBA Tips Archive for Oracle

  


Configuring SMTP on Windows

by Jeff Hunter, Sr. Database Administrator


Contents

  1. Overview
  2. Exim - (as part of Cygwin)
  3. Microsoft Internet Information Server (IIS)



Overview

This articles presents several ways to configure a Microsoft Windows machine with the Simple Mail Transfer Protocol (SMTP).



Exim - (as part of Cygwin)

One method is to install exim, an SMTP server [a GNU (GPL) software, included with Cygwin] on a Windows 2000 or Windows XP machine. (This is always my preferred method!)

  This article assumes that Cygwin is not installed on the Windows computer. Complete instructions for installing Cygwin and configuring for Exim is included in this section.

  1. Login to the Windows machine as Administrator, or as a user with administrator privilege. Make sure the user has a login password already created.

  2. Create a folder called c:\cygwin

  3. Download the setup.exe program from http://www.cygwin.com/. Save the file setup.exe to c:\cygwin.

  4. Run the newly downloaded setup.exe program. (i.e. Click Start /Run / and type c:\cygwin\setup.exe)

    On the Welcome screen, click [Next] to continue.

    On the "Choose a Download Source" screen, select "Install from the Internet". (downloaded files will be kept for future re-use)

    On the "Select Root Install Directory" screen, the "Root Directory" should be c:\cygwin.

    On the "Select Local Package Directory" screen, the "Local Package Directory" should be C:\CygwinInstall.

    On the next two screens, select the correct "Internet Connection" and "Download Site" close to you.

    On the "Select Packages", click the "View" button until it shows "Full". Then look for the line for "exim" and click the word "skip" until it shows an [x] in the "Bin?" column. Finally, look for the line "cygrunsrv" and do the same - click on the word "skip" on that line until an [x] appears in the "Bin?" column.

    Click [Next] to start the installation.

  5. Right click the "My Computer" icon and select "Properties". From the "System Properties" dialog, select the "Advanced" tab and then the "Environment Variables" button.

    In the "Systems variables" section (lower section), click the "New" button to add a new system variables:

    Variable name: CYGWIN
    Variable value: ntsec tty

    Also in the "Systems variables" section, modify the Path variable (clicking on the "Edit" button) and appending the following to the end of the existing variable string:

     ;c:\cygwin\bin

  6. Open a Cygwin window (by double clicking the icon), a black screen pops up, type exim-config. Answer the prompts as follows:

    • When asked for "local postmaster", type "Administrator" or type a user name with Administrator privilege.
    • When asked for "fully qualified primary hostname", you can accept the default or type in your machine's FQDN. (i.e. mail.mydomain.com)
    • When asked to "install the exim daemon as a service", answer "yes".
    • When asked to "Enter the period of the queue runner", answer "15".
    • When asked "Do you want the daemon to run with ntsec", answer "no".
    • When asked "Do you want to start the exim daemon as a service now", answer "yes".
    At this point, the Exim Mail Transfer Agent service (exim) should be running!

  7. Now let's check to make sure the exim (SMTP server) is running, type:
    netstat -an | grep  25
    You should see a response like:
    TCP    0.0.0.0:25         0.0.0.0:0          LISTENING

  8. To start and stop the exim service, use:
    net start exim
    net start exim

  9. To allow all internal / networked workstations within your network to use exim as an outbound SMTP server, we need to perform several tasks. The first task is to configure the firewall (if installed as part of Windows XP Service Pack 2 or higher) to allow traffic to pass through.

    Invoke the "Control Panel" and select the "Security Center" applet. If the firewall is not enabled (NOT MONITORED), then there is no need to continue with this section. If however, you have the firewall enabled, click the "Windows Firewall" in the "Manage Security Sections for:" section. In the "Exceptions" tab, click the "Add Port" button. In the dialog box, use a name of "exim" and the Port Number "25". Also, make sure to check the TCP radio button. The "Scope" of this rule should be set to "Any computer" by default.

  10. Another task that needs to be completed in order to allow all internal / networked workstations within your network to use exim as an outbound SMTP server, is to edit the file c:\cygwin\etc\exim.conf. Open this file in an editor and modify the following:

    • Find the line:
      hostlist  relay_from_hosts = 127.0.0.1
      and change it to
      hostlist  relay_from_hosts = 127.0.0.1 : 192.168.1.0/24
      The above modification tells exim to accept emails (for sending) from any workstation with an IP address of 192.168.1.xx. This line could be read as "relaying mail for the subnet 192.168.1.0/24". Please keep in mind that your local network subnet number may be different.

    • Find the line:
      host_lookup = !127.0.0.1/8:*
      and change it to
      # host_lookup = !127.0.0.1/8:*
    • Find the line:
      rfc1413_query_timeout = 30s
      and change it to
      rfc1413_query_timeout = 1s
    • Find the line:
      require  verify = sender
      and change it to
      # require  verify = sender

  11. After you modify and save the file c:\cygwin\etc\exim.conf, restart the exim email server by typing:
    net stop exim
    net start exim



Microsoft Internet Information Server (IIS)

One easy way is to install Microsoft's web server, Internet Information Server (IIS). This is faily painless. If you are running Windows XP Professional on your workstation you can install Microsoft's web server, Internet Information Server (IIS) from your Windows XP Pro installation CD. Instruction for installing and configuring IIS on Windows XP Pro, follow the instructions below:

  1. Place the Windows XP Professional CD-Rom into your CD-Rom Drive. The "Welcome to Microsoft Windows XP" splash screen should come up if you have autorun turned on for the CD-ROM.

    If not and the splash screen does not come up, navigate to the drive letter of the CD-ROM and run setup.exe.

  2. From the "Welcome to Microsoft Windows XP" splash screen, click on the "Install optional Windows components" option.

      You can also get to this by opening the "Add/Remove Programs" applet from from "Control Panel". From the "Add or Remove Programs" dialog, click the "Add/Remove Windows Components" button (left).

  3. Click the check box for "Internet Information Services (IIS)". By default, the "SMTP Service" is included with a default IIS install so it is possible to leave all the default installation settings intact.

      I, however, like to add other services and options (i.e. FTP). To do this, make sure the "Internet Information Services (IIS)" option is selected and click the "Details" button. Add or remove any other services or options, but make sure that the "SMTP Service" stays checked.

    Click [Next] to start the installation process.

  4. Once IIS is installed on your machine you can view your home page in any web browser by typing the following into the address bar of your web browser:
    http://localhost

      You can substitute localhost for the name of your computer!

    If everything was successful, you will be presented with a "Welcome to Windows XP Server Internet Services" page with a message indicating "Your Web service is now running.".

  5. In addition to a fully functioning web server, you should now also have the Simple Mail Transfer Protocol (SMTP) service running. There are many ways to check if it is running.

    I first look at the running services:

    C:\> net start
    and look for the "Simple Mail Transfer Protocol (SMTP)" running.

    We can also check that it is running on port 25 by running:

    C:\> netstat -an | grep  25
    You should see a response like:
    TCP    0.0.0.0:25         0.0.0.0:0          LISTENING

    Finally, I like to make sure SMTP is responding to requests. To do this, telnet to your machine on port 25. I then like to send the HELLO command as follows:

    C:\> telnet localhost 25
    220 melody Microsoft ESMTP MAIL Service, Version: 6.0.2600.2180 ready at  Thu, 15 Sep 2005 19:39:33 -0400
    
    helo
    250 melody Hello [127.0.0.1]
    
    quit
    221 2.0.0 melody Service closing transmission channel

  6. To allow all internal / networked workstations within your network to use IIS as an outbound SMTP server, we need to perform several tasks. The first task is to configure the firewall (if installed as part of Windows XP Service Pack 2 or higher) to allow traffic to pass through.

    Invoke the "Control Panel" and select the "Security Center" applet. If the firewall is not enabled (NOT MONITORED), then there is no need to continue with this section. If however, you have the firewall enabled, click the "Windows Firewall" in the "Manage Security Sections for:" section. In the "Exceptions" tab, click the "Add Port" button. In the dialog box, use a name of "SMTP" and the Port Number "25". Also, make sure to check the TCP radio button. The "Scope" of this rule should be set to "Any computer" by default.

    We now need to configure SMTP from within the IIS Console. At a minimum, we need to configure the "Relay Restrictions" to allow computers within the network to relay mail through this virtual server. In this example, I will simply grant to all computers the ability to relay through this server.

    Configuring SMTP (and other IIS services) is done using the "Internet Information Services" console. This application can be found from the Start menu: Start / Programs / Administration Tools / Internet Information Services.

    Once the "Internet Information Services" console is open you will see any IIS web services you have running on your machine including the SMTP server and FTP server (if you chose to install them with IIS).

    From the tree, right-click on the item "Default SMTP Virtual Server", and select "Properties". From the "Default SMTP Virtual Server Properties" dialog, select the "Access" tab. Now, select the "Relay" button under "Relay Restrictions". By default, the option "Only the list below" is selected. For my example, I want to grant everyone access so I click the "All except the list below" radio button and click "OK" on both open dialog boxes.

    After making this change, we need to restart the SMTP server from the main IIS console application. Again, right-click on the item "Default SMTP Virtual Server" and select "stop". Then do it again and select "start".



Copyright (c) 1998-2014 Jeffrey M. Hunter. All rights reserved.

All articles, scripts and material located at the Internet address of http://www.idevelopment.info is the copyright of Jeffrey M. Hunter and is protected under copyright laws of the United States. This document may not be hosted on any other site without my express, prior, written permission. Application to host any of the material elsewhere can be made by contacting me at jhunter@idevelopment.info.

I have made every effort and taken great care in making sure that the material included on my web site is technically accurate, but I disclaim any and all responsibility for any loss, damage or destruction of data or any other property which may arise from relying on it. I will in no case be liable for any monetary damages arising from such loss, damage or destruction.

Last modified on
Thursday, 18-Nov-2010 18:38:21 EST
Page Count: 17796