Using a third-party email service, Amazon Simple Email Service (SES)
0
I want to use the Amazon Simple Email Service (SES) to send emails to our client from our Company's SQL server. Additional Notes from our developer are below:
Using a Third-Party Email Service
Another way to send mail from SQL Server 2019 on Linux without using xp_cmdshell is to use a third-party email service such as SendGrid or Amazon Simple Email Service (SES).
To use a third-party email service, you need to create an account with the service and obtain your API key. Once you have your API key, you can use it to send emails from your database using the third-party email service's API.
For example, the following T-SQL code sends an email to the address john.doe@example.com using the SendGrid API:
SQL
DECLARE @apiKey VARCHAR(255) = 'YOUR_SENDGRID_API_KEY';
DECLARE @request NVARCHAR(MAX) = N'https://api.sendgrid.com/v3/mail/send';
DECLARE @jsonBody NVARCHAR(MAX) = N'{
"personalizations": [
{
"to": [
{
"email": "john.doe@example.com"
}
]
}
],
"from": {
"email": "sender@example.com"
},
"subject": "Test email from SQL Server",
"content": [
{
"type": "text/plain",
"value": "This is a test email from SQL Server."
}
]
}';