Some of the websites hosted on a local computer or home server may require an email server to send out emails. For example, blogs or forums may send out notifications, or personal homepages may provide a contact form. When a local mail server is not available or not desired, a local SMTP relay may be a convenient option to collect and send emails from these websites.
The relay server receives the email from the website scripts and forwards it to a pre-configured email server on your network or the internet. Instead of configuring each individual website to send emails to the outgoing email server of, say, a Gmail or Yahoo account, all emails are simply sent to localhost. This has the advantage that, if the actual remote server changes for whatever reason, only the relay needs to be updated and the website scripts remain untouched.
Installing SMTP Server
IIS already comes with a built-in SMTP server that can be configured to act as a relay. The server is not automatically installed with IIS, but it can easily be added by performing the following steps:
- Open Add or Remove Programs from the Control Panel
- Click on the Add/Remove Windows Components button on the left
- In the Windows Components Wizard, double-click the entry for Application Server
- Double-click the entry for Internet Information Services
- Check the box for SMTP Service
- Click OK, OK again, and Next > to install the component
- Wait while setup configures the components
- Click Finish when components wizard is done.
The IIS SMTP Service is now installed and ready to be configured.
Configuring SMTP Server
The next step is to configure the SMTP server as a relay. This can be done by performing the following steps:
- Start IIS Manager
- Open Properties for the Default SMTP Virtual Server node
- Select the Access tab
- Click the Authentication… button
- Check the boxes for Anonymous access and Integrated Windows Authentication (if you have particular authentication requirements, you can configure these here as well)
- Click the Relay… button
- Uncheck Allow all computers which successfully authenticate… (if you wish to allow computers other than localhost access to the relay, you can configure these here)
- Select the Only the list below radio box and click the Add… button
- Enter 127.0.0.1 (for localhost) and click OK
- Click OK to close the Relay Restrictions window
- Select the Delivery tab
- Click the Outbound Security… button
- Configure the user name and password for your outgoing email server and click OK (this is where the user name and password for the remote email server account goes, i.e. Gmail or Yahoo)
- Back on the Delivery tab, click Advanced…, enter the domain name of your email server in the Smart host field and click OK (this is the domain of the remote email server, i.e. smtp.gmail.com)
- Click Apply and OK to close the Properties window.
The SMTP relay is now fully operational. All emails sent to localhost on port 25 should be forwarded to the configured remote email server.
Notes on PHP
If you use PHP for some of your websites you can configure a default SMTP server to be used for the mail() function by doing the following:
- Open the server’s php.ini in a text editor
- Scroll down to the section
SMTP = localhostand
smtp_port = 25
- Save and close the file
- Restart the World Wide Web Publishing Service