<link href="https://fonts.googleapis.com/css?family=Roboto:100,100italic,200,200italic,300,300italic,400,400italic,500,500italic,600,600italic,700,700italic,800,800italic,900,900italic&amp;display=swap" rel="stylesheet"/>
2 minutes reading time (450 words)

Create an API key in SendGrid for sending SMTP email

How to create an API key with the correct permissions for sending SMTP email in SendGrid, with an example of the settings to send mail using the API key

Create a new API key

Logon to SendGrid
https://app.sendgrid.com/login

Settings - API Keys - Create API Key

API Key Name e.g. website
API Key Permissions - Select Restricted Access

Set the API key permissions

Mail Send - set permissions to full access

You can use the API to access other SendGrid features, which may mean assigning different permissions to the API key. (refer to the SendGrid API documentation linked at the end of this article)

You should follow the principle of "least privilege" when assigning API key permissions. If in doubt, just assign "Mail send" permissions 

Create & view

Copy the API key

Edit API key permissions

You can edit the permissions or delete the API key but you wont be able to view it again after its been created

Settings for using the API key to send SMTP mail

Here is an example for using the SendGrid API key to send mail using SMTP
The username will always be apikey, you'll need to replace SECRETKEY with your own API key

Mail server smtp.sendgrid.net
Port 587
Security STARTTLS
Username apikey
Password SECRETKEY

Send a test message using PowerShell

Send a test message using the API Key from PowerShell. You will get prompted for credentials, the username will be apikey, and the password will be the secret key.

Send-MailMessage -SmtpServer smtp.sendgrid.net -Credential $credential -Usessl -Port 587 -From noreply@yourdomain.com -To user@domain.com -Subject "test email from sendgrid" -Body "this is a test email" 

Related Posts

 

Comments

No comments made yet. Be the first to submit a comment
Already Registered? Login Here
Tuesday, 16 September 2025
You can help support this website by buying me a coffee!
Buy Me A Coffee