{"id":21470061,"url":"https://github.com/sensu-plugins/sensu-plugins-mailer","last_synced_at":"2025-07-15T07:30:48.088Z","repository":{"id":27389328,"uuid":"30865478","full_name":"sensu-plugins/sensu-plugins-mailer","owner":"sensu-plugins","description":"This plugin is an email handler for Sensu.","archived":false,"fork":false,"pushed_at":"2021-06-11T05:13:40.000Z","size":133,"stargazers_count":17,"open_issues_count":20,"forks_count":36,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-04-26T16:20:57.078Z","etag":null,"topics":["email-notification","sensu-handler","sensu-plugins"],"latest_commit_sha":null,"homepage":"http://sensu-plugins.io","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sensu-plugins.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-02-16T11:31:30.000Z","updated_at":"2021-06-07T21:18:58.000Z","dependencies_parsed_at":"2022-08-20T07:50:28.779Z","dependency_job_id":null,"html_url":"https://github.com/sensu-plugins/sensu-plugins-mailer","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sensu-plugins%2Fsensu-plugins-mailer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sensu-plugins%2Fsensu-plugins-mailer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sensu-plugins%2Fsensu-plugins-mailer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sensu-plugins%2Fsensu-plugins-mailer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sensu-plugins","download_url":"https://codeload.github.com/sensu-plugins/sensu-plugins-mailer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225048542,"owners_count":17412834,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["email-notification","sensu-handler","sensu-plugins"],"created_at":"2024-11-23T09:21:56.531Z","updated_at":"2024-11-23T09:21:57.155Z","avatar_url":"https://github.com/sensu-plugins.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Sensu-Plugins-mailer\n\n[![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-mailer.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-mailer)\n[![Gem Version](https://badge.fury.io/rb/sensu-plugins-mailer.svg)](http://badge.fury.io/rb/sensu-plugins-mailer)\n[![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-mailer/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-mailer)\n[![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-mailer/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-mailer)\n[![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-mailer.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-mailer)\n\n## Functionality\n\n## Files\n * bin/handler-mailer-mailgun.rb\n * bin/handler-mailer-ses.rb\n * bin/handler-mailer.rb\n\n## Usage\n\nThe following three configuration variables must be set if you want mailer to use remote SMTP settings:\n\n    smtp_address - defaults to \"localhost\"\n    smtp_port - defaults to \"25\"\n    smtp_domain - defaults to \"localhost.localdomain\"\n\nThere is an optional subscriptions hash which can be added to your mailer.json file.  This subscriptions hash allows you to define individual mail_to addresses for a given subscription.  When the mailer handler runs it will check the clients subscriptions and build a mail_to string with the default mailer.mail_to address as well as any subscriptions the client subscribes to where a mail_to address is found.  There can be N number of hashes inside of subscriptions but the key for a given hash inside of subscriptions must match a subscription name. \n\nOptionally, you can specify your own ERB template file to use for the message\nbody.  The order of precedence for templates is: command-line argument (-t),\nclient config called \"template\", the mailer handler config, default.\n\nOptionally, you can specify your own ERB template file to use for the message\nsubject.  The order of precedence for templates is: command-line argument (-T),\nclient config called \"subject_template\", the mailer handler config, default.\n\n```json\n{\n  \"mailer\": {\n    \"mail_from\": \"sensu@example.com\",\n    \"mail_to\": \"monitor@example.com\",\n    \"smtp_address\": \"smtp.example.org\",\n    \"smtp_port\": \"25\",\n    \"smtp_domain\": \"example.org\",\n    \"template\": \"/optional/path/to/template.erb\",\n    \"subject_template\": \"/optional/path/to/subject_template.erb\",\n    \"subscriptions\": {\n      \"subscription_name\": {\n        \"mail_to\": \"teamemail@example.com\"\n      }\n    }\n  }\n}\n```\n\n**handler-mailer-mailgun**\n```\n{\n  \"mailer-mailgun\": {\n    \"mail_from\": \"sensu@example.com\",\n    \"mail_to\": \"bob@example.com\",\n    \"mg_apikey\": \"mailgunapikeygoeshere\",\n    \"mg_domain\": \"mailgun.domain.com\"\n  }\n}\n```\n\n**handler-mailer-ses**\n```\n{\n  \"mailer-ses\": {\n    \"mail_from\": \"sensu@example.com\",\n    \"mail_to\": \"monitor@example.com\",\n    \"aws_access_key\": \"myawsaccesskey\",\n    \"aws_secret_key\": \"myawssecretkey\",\n    \"aws_ses_endpoint\": \"email.us-east-1.amazonaws.com\"\n  }\n}\n```\n\n**handler-mailer**\n```\n{\n  \"mailer\": {\n    \"admin_gui\": \"http://admin.example.com:8080/\",\n    \"mail_from\": \"sensu@example.com\",\n    \"mail_to\": \"monitor@example.com\",\n    \"smtp_address\": \"smtp.example.org\",\n    \"smtp_port\": \"25\",\n    \"smtp_domain\": \"example.org\"\n  }\n}\n```\nBy default, the handler will use `plain` as the SMTP authentication type, but you may also specify `\"smtp_authentication\": \"ntlm\"` for compatible servers, e.g. Microsoft Exchange.\n\n### Contact Based Routing\n\nOptionally, this handler can use the same syntax as [Sensu Enterprise contact routing](https://sensuapp.org/docs/0.26/enterprise/contact-routing.html) for sending e-mails for particular checks or clients, in addition to the previous configuration. This is configured by declaring contacts:\n\n**support.json**\n```\n{\n  \"contacts\": {\n    \"support\": {\n      \"email\": {\n        \"to\": \"support@sensuapp.com\"\n      }\n    }\n  }\n} \n```\n\nThen, in a check definition, you can specify a contact or an array of contacts which should be notified by e-mail:\n\n**example_check.json**\n```\n{\n  \"checks\": {\n    \"example_check\": {\n      \"command\": \"do_something.rb\",\n      \"handler\": \"mailer\",\n      \"contact\": \"support\"\n    }\n  }\n}\n```\n\nAdditionally, a client definition can specify a contact or an array of contacts to be notified of any check which alerts to the mailer handler. This is configured by specifying a contact value, or contacts array in the client.json configuration.\n\n## Installation\n\n[Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)\n\nCreate a handler file in `/etc/sensu/conf.d` with the following content, replacing with your own configuration:\n\n```json\n{\n    \"mailer\" :  {\n        \"admin_gui\" : \"http://localhost:3000\",\n        \"mail_from\": \"from@email.com\",\n        \"mail_to\": \"to@email.com\",\n        \"delivery_method\": \"smtp\",\n        \"smtp_address\": \"localhost\",\n        \"smtp_port\": \"25\",\n        \"smtp_domain\": \"localhost.local_domain\",\n        \"smtp_enable_starttls_auto\": \"true\",\n        \"smtp_username\" : \"username\",\n        \"smtp_password\" : \"XXXXXXXX\"\n    },\n    \"handlers\": {\n        \"mailer\": {\n            \"type\": \"pipe\",\n            \"command\": \"/opt/sensu/embedded/bin/handler-mailer.rb\"\n        }\n    }\n}\n```\n\n## Notes\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsensu-plugins%2Fsensu-plugins-mailer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsensu-plugins%2Fsensu-plugins-mailer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsensu-plugins%2Fsensu-plugins-mailer/lists"}