Skip to content
This repository has been archived by the owner on Feb 14, 2020. It is now read-only.

SMTP Server Setup with SendGrid

Harun Davood edited this page Oct 13, 2017 · 1 revision

Prerequisites

  1. Windows Server with IIS > 7.0 enabled
  2. A SendGrid account with a username and password

Configure IIS

  1. Open IIS Manager in Windows
  2. Click on your site and double-click on the “SMTP E-mail” under the ASP.NET section
  3. Click on the “Deliver e-mail to SMTP server” radio button if not already enabled and enter 'localhost' In the SMTP Server field or check the 'Use localhost' box
  4. In the port field, type 587.
  5. In Authentication Settings click the “Not required” option.
  6. On the right side “Actions” pane: click Apply

Enable SMTP Service:

  1. Access the "Windows Features On and Off" feature on your Windows server.
  2. Click "Next" until you get to the Features tab.
  3. Scroll down the list to the SMTP Server, and check the box. The Required Role Services dialog will appear, listing all of the dependencies that the SMTP server depends on to operate. Click Add Require Role Services.
  4. Click Next twice and review the list of available IIS Role Services and check any that you would like to add
  5. Click Next then click Install
  6. Once the SMTP Server service is installed, the IIS 6.0 virtual server technology is activated, and the IIS 6.0 administration snap-in will now be active.

Configure IIS 6.0 to Relay Outbound Email to SendGrid

  1. From the Server Manager interface Go to Tools > IIS 6.0 Manager
  2. Right click on the SMTP Virtual Server #1 and select the Properties option
  3. Click the box to enable logging section to assist you in configuring the server
  4. Click on Properties and check the box to activate Use Local Time For File Naming And Rollover option Click on the Advanced tab and check the following items: Date, Time, Client IP Address, User Name, Service Name, Server Name, Server IP Address, Server Port, Method, Protocol Status, Bytes Sent, Protocol Version, and Host.
  5. Click OK
  6. Click on the Access tab the click the Relay button in the Relay Restrictions section
  7. Click Add, enter 127.0.0.1, and click OK. The IP will appear in the list with Access Granted
  8. Click OK Only The List Below radio button and enter 127.0.0.1 in the IP address field.
  9. Click on OK to return to the Access tab as shown in the previous screenshots.
  10. Select the Delivery tab and click the Outbound Security button
  11. Click on Basic Authentication where the Username will be your SendGrid.com username and the password will be your SendGrid.com password
  12. Click OK
  13. Click the Advanced button
  14. In the Smart host field: enter smtp.sendgrid.net
  15. Click on OK twice and you can close the IIS 6.0 admin MMC

Configure Domains

  1. In IIS 6.0 Manager, expand the SMTP virtual server, right-click Domains, point to New, and then click Domain.
  2. In Welcome to the New SMTP Domain Wizard, ensure that the Remote option is selected, and click Next.
  3. In Domain Name, in the Name text box, type in:
 smtp.sendgrid.net
  1. Right-click the domain you just created, and then click Properties.
  2. Select the Allow incoming mail to be relayed to this domaincheck box.
  3. Click Outbound Security, and then configure the authentication and provide the credentials required by the SMTP server to which the smart host will connect.

Testing Your New Configuration

  1. Open up a telnet client within Windows. You do that in the Command Prompt by entering the following:
telnet localhost 587
  1. With telnet running, enter the following commands pressing ENTER for each new line (if configured correctly, the server won’t do anything until you enter the period):
EHLO
AUTH LOGIN
<Enter your BASE64 encoded SendGrid username here>
<Enter your BASE64 encoded SendGrid password here>
  1. Send a message to a specific email address by entering the following commands pressing ENTER for each new line. You will complete your message after typing the message body and entering a "." on a new line.
mail from: <enter any sender address here>
rcpt to: <enter a valid email address here> 
data
To: <enter recipient name here>
From: <enter sender name here>
Subject: <enter email subject here>
<hit enter>
<type message body and hit enter>
. 
  1. If these manually entered commands work, then you should have the following success code: "250….Queued mail for delivery"

Note: If you receive an error stating “‘telnet’ is not recognized as an internal or external command, operable program or batch file.” this means that Telnet is not installed on your machine. This can be done by visiting your “Add and Remove Progams” section within your Control Panel, and installing the ‘Telnet Client’ and ‘Telnet Server’ packages within ‘Turn Windows features on or off”.