Zabbix with Sendgrid SMTP Notification on Ubuntu

The built-in mail option seems to work out of the box, but every post seems to suggest using a script to trigger internal mail binaries for mail notifications. Those require extra dependencies and configuration. With SendGrid and the REST API, it can be simply done with a script using curl. I assume a SendGrid account and key have already been setup.

Creating the script

sudo vim /usr/lib/zabbix/alertscripts/


curl --request POST \
 --url "" \
 --header "Authorization: Bearer $SENDGRID_API_KEY" \
 --header 'Content-Type: application/json' \
 --data "{\"personalizations\": [{\"to\": [{
\"email\": \"$1\"}]}],\"from\": {\"email\": \"[email protected]\"},\"subject\": \"$2\",\"content\": [{\"type\": \"text/plain\", \"value\": \"$3\"}]}"

Notification Testing

There is no way to test aside from triggering an actual fault, so it’s necessary to create a dummy condition and then trigger it with the zabbix_sender utility. I had to explicitly install it:

Install zabbix_sender

sudo apt install zabbix_sender

Create Action and Condition

  1. Configuration -> Actions -> Create action
  2. Select condition
  3. Add new condition (= Dummy trigger)
  4. Select the Operations tab
  5. Add new operations (user with custom media type)
  6. Save by clicking Add


zabbix_sender --zabbix-server= --host="" --key="test.timestamp" --value="${VALUE}"


VALUE="$(date --rfc-3339=ns)"; zabbix_sender --zabbix-server= --host="" --key="test.timestamp" --value="${VALUE}"



This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *