Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
bec13cc
Delete iis/manage/configuring-security/iis-8-certificate-management-a…
Rick-Anderson May 23, 2024
a01ade9
Update TOC.yml
Rick-Anderson May 23, 2024
8aecd7e
Update TOC.yml
Rick-Anderson May 23, 2024
841fbc0
Delete iis/manage/configuring-security/iis-8-sandboxing-and-security.md
Rick-Anderson May 23, 2024
cf3ce84
Added new flags introduced in IIS 10 version 1809.
Jun 6, 2024
006a4b6
Update iis/configuration/system.applicationHost/sites/siteDefaults/bi…
Rick-Anderson Jun 6, 2024
2ec91c9
Update url-rewrite-module-video-walkthrough.md
Rick-Anderson Jun 25, 2024
4a30fc9
Merge branch 'main' of https://github.com/MicrosoftDocs/iis-docs
Rick-Anderson Jun 25, 2024
a567caa
Update url-rewrite-module-video-walkthrough.md (#1056)
Rick-Anderson Jun 25, 2024
f739436
Remove dead content (#1059)
Rick-Anderson Jun 26, 2024
20eb56e
Delete dead content (#1058)
Rick-Anderson Jun 26, 2024
000a1db
Update application-pool-identities.md (#1060)
lextm Jul 9, 2024
d364764
Revert "Remove dead content (#1059)" (#1062)
Rick-Anderson Jul 10, 2024
e19028e
SFI Image corrections for sev 0 (#1067)
wadepickett Sep 30, 2024
8df9ff5
IIS-docs: SFI Image Sev 1-2 Fixes (#1068)
wadepickett Oct 22, 2024
19d63dc
Fixed broken links in Learn Online Build Report. (#1065)
lextm Oct 23, 2024
632e245
Added new flags introduced in IIS 10 version 1809. (#1064)
lextm Oct 24, 2024
28046eb
Revert "IIS-docs: SFI Image Sev 1-2 Fixes (#1068)" (#1071)
Rick-Anderson Oct 24, 2024
4f8b1be
Update using-custom-rewrite-providers-with-url-rewrite-module.md (#1069)
r-V3 Oct 28, 2024
3868c26
adding examples and making modifications (#1070)
Rick-Anderson Nov 4, 2024
59e4aed
SFI images IIS-docs sev1-2 updates only (#1072)
wadepickett Nov 5, 2024
42a16fa
Delete .openpublishing.build.ps1 (#1073)
shujingMS Nov 15, 2024
0873eb2
Update ihttprequest-getclientcertificate-method.md (#1075)
JawaharGaneshS Nov 29, 2024
df735be
Update web-deploy-automatic-backups.md (#1076)
wadepickett Jan 15, 2025
0785ef1
sfi (#1077)
v-albemi Feb 6, 2025
eadcbfb
SFI Wave 4 Remediation (#1078)
v-albemi Feb 10, 2025
dd7dc07
SFI Wave 4 Remediation (#1079)
ShawnKupfer Mar 3, 2025
297582c
Update hyper-v-guides.md (#1063)
Rick-Anderson Mar 6, 2025
6de4619
sfi-remove unused images (#1083)
v-thepet Mar 11, 2025
05f11ee
SFI Wave 4 Remediation (#1085)
v-thepet Mar 13, 2025
bedb46e
restore configure-smtp-e-mail-in-iis-7-and-above.md (#1087)
Rick-Anderson Mar 21, 2025
bd4daa9
Update ms.topic to reference (#1089)
kcpitt Mar 29, 2025
e1ccd2e
Update sample5.cmd to match test results (#1091)
lextm Mar 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions .openpublishing.build.ps1

This file was deleted.

20 changes: 0 additions & 20 deletions iis/TOC.yml
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,6 @@
href: manage/configuring-security/analyzing-client-usage-data-with-iis-user-access-logging.md
- name: Configure Request Filtering in IIS
href: manage/configuring-security/configure-request-filtering-in-iis.md
- name: IIS 8 - Certificate Management and Deployment
href: manage/configuring-security/iis-8-certificate-management-and-deployment.md
- name: IIS 8 - Sandboxing and Security
href: manage/configuring-security/iis-8-sandboxing-and-security.md
- name: Managing Performance Settings
items:
- name: Improving Performance with Native Output Caching
Expand All @@ -296,8 +292,6 @@
href: manage/managing-performance-settings/walkthrough-iis-output-caching.md
- name: Configure IIS 7 Output Caching
href: manage/managing-performance-settings/configure-iis-7-output-caching.md
- name: Use Bit Rate Throttling
href: manage/managing-performance-settings/use-bit-rate-throttling.md
- name: Managing your Configuration Settings
items:
- name: Delegating Configuration to web.config Files
Expand Down Expand Up @@ -602,8 +596,6 @@
href: troubleshoot/using-failed-request-tracing/troubleshooting-failed-requests-using-tracing-in-iis.md
- name: Using Failed Request Tracing Rules to Troubleshoot Application Request Routing
href: troubleshoot/using-failed-request-tracing/using-failed-request-tracing-rules-to-troubleshoot-application-request-routing-arr.md
- name: Troubleshoot with Failed Request Tracing
href: troubleshoot/using-failed-request-tracing/troubleshoot-with-failed-request-tracing.md
- name: Troubleshooting Failed Requests Using Tracing in IIS 8.5
href: troubleshoot/using-failed-request-tracing/troubleshooting-failed-requests-using-tracing-in-iis-85.md
- name: Performance Issues
Expand Down Expand Up @@ -707,8 +699,6 @@
href: extensions/troubleshooting-application-request-routing/troubleshooting-502-errors-in-arr.md
- name: URL Rewrite Module
items:
- name: URL Rewrite Module - Video Walkthrough
href: extensions/url-rewrite-module/url-rewrite-module-video-walkthrough.md
- name: Using the URL Rewrite Module
href: extensions/url-rewrite-module/using-the-url-rewrite-module.md
- name: Creating Rewrite Rules for the URL Rewrite Module
Expand Down Expand Up @@ -773,8 +763,6 @@
href: extensions/introduction-to-iis-express/iis-75-express-readme.md
- name: IIS 8.0 Express Readme
href: extensions/introduction-to-iis-express/iis-80-express-readme.md
- name: IIS 8 - IIS Express for Developers
href: extensions/introduction-to-iis-express/iis-8-iis-express-for-developers.md
- name: Using IIS Express
items:
- name: Using the Windows System Tray to Manage Websites and Applications
Expand Down Expand Up @@ -972,8 +960,6 @@
href: web-hosting/getting-started/deploying-a-static-content-server.md
- name: Using Windows SharePoint Services 3.0 on IIS 7.0
href: web-hosting/getting-started/using-windows-sharepoint-services-30-on-iis.md
- name: Microsoft Web Platform Privacy Statements
href: web-hosting/getting-started/microsoft-web-platform-privacy-statements.md
- name: Frequently Asked Questions (FAQ)
items:
- name: Tools and Utilities Questions
Expand All @@ -998,12 +984,8 @@
href: web-hosting/migrate-to-the-microsoft-web-platform/breaking-changes-for-aspnet-4-apps-running-on-iis-7-integrated-mode.md
- name: IIS 7 for Apache Administrators
href: web-hosting/migrate-to-the-microsoft-web-platform/iis-for-apache-administrators.md
- name: Migrate to a Windows-Based Platform
href: web-hosting/migrate-to-the-microsoft-web-platform/migrate-to-a-windows-based-platform.md
- name: Migrate from MySQL to SQL Server 2008
href: web-hosting/migrate-to-the-microsoft-web-platform/migrate-from-mysql-to-sql-server-2008.md
- name: How to Migrate to the Microsoft Web Platform
href: web-hosting/migrate-to-the-microsoft-web-platform/how-to-migrate-to-the-microsoft-web-platform.md
- name: Configuring Components
items:
- name: Enabling LINQ with ASP.NET
Expand Down Expand Up @@ -1054,8 +1036,6 @@
href: web-hosting/configuring-servers-in-the-windows-web-platform/sql-server-2005.md
- name: SQL 2008 for Hosters
href: web-hosting/configuring-servers-in-the-windows-web-platform/sql-2008-for-hosters.md
- name: Configure your Servers for the Windows Web Hosting Platform
href: web-hosting/configuring-servers-in-the-windows-web-platform/configure-your-servers-for-the-windows-web-hosting-platform.md
- name: Installing Infrastructure Components
items:
- name: Planning the Deployment
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
---
title: "Configure SMTP E-Mail in IIS 7 and higher"
author: rick-anderson
description: "To send e-mail from a PHP application using the System.Net.Mail API, you must configure Simple Mail Transfer Protocol (SMTP) e-mail. Configuring e-mail servi..."
ms.date: 11/15/2009
ms.assetid: 181c9548-33dd-4af4-88b8-0dab0fd05811
msc.legacyurl: /learn/application-frameworks/install-and-configure-php-on-iis/configure-smtp-e-mail-in-iis-7-and-above
msc.type: authoredcontent
---
# Configure SMTP E-Mail in IIS 7 and higher

by Tali Smith

## Note

The IIS SMTP Virtual Server Component that is mentioned in this article is part of IIS 6.0, the support for which has ended with the support of [Windows Server 2003](https://support.microsoft.com/lifecycle/search/810). To relay emails to Exchange OnPrem and/or Office 365, use one of the supported versions of Exchange Server, as we no longer support doing so with IIS SMTP.

## Introduction

To send e-mail from a PHP application using the System.Net.Mail API, you must configure Simple Mail Transfer Protocol (SMTP) e-mail. Configuring e-mail services tells the System.Net.Mail application programming interface (API) to which SMTP server to deliver the e-mail generated by your application. 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.

The procedures for configuring SMTP e-mail can be performed at the following levels in Internet Information Services 7 (IIS 7) and above:

- Web server
- Site
- Application
- Physical and virtual directories
- File (URL)

## Install SMTP

The SMTP server is not installed by default.

1. Open Server Manager by right-clicking on **My Computer**, and selecting **Manage**. (Alternately, open **Control Panel**, click on **Programs and Features**, and then select **Turn Windows features on or off**.)
2. Under **Features**, select **Add Features**.
3. Select the **SMTP Server** check box.
4. Click **Add Required Role Services**. If there are any missing roles required for the SMTP installation, Windows Server® 2008 R2 or Windows Server® 2008 installs them. Click **Next**.
5. You need to step through the entire wizard again, even though IIS is already installed (IIS 6 Management Compatibility and the IIS 6 Management Console must be installed for SMTP to work).

![Screenshot of the Add Features Wizard showing Confirm Installation Selections in the main pane. Install is highlighted.](configure-smtp-e-mail-in-iis-7-and-above/_static/image1.jpg)

*Figure 1: Confirm Installation Selections*
6. Press **Close** when installation is complete.

## Configure SMTP E-Mail for a Web Application

Once you add SMTP, you can configure it for your PHP applications. This can be done by using the user interface (UI), by running Appcmd.exe commands from a command prompt, by editing configuration files directly, or by writing Windows® Management Instrumentation (WMI) scripts. Note that you must have IIS installed before enabling SMTP.

### Use the User Interface

1. Open **Internet Information Services (IIS) Manager**, and then navigate to the level you want to manage.
2. **Features View**, double-click **SMTP E-mail**.
3. On the **SMTP E-mail** page, type the e-mail address of the sender in the **E-mail address** text box.
4. 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 the PHP application (or by a Microsoft® ASP.NET application or by a user).
5. 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** check box to set the name to **LocalHost**. Setting the name to LocalHost means that ASP.NET uses 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.
6. 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.
7. Click **Apply** in the **Actions** pane.

### Use the Command Line

You can configure IIS so that e-mail is delivered immediately or stored for later delivery.

#### Deliver e-mail messages immediately

To configure SMTP e-mail to deliver e-mail messages immediately, use the following syntax:

[!code-console[Main](configure-smtp-e-mail-in-iis-7-and-above/samples/sample1.cmd)]

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 are 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:

[!code-console[Main](configure-smtp-e-mail-in-iis-7-and-above/samples/sample2.cmd)]

The variable from string is the e-mail address of the sender. The variable/deliveryMethod:PickupDirectoryFromIis|SpecifiedPickupDirectory string 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 that when you use Appcmd.exe to configure the `<mailSettings>` element at the global level in IIS, you must specify **/commit:WEBROOT** in the command so that configuration changes are made to the root Web.config file instead of the ApplicationHost.config file.

### Edit the Configuration Files

1. First, configure the Php.ini file. Open the **Php.ini** file, and find the entry:

[!code-console[Main](configure-smtp-e-mail-in-iis-7-and-above/samples/sample3.cmd)]
2. Set the following values:

[!code-console[Main](configure-smtp-e-mail-in-iis-7-and-above/samples/sample4.cmd)]

Note that the default value is localhost, so there is no need to change this if SMTP is installed locally.

- Save and close the **Php.ini** file.
3. Enable Relay for localhost:

- Open the **Internet Information Services (IIS) 6.0 Manager**.
- Right-click on **Default SMTP Virtual Server**.
4. On the **Properties** page, open the **Access** tab, and then click on **Connection**. You can see which server or IP addresses are allowed to connect to the server.
5. If the IP address 127.0.0.1 is not listed, add it using the **Add** button. You may also add your server IP address to the list.

![Screenshot of a desktop showing multiple windows. The Computer dialog is at the top with I P address and O K highlighted.](configure-smtp-e-mail-in-iis-7-and-above/_static/image3.jpg)

*Figure 2: Enable Relay for localhost*
6. Click **OK** to accept the information.
7. Click the **Relay** button on the **Access** tab, and set up the relay options for the server. Ensure that localhost and the IP address 127.0.0.1 are granted permission to relay mail.
8. Click **OK** to accept the options, and then click **Apply** and **OK** to return to the main page of the IIS Manager.
9. Click **Restart IIS**.

## Test E-Mail from PHP

Create a test script to see whether you can send e-mail using PHP. Copy the following text and save it as **email\_test.php** at your server root.

[!code-xml[Main](configure-smtp-e-mail-in-iis-7-and-above/samples/sample5.xml)]

Run the file at **mydomain.com/email\_test.php**.

## Links for Further Information

- [Configure SMTP e-mail in IIS 7](https://technet.microsoft.com/library/cc772058(WS.10).aspx).
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ You can add `<binding>` elements within the `<bindings>` element for each site i
| --- | --- |
| `bindingInformation` | Required string attribute.<br><br>Specifies information to communicate with a site. For example, a Web site binding includes the IP address (or unspecified IP addresses), the port number, and an optional host header used to communicate with the site. |
| `protocol` | Required string attribute.<br><br>Specifies the protocol for communicating with a site. |
| `sslFlags` | Optional uint attribute.<br><br>Specifies the type of binding used for Secure Sockets Layer (SSL) certificates.<br><ul> <li>A value of "0" specifies that the secure connection be made using an IP/Port combination. Only one certificate can be bound to a combination of IP address and the port.</li> <li>A value of "1" specifies that the secure connection be made using the port number and the host name obtained by using Server Name Indication (SNI).</li> <li>A value of "2" specifies that the secure connection be made using the centralized SSL certificate store without requiring a Server Name Indicator.</li> <li>A value of "3" specifies that the secure connection be made using the centralized SSL certificate store while requiring Server Name Indicator</li></ul> Centralized SSL certificate support enables you to create a centralized certificate store that can contain multiple certificate files. You can name the certificate files to correspond to the host names that they contain. This enables you to create a binding that only requires a port, rather than an IP/port or a host name/port combination. When a request comes in, IIS matches the port, determines the host name from the request, and searches the centralized certificate store for a certificate file with a matching name. It uses that certificate. <br><br> With a Server Name Indicator (SNI), the host name is exchanged as part of the SSL handshake. SNI is enabled in the Add Site Binding dialog box when you add a binding with a type of HTTPS. This is especially useful for SSL connections that host multiple servers on a single network address. For more information, see [IIS 8.0 Server Name Indication (SNI): SSL Scalability](/iis/get-started/whats-new-in-iis-8/iis-80-server-name-indication-sni-ssl-scalability). <br><br>The sslFlags attribute is only set when the protocol is **https**. The default value is `0`. |
| `sslFlags` | Optional `uint` attribute that works like flags type, with the following possible flags: <table> <tbody> <tr> <th>Value</th> <th>Description</th></tr> <tr> <th><code>0</code></th> <td>The secure connection made using an IP/Port combination. Only one certificate can be bound to a combination of IP address and the port.</td></tr> <tr> <th><code>1</code></th> <td>The secure connection made using the port number and the host name obtained by using Server Name Indication (SNI).</td></tr> <tr> <th><code>2</code></th> <td>The secure connection be made using the centralized SSL certificate store.</td></tr> <tr> <th><code>4</code></th> <td>Disable HTTP/2.</td></tr> <tr> <th><code>8</code></th> <td>Disable OCSP Stapling.</td></tr> <tr> <th><code>16</code></th> <td>Disable QUIC.</td></tr> <tr> <th><code>32</code></th> <td>Disable TLS 1.3 over TCP.</td></tr> <tr> <th><code>64</code></th> <td>Disable Legacy TLS.</td></tr> </tbody></table> Centralized SSL certificate support enables creating a centralized certificate store that can contain multiple certificate files. The certificate files can be named to correspond to the host names that they contain. This enables creating a binding that only requires a port, rather than an IP/port or a host name/port combination. When a request comes in, IIS matches the port, determines the host name from the request, and searches the centralized certificate store for a certificate file with a matching name. It uses that certificate. <br><br> With a Server Name Indicator (SNI), the host name is exchanged as part of the SSL handshake. SNI is enabled in the **Add Site Binding** dialog box when adding a binding with a type of HTTPS. This is useful for SSL connections that host multiple servers on a single network address. <br><br> Values greater than 4 are only supported in IIS 10 version 1809 and higher. The default value is `0`. |

### Child Elements

Expand Down
Loading