Configure SMTP E-mail (IIS 7)
Applies To: Windows 7, Windows Server 2008, Windows Server 2008 R2, Windows Vista
Configure SMTP e-mail in IIS when you want to deliver e-mail messages from your site. Mail can be delivered immediately or it can be delivered to a file location on disk where it can be retrieved for delivery later. For example, a company can provide an e-mail link for sending feedback messages or for requesting information.
Note
The e-mail configuration settings are consumed by the classes in the System.Net.Mail namespace. ASP.NET applications must use this namespace in for the configuration settings to have any effect.
Note
The SMTP server is not installed by default. SMTP can be added through the Features Summary area of the Server Manager tool in Windows Server® 2008.
Prerequisites
For information about the levels at which you can perform this procedure, and the modules, handlers, and permissions that are required to perform this procedure, see SMTP E-mail Feature Requirements (IIS 7).
Exceptions to feature requirements
- None
To configure SMTP e-mail for a Web application
You can perform this procedure by using the user interface (UI), by running Appcmd.exe commands in a command-line window, by editing configuration files directly, or by writing WMI scripts.
User Interface
To Use the UI
Open IIS Manager and navigate to the level you want to manage. For information about opening IIS Manager, see Open IIS Manager (IIS 7). For information about navigating to locations in the UI, see Navigation in IIS Manager (IIS 7).
In Features View, double-click SMTP E-mail.
On the SMTP E-mail page, type the e-mail address of the sender in the E-mail address text box.
On the SMTP E-mail page, select one of the following delivery methods:
Deliver e-mail to SMTP server: to deliver e-mail messages immediately. This requires an operational SMTP server for which the user has credentials.
Store e-mail in pickup directory: to store e-mails in a file location on disk for later delivery by an application such as an ASP.NET application, or by a user, such as an administrator.
If Deliver e-mail to SMTP server is selected, do the following:
Type the unique name of your SMTP server in the SMTP Server text box or select the Use localhost box to set the name to LocalHost. Setting the name to LocalHost means that ASP.NET will use an SMTP server on the local computer. Typically, this is the default SMTP virtual server.
Enter a TCP port in the Port text box. Port 25 is the SMTP standard TCP port and is the default setting. More than one virtual server can use the same TCP port if all servers are configured by using different IP addresses.
Under Authentication Settings, specify the authentication mode and credentials if your SMTP server requires these.
If Store e-mail in pickup directory is selected, type the batch e-mail location in the Store e-mail in pickup directory text box.
Click Apply in the Actions pane.
Command-line
Deliver e-mail messages immediately
To configure SMTP e-mail to deliver e-mail messages immediately, use the following syntax:
**appcmd set config /commit:WEBROOT /section:smtp /from:**string **/deliveryMethod:network /network.port:**int /network.defaultCredentials:True|**False /network.host:**string **/network.userName:**string **/network.password:**string
The variable **from **string is the e-mail address of the sender. The variable /deliveryMethod:network configures IIS to deliver e-mail messages immediately. The variable **/network.port **int sets the TCP port that is used by IIS to deliver e-mail messages. The variable **/network.host **string specifies the host used for SMTP transactions. The variable network.defaultCredentials:True|False enables or disables authentication using the default network credentials. If defaultCredentials is set to True, Kerberos or NTLM will be used if the server supports these protocols. The variables **network.userName:**string and **network. password:**string set a Basic authentication user name and password.
Store e-mails for later delivery
To configure SMTP e-mail to store e-mails in a file location on disk for later delivery by an application, such as an ASP.NET application, or by a user, such as an administrator, use the following syntax:
**appcmd set config /commit:WEBROOT /section:smtp /from:**string /deliveryMethod:PickupDirectoryFromIis|**SpecifiedPickupDirectory /SpecifiedPickupDirectory:**string
The variable from string is the e-mail address of the sender. The variable/deliveryMethod:PickupDirectoryFromIis|SpecifiedPickupDirectory configures IIS to store e-mails in a file location on disk for later delivery. The variable **/SpecifiedPickupDirectory **string sets the file location on disk in which to store the e-mail messages for later delivery.
Note
When you use Appcmd.exe to configure the <mailSettings> element at the global level in IIS 7, you must specify /commit:WEBROOT in the command so that configuration changes are made to the root Web.config file instead of ApplicationHost.config.
For more information about Appcmd.exe, see Appcmd.exe (IIS 7).
Configuration
The procedure in this topic affects the following configuration elements:
- <mailSettings>
For more information about IIS 7 configuration, see IIS 7.0: IIS Settings Schema on MSDN.
WMI
Use the following WMI classes, methods, or properties to perform this procedure:
- SmtpMailSettingsSection
For more information about WMI and IIS, see Windows Management Instrumentation (WMI) in IIS 7. For more information about the classes, methods, or properties associated with this procedure, see the IIS WMI Provider Reference on the MSDN site.