Skip to content

Mailozaurr is a PowerShell module that aims to provide SMTP, POP3, IMAP and probably some other ways to interact with Email. Underneath it uses MimeKit and MailKit libraries written by Jeffrey Stedfast.

License

Notifications You must be signed in to change notification settings

EvotecIT/Mailozaurr

Repository files navigation

Mailozaurr - PowerShell Module

Mailozaurr is a PowerShell module that aims to provide SMTP, POP3, IMAP and few other ways to interact with Email. Underneath it uses MimeKit and MailKit and EmailValidation libraries written by Jeffrey Stedfast.

This project has 2 branches:

  • v1-legacy - this is the old version of the module. It's working, it's stable and has been around for a while. It's written entirely in PowerShell, and has nice features. It will be maintained until v2 is ready.
  • v2-speedygonzales - this is the new version of the module. It's a complete rewrite. It's written in C#, and slowly all functions from V1 will be replaced by their C# alternative. It's faster, and has couple of new features. It's still in development, but it's already usable.
    • Removed DNS functions as they are moved to DnsClientX module
    • Removed EmailValidation/SPF/DKIM/DMARC/MX/DMARC functions as they are moved to DomainDetective module

This V2 branch uses following libraries:

For oAuth2 it also requires some Microsoft and Google libraries that are also bundled in

Additional dependencies due to features added

This started with a single goal to replace Send-MailMessage which is depracated/obsolete with something more modern, but since MailKit and MimeKit have lots of options why not build on that?

Support This Project

If you find this project helpful, please consider supporting its development. Your sponsorship will help the maintainers dedicate more time to maintenance and new feature development for everyone.

It takes a lot of time and effort to create and maintain this project. By becoming a sponsor, you can help ensure that it stays free and accessible to everyone who needs it.

To become a sponsor, you can choose from the following options:

Your sponsorship is completely optional and not required for using this project. We want this project to remain open-source and available for anyone to use for free, regardless of whether they choose to sponsor it or not.

If you work for a company that uses our .NET libraries or PowerShell Modules, please consider asking your manager or marketing team if your company would be interested in supporting this project. Your company's support can help us continue to maintain and improve this project for the benefit of everyone.

Thank you for considering supporting this project!

Building project for local use

To build a project and play with the sources you need to:

Install-Module PSPublishModule -Force -Verbose

Once the module is installed - go to Build folder and run: Manage-Mailozaurr.ps1. This will make sure the project has required libraries.

Features

  • Send Email (Send-EmailMessage) using:
    • SMTP with standard password
    • SMTP with oAuth2 Office 365
    • SMTP with oAuth2 Google Mail
    • SMTP with SendGrid
    • SendGrid API
    • Office 365 Graph API
  • POP3
    • Connect to POP3
    • Get POP3 Emails
    • Save POP3 Emails
  • IMAP
    • Connect to IMAP
    • Get IMAP Folder
    • Get Messages (you have to your own work to get what you need). Needs improvements!
  • Office 365 Graph API
    • Get Mail Folders
    • Get Mail Messages
    • Save Mail Messages
  • DNS Checks via TCP/UDP, but also via HTTPS using Cloudflare/Google providers
    • DKIM Reporting (Find-DKIMRecord)
    • MX Reporting (Find-MXRecord)
    • DMARC Reporting (Find-DMARCRecord)
    • SPF Reporting (Find-SPFRecord)
    • DNSBL Reporting (Find-DNSBL)
  • Email Validation
    • Test Email Address for errors

Documentation

While I didn't spent much time creating WIKI, working on Get-Help documentation, I did write blog articles that should help you get started.

You can also utilize Examples which should help to understand use cases. Of course it would be great having pretty help so if you can help me out feel free to submit PR's.

Keep in mind PSSharedGoods is only required for development. When you use this module from PowerShellGallery it's not installed as everything is merged.

Limiting access to mailboxes (Microsoft Graph API)

Microsoft Graph API requires Send.Mail permission to send emails. In some cases Mail.ReadWrite permission is also required when the size of email is above 4MB. If the application is registered in Azure AD (Entra ID) without any additional configuration, it will have access to all mailboxes in the organization. To limit access to specific mailboxes, you need to use Application Access Policy. This is a feature that allows you to limit access to specific mailboxes. You can read more about it here.

Following permissions (as shown on the screenshot) are required to send emails using Microsoft Graph API.

Microsoft Graph Permissions

The rest of the permissins is not required and is there for other features that Microsoft Graph provides.

To install

Install-Module -Name Mailozaurr -AllowClobber -Force

Force and AllowClobber aren't necessary, but they do skip errors in case some appear.

And to update

Update-Module -Name Mailozaurr

That's it. Whenever there's a new version, you run the command, and you can enjoy it. Remember that you may need to close, reopen PowerShell session if you have already used module before updating it.

The essential thing is if something works for you on production, keep using it till you test the new version on a test computer. I do changes that may not be big, but big enough that auto-update may break your code. For example, a small rename to a parameter, and your code stops working! Be responsible!

About

Mailozaurr is a PowerShell module that aims to provide SMTP, POP3, IMAP and probably some other ways to interact with Email. Underneath it uses MimeKit and MailKit libraries written by Jeffrey Stedfast.

Topics

Resources

License

Stars

Watchers

Forks