Configure Send Grid/SMTP Relay
Configure Send Grid/SMTP Relay
SendGrid Walkthrough
Customer instructions to easily copy and paste are in the following article:
https://clubspeed.freshdesk.com/a/solutions/articles/47001243510
Server Prep
Open IIS 6.0, expand the computer, right-click SMTP > select the properties

By default SMTP uses Port 25. In the event you need to swap this to Port 587 or Port 2525 you would do the following:
General Settings > Advanced... > Add... > Enter the new port number in the TCP port value box. Port 25 is fine but in the event of SMTP SendGrid authentication issue comes up, simply use a different port.

Ensure Enable logging is on in the general tab
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.
Click OK

Under the Access Tab you need to alter the "Connection Control" settings and the "Relay Restrictions" to grant access to 127.0.0.1 and the server's local IP address:

Under the Messages Tab, it should match the following configuration:

Delivery Tab

Outbound Security:
This is the actual section on where you will be entering the customer's API key from SendGrid. You will be using Basic Authentication. The username will always be "apikey" and the password will be a very long complicated string. Ensure TLS Encryption is on and visit this section later for configuration.

Outbound Connections should match the same as the image below; however, the TCP port value should match the port that SendGrid is using for the relay (default is 25)

Advanced values:
The only setting that needs to be adjusted per site is the addition of a Smart Host. In the empty field, enter "smtp.sendgrid.net"

Do not touch LDAP Routing or Security Tabs.
SQL Configurations:
ClubspeedV8 > dbo.ControlPanel > Search for the following SettingName and adjust the SettingValue field to match their locations "Single Sender Verification ID" that they will be using
EmailEventFrom
EmailMarketingFrom
EmailPurchaseOrderFrom
EmailReceiptFrom
EmailWelcomeFrom
Below is an example of Super Charged Edision's configuration:

Depending on what port they use for SMTP, you need to ensure the following values in the ControlPanel also match up:
SMTPMarketingServerPort
SMTPServerPort

The default value is 25.
Contact the customer and get an API key from SendGrid
If they don't have an account they can make a free account or strongly recommend pay for an account with the following link: SendGrid Pricing
If they plan on sending more than 100 Emails a day, they will need to upgrade to a premium account.
If they already have an account direct them to the following link:
They MUST have 2 Factor Authentication enabled on their account:
https://app.sendgrid.com/settings/auth
The integration will not work without it.
They must verify a Sender Identity :
https://app.sendgrid.com/settings/sender_auth/senders/new
This will be something they have to set up before we can continue. Essentially this will be a signature of their domain. It must be a valid domain and it cannot be a domain from "google" or "yahoo". It must be their own unique business domain.


Once verified, have them provide us with the domain that they verified so we can implement it into our SQL database.
Example of a verifed domain:

Once this is all done, have the customer go back to their Dashboard:
Have the customer "Click Email API", then click "Integration Guide"

Instruct the customer to click the "choose" option for the SMTP Relay

Instruct the customer to name the API key "Clubspeed" and then have them click "Create Key"

The highlighted YOUR_API_KEY will then change to a very long string of characters. Have them send us the exact key (everything that is highlighted) so we can implement it into the system.
Here is an example of a key (this key will not work for any other site):
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

Once we have confirmed we got the key, have them check the "I've updated my settings." and click "Next: Verify Integration"
We cannot view the API Key beyond this point as it is hidden for security purposes.
A new window will appear to "Verify Integration". Have your customer on standby to click that button but while they set up
Going back to the Clubspeed Controller > open IIS 6.0 > go back into the properties of the SMTP relay > open the Delivery Tab > Outbound Security > Update the username to be "apikey" if you haven't already > Paste the provided API key into the password field > Click OK > Click apply and OK

TEST THE CONNECTION:
Open the locations sp_admin portal > log into support > settings tab > advanced settings > Event mail template > scroll to the bottom > enter your email


Instruct the customer to Click the Verify Integration button > now you click the "Send Test Email to" button in the SP_admin portal > confirm from the customer that the test was successful (this will take a while but while it is loading it will say checking)


When successful it will look like the following:

