Skip to content

Commit 0755b0f

Browse files
Rick-AndersonLex Lilextmwadepickettr-V3
authored
Merge to live (#1088)
* Delete iis/manage/configuring-security/iis-8-certificate-management-and-deployment.md * Update TOC.yml * Update TOC.yml * Delete iis/manage/configuring-security/iis-8-sandboxing-and-security.md * Added new flags introduced in IIS 10 version 1809. * Update iis/configuration/system.applicationHost/sites/siteDefaults/bindings/binding.md * Update url-rewrite-module-video-walkthrough.md * Update url-rewrite-module-video-walkthrough.md (#1056) * Update url-rewrite-module-video-walkthrough.md * a a * Remove dead content (#1059) a * Delete dead content (#1058) * Delete dead content * Update iis/TOC.yml * Delete dead content * Delete dead content * Delete dead content * Update application-pool-identities.md (#1060) Moved the picture down so that it matches what end users should see after step 7 and 8. * Revert "Remove dead content (#1059)" (#1062) This reverts commit f739436. * SFI Image corrections for sev 0 (#1067) * IIS-docs: SFI Image Sev 1-2 Fixes (#1068) * IIS-docs: SFI Image sev 0-2 Fixes * Added more non-referenced images for deletion * finished fixing all sev 2 * Fixed broken links in Learn Online Build Report. (#1065) * Fixed broken links in Learn Online Build Report. * Fixed two more links. --------- Co-authored-by: Lex Li <[email protected]> * Added new flags introduced in IIS 10 version 1809. (#1064) Co-authored-by: Lex Li <[email protected]> * Revert "IIS-docs: SFI Image Sev 1-2 Fixes (#1068)" (#1071) This reverts commit 8df9ff5. * Update using-custom-rewrite-providers-with-url-rewrite-module.md (#1069) * Update using-custom-rewrite-providers-with-url-rewrite-module.md The download link is invalid. Deleted it. Third part saved download link: https://web.archive.org/web/20200801000000id_/download.microsoft.com/download/3/9/E/39E30671-7AD2-4902-B56B-C300D862595E/RewriteExtensibility.msi Check if there is an official download way. * Update iis/extensions/url-rewrite-module/using-custom-rewrite-providers-with-url-rewrite-module.md Linked to URL Rewrite 2.1 module as has been suggested previously by IIS team's Sam Wu. --------- Co-authored-by: Wade Pickett <[email protected]> * adding examples and making modifications (#1070) adding examples and making modifications Co-authored-by: EsraShrouf <[email protected]> * SFI images IIS-docs sev1-2 updates only (#1072) * SFI images IIS-docs sev1-2 updates only * Re-evaluated with new guidelines and high bar for change for fictitious settings required for topics * Delete .openpublishing.build.ps1 (#1073) * Update ihttprequest-getclientcertificate-method.md (#1075) * Update ihttprequest-getclientcertificate-method.md The link for HTTP_SSL_CLIENT_CERT_INFO structure was broken. So fixed the link * Update ihttprequest-getclientcertificate-method.md --------- Co-authored-by: Rick Anderson <[email protected]> * Update web-deploy-automatic-backups.md (#1076) * sfi (#1077) * SFI Wave 4 Remediation (#1078) * sfi * sfi * sfi * sfi * sfi * sfi * sfi * sfi * SFI Wave 4 Remediation (#1079) * Update hyper-v-guides.md (#1063) * Update hyper-v-guides.md removed bad links * Update iis/web-hosting/installing-infrastructure-components/hyper-v-guides.md Co-authored-by: Wade Pickett <[email protected]> --------- Co-authored-by: Wade Pickett <[email protected]> * sfi-remove unused images (#1083) * SFI Wave 4 Remediation (#1085) * sfi * . * ? * restore configure-smtp-e-mail-in-iis-7-and-above.md (#1087) --------- Co-authored-by: Lex Li <[email protected]> Co-authored-by: Lex Li <[email protected]> Co-authored-by: Wade Pickett <[email protected]> Co-authored-by: r-V3 <[email protected]> Co-authored-by: EsraShrouf <[email protected]> Co-authored-by: Shujing Zhang <[email protected]> Co-authored-by: JawaharGaneshS <[email protected]> Co-authored-by: Mick Alberts <[email protected]> Co-authored-by: Shawn Kupfer <[email protected]> Co-authored-by: Theano Petersen <[email protected]>
1 parent 4970ec6 commit 0755b0f

File tree

1 file changed

+125
-0
lines changed

1 file changed

+125
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
---
2+
title: "Configure SMTP E-Mail in IIS 7 and higher"
3+
author: rick-anderson
4+
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..."
5+
ms.date: 11/15/2009
6+
ms.assetid: 181c9548-33dd-4af4-88b8-0dab0fd05811
7+
msc.legacyurl: /learn/application-frameworks/install-and-configure-php-on-iis/configure-smtp-e-mail-in-iis-7-and-above
8+
msc.type: authoredcontent
9+
---
10+
# Configure SMTP E-Mail in IIS 7 and higher
11+
12+
by Tali Smith
13+
14+
## Note
15+
16+
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.
17+
18+
## Introduction
19+
20+
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.
21+
22+
The procedures for configuring SMTP e-mail can be performed at the following levels in Internet Information Services 7 (IIS 7) and above:
23+
24+
- Web server
25+
- Site
26+
- Application
27+
- Physical and virtual directories
28+
- File (URL)
29+
30+
## Install SMTP
31+
32+
The SMTP server is not installed by default.
33+
34+
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**.)
35+
2. Under **Features**, select **Add Features**.
36+
3. Select the **SMTP Server** check box.
37+
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**.
38+
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).
39+
40+
![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)
41+
42+
*Figure 1: Confirm Installation Selections*
43+
6. Press **Close** when installation is complete.
44+
45+
## Configure SMTP E-Mail for a Web Application
46+
47+
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.
48+
49+
### Use the User Interface
50+
51+
1. Open **Internet Information Services (IIS) Manager**, and then navigate to the level you want to manage.
52+
2. **Features View**, double-click **SMTP E-mail**.
53+
3. On the **SMTP E-mail** page, type the e-mail address of the sender in the **E-mail address** text box.
54+
4. On the **SMTP E-mail** page, select one of the following delivery methods:
55+
56+
- **Deliver e-mail to SMTP server:** to deliver e-mail messages immediately. This requires an operational SMTP server for which the user has credentials.
57+
- **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).
58+
5. If **Deliver e-mail to SMTP server** is selected, do the following:
59+
60+
- 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.
61+
- 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.
62+
- Under **Authentication Settings**, specify the authentication mode and credentials if your SMTP server requires these.
63+
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.
64+
7. Click **Apply** in the **Actions** pane.
65+
66+
### Use the Command Line
67+
68+
You can configure IIS so that e-mail is delivered immediately or stored for later delivery.
69+
70+
#### Deliver e-mail messages immediately
71+
72+
To configure SMTP e-mail to deliver e-mail messages immediately, use the following syntax:
73+
74+
[!code-console[Main](configure-smtp-e-mail-in-iis-7-and-above/samples/sample1.cmd)]
75+
76+
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.
77+
78+
#### Store e-mails for later delivery
79+
80+
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:
81+
82+
[!code-console[Main](configure-smtp-e-mail-in-iis-7-and-above/samples/sample2.cmd)]
83+
84+
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.
85+
86+
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.
87+
88+
### Edit the Configuration Files
89+
90+
1. First, configure the Php.ini file. Open the **Php.ini** file, and find the entry:
91+
92+
[!code-console[Main](configure-smtp-e-mail-in-iis-7-and-above/samples/sample3.cmd)]
93+
2. Set the following values:
94+
95+
[!code-console[Main](configure-smtp-e-mail-in-iis-7-and-above/samples/sample4.cmd)]
96+
97+
Note that the default value is localhost, so there is no need to change this if SMTP is installed locally.
98+
99+
- Save and close the **Php.ini** file.
100+
3. Enable Relay for localhost:
101+
102+
- Open the **Internet Information Services (IIS) 6.0 Manager**.
103+
- Right-click on **Default SMTP Virtual Server**.
104+
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.
105+
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.
106+
107+
![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)
108+
109+
*Figure 2: Enable Relay for localhost*
110+
6. Click **OK** to accept the information.
111+
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.
112+
8. Click **OK** to accept the options, and then click **Apply** and **OK** to return to the main page of the IIS Manager.
113+
9. Click **Restart IIS**.
114+
115+
## Test E-Mail from PHP
116+
117+
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.
118+
119+
[!code-xml[Main](configure-smtp-e-mail-in-iis-7-and-above/samples/sample5.xml)]
120+
121+
Run the file at **mydomain.com/email\_test.php**.
122+
123+
## Links for Further Information
124+
125+
- [Configure SMTP e-mail in IIS 7](https://technet.microsoft.com/library/cc772058(WS.10).aspx).

0 commit comments

Comments
 (0)