Skip to content

crshanks/nr-synthetics-ms365-sendmail

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

nr-synthetics-ms365-sendmail

This repository provides some examples of how to send emails from New Relic Synthetics using Microsoft Graph sendMail API.

Microsoft Graph sendMail

While Microsoft provides a SDK for accessing MS Graph, it isn’t currently available on the synthetics public minion runtime. Therefore the example code (GitHub repo) makes calls to the sendMail API directly.

Steps to try this out yourself (with credit to this excellent stack overflow answer):

  1. Set up a free Microsoft 365 developer sandbox subscription, if you don’t have one already
  2. Create an Azure App registration for sending emails
  • Create an Azure App registration, no redirct url is required

  • Add mail sending permission: Azure App Registration Admin > API permissions > Add permission > Microsoft Graph > Application permissions > Mail.Send

    WARNING: You will want to limit access of the app registration to specific mailboxes using application access policy. By default its tenant wide - allows impersonation of any user's mailbox!

  • Grant Admin Consent to permission to your newly created Mail.Send permission (likely requires Global Admin)

  • Create Application Password: Azure App Registration Admin > Certificates and secrets > Client Secrets -> New client secret (note the generated secret)

  • Create a reminder/plan to refresh this secret every expiration period (in Azure as well as your own code)

  1. Consider limiting Mail.Send permission based on the Warning above (see Appendix 2 here)
  2. Run one of the scripts in Synthetics new runtime as a Scripted API monitor from a single location
  • sendmail.js: a minimal example that sends a hello world email to the recipient
  • sendmail-report-dashboard.js: a script that creates a snapshot url for a dashboard and embeds the PNG image in the email body

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published