Check your email if you received it ideally into your direct inbox (or potentially your spam folder) and if you recieved the email, then the integration was successful!
Troubleshooting:
Restart the Simple Mail Transfer Protocol (SMTP) service in Windows Services
Restart IIS
Verify the SendGrid Account doesn't have any outstanding payments due
Create a new API Key and test again
Try alternative ports (25, 587, 2525)
Clear the mailroot queue: C:\inetpub\mailroot\Queue
Testing SMTP via Telnet:
Open the following site - https://www.base64encode.org/
Open a command prompt and enter the following 1 at a time:
TELNET smtp.sendgrid.net 25
AUTH LOGIN
Username/apikey: YXBpa2V5
Password: (APIKEY after encoded into 64)
Example with encoded password blocked:

In the event you recieve a 535 error, something has gone wrong! This is similar to a 404 error. Create a new key and try again.

Sendgrid Documentation:
https://docs.sendgrid.com/for-developers/sending-email/getting-started-smtp
- Start a Telnet session by typing the following in the terminal:
SendGrid accepts unencrypted and TLS connections on ports 25, 587, & 2525. You can also connect via SSL on port 465. Many hosting providers and ISPs block port 25 as a default practice. If your Telent session continually times out or will not connect using port 25, it is likely that your ISP or hosting provider is blocking the port. You can contact your host/ISP to find out which ports are open for outgoing SMTP relay. We recommend using port 587 to avoid any rate limiting that your server host may apply.
- Once you successfully connect to SendGrid, log in to the server by typing the following:
The mail server will respond with 334 VXNlcm5hbWU6
, which is a Base64 encoded request for your username.
- Input
YXBpa2V5
and press Enter on your keyboard. Twilio SendGrid requires you to authenticate using an API key. When using Basic Authentication and an API key, you must use the stringapikey
in place of your account username. The stringapikey
isYXBpa2V5
when Base64 encoded, which is why we use it in this step.
The mail server will respond with 334 UGFzc3dvcmQ6
. This response is a Base64 encoded request for your password (your API Key).
- Enter your Base64 converted API key in the next line as the password and press Enter.
The mail server will respond with 235 Authentication successful
. Getting this far indicates that your connection to smtp.sendgrid.net
over the chosen port is open and that your API key is valid.
- Next, add the email that you’re sending from using the SMTP MAIL FROM command and press Enter.
The mail server will respond with 250 Sender address accepted
.
- Add the email that you’re sending to using the SMTP RCPT TO command and press Enter.
Note that you can add more RCPT TO addresses during this step. Repeat the process by adding another RCPT TO command and pressing Enter for each recipient you intend to deliver the message to.
The mail server will respond with 250 Recipient address accepted
after each recipient is added.
- On the next line, type
DATA
and press Enter.
The mail server will respond with 354 Continue
. Unlike the MAIL FROM and RCPT TO commands, which are part of the email envelope, the DATA command is not meant to contain information that routes your email from a sender to a recipient. Instead, DATA allows you to modify the content of your message.
- Optionally, add a mail-to header to add the name and email address of the recipient to the email header and press Enter. Note that the name should be wrapped in quotation marks, and the address should be wrapped in a greater than and less than symbol.
- Next, add a from header to add the name and email address of the sender to the email header and press Enter. If a from header is not included, SendGrid will block your email because it doesn’t follow RFC 5322 compliance guidelines. Note that the name should be wrapped in quotation marks, and the address should be wrapped in a greater than and less than symbol.
- Include a subject line and press Enter.
- Press Enter again to add a carriage line return. Then add the body content of the message and press Enter.
For example:
- Finally, send the email by typing a period,
.
, and then pressing Enter.
The mail server will return 250 Ok: queued as <examplestring1234>
. This means the email has been queued to send. The queue moves very quickly, and you should see mail delivered to the designated recipients shortly.
- Exit the Telnet connection by typing
quit
and pressing Enter.
The full command should look like the following example.
235250250354"Tira Misu"<>"Person 1"<>"This is the test message body.".250SPANISH TRANSLATION FOR CUSTOMERS TO RELAY US THE API KEY, just send the below text along with the matching photos above for directions for Spanish speaking only clients:
1. Vaya a la segunda opción en el mano izquierda que se llama "email API"

2. Luego a "Integration Guide" debajo de email API

3. Click en "Choose" Debajo de SMTP Relay.

4. Luego queremos poner un nombre, algo como "eCorreoClubspeed" por ejemplo, y usar el botón "Create Key"

5. Finalmente, después de usar el botón para crear clave(create key), nosotros ocupamos la clave y el resto de la información que aparece en el número 2.
Mandanos un screenshoot de eso para que nosotros podemos terminar la integración con SendGrid.
