Skip to content

PowershellFrameworkCollective/MailDaemon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MailDaemon

Description

This module is a simple way to implement a mail daemon on your systems.

Ever felt it a pain to set up your mail system right? Anonymous sending is causing trouble, but you don't want to give every task user access to an account to do so? Wished it was as easy as writing a logfile and emails aren't lost during a downtime?

Then this module is for you!

Main Features

  • Centralize mail sending, with dedicated account or credentials
  • Retry sending emails when service is unavailable
  • Full logging without having to worry about the logs - never again lose a message without being able to look up why
  • Easy to setup
  • Easy to use
  • Manageable by Group Policy / SCCM / Intune / ...

Prerequisites

  • PowerShell 5.1 (or later)
  • PowerShell Module: PSFramework
  • PowerShell Module: EntraAuth

Installation

To install the module from the PSGallery, run this line:

Install-Module MailDaemon

Setting up the Daemon on your system

Local using SMTP

Install-MDDaemon -SmtpServer mail.domain.com -SenderDefault '[email protected]' -RecipientDefault '[email protected]'

Local using Graph API

Install-MDDaemon -SenderDefault '[email protected]' -ClientID $clientID -TenantID $tenantID -CertificateName 'CN=GraphMailCertificate'

Remote Deployment

Setting it up an all^ machines^^:

Get-ADComputer -Filter * | Install-MDDaemon -SmtpServer mail.domain.com -SenderDefault '[email protected]' -RecipientDefault '[email protected]'

^Will copy the modules needed if not already present

^^Expect some of them to fail, due to being offline ;)

Setting up Sending emails via Graph

Some setup is required before you can send emails via Graph API.

WARNING: Before you actually go and do it, read to the end of this section!!!

The third step is an incredibly impactful step - it gives your application full access to every single mailbox in the tenant, which is almost certainly way too much! You should constrain the scope of your application's permission first before assigning those scopes. This may need to be done by the Exchange ONline team.

Sending Emails

Sending emails is a matter of up to three commands used during your script:

Preparing your email meta information

Can be run any number of times to later specify other information

Set-MDMail -From '[email protected]' -To '[email protected]' -Subject 'Backup Failed'

Adding content to the mail body

Can also be specified/overwritten during Set-MDMail

Add-MDMailContent "Backup on server $server failed due to $errorreason"

Submitting mail for sending

Send-MDMail -TaskName BackupTask

About

A module implementing an Email Agent

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

 
 
 

Contributors