I've published the beta of PoshMailKit (0.9.1-beta2). You can install and try it out using this command:
Install-Module -Name PoshMailKit -AllowPrerelease
Or, you can check it out on GitHub.
Rename
Who is that masked man...
As mentioned in my update of my last post, I had to change the name of the project because I discovered that somebody had already taken the name in the PowerShell Gallery a couple years ago and pretty much immediately abandoned and delisted it. While I like that old name a bit better, this one with work just as well.
What works
Feels good getting that solved
I've gotten the following implemented in Send-MKMailMessage
, which will all work identically to their counterparts in the old SmtpClient
based Send-MailMessage
:
- To, Cc, and Bcc, all with multiple recipients support
- Basic parameters: Subject, From, Body, SmtpServer, Port
- BodyAsHtml
- Attachments
- Priority
- Note: as the
Send-MailMessage
version relies on aSystem.Net.Mail
based Enum, I've recreated the enum with the same options, but they don't translate directly to the proper priorities inMailKit
- The names in
MailKit
's version of the Enum (MailKit.MessagePriority
) are the actual names that the protocol uses:- Normal is still Normal
- High is Urgent
- Low is NonUrgent
- This parameter is included for legacy support so it can work as a drop-in replacement as intended
- Note: as the
Additionally, I've included the following parameters that aren't found in Send-MailMessage
:
- MessagePriority
- This is the replacement parameter for Priority using the
MailKit.MessagePriority
enum directly; note that -Priority is really just translating to what this parameter takes, and it otherwise functions identically under the hood - This parameter and the legacy -Priority parameter are mutually exclusive
- Using -Priority or -MessagePriority will put the cmdlet into
Legacy
orModern
mode (respectively) and are mutually exclusive; currently this only affects these parameters, but other parameters will also get modern counterparts that will behave differently (and, arguably, better, or at least more "correctly")
- This is the replacement parameter for Priority using the
- InlineAttachments
- This allows you to include labeled attachments that you can use with an HTML body
- It takes a hashtable consisting of \<label data-preserve-html-node="true"-name> = \<path data-preserve-html-node="true"-to-file>
- I'm not giving examples of how to use it just yet but plan to include some with the 1.0 release; that said, without going into details or a full example, you can call the attachment by adding
src='cid:<label-name>'
to the appropriate tag
Finally, it supports positional parameters and takes them the same way Send-MailMessage
does. I would have preferred to make some changes to them because it's kind of weird that you're required to include the -From parameter but it's not positional, so at the very end you have to add one named parameter, but it is what it is; I doubt many people are really using it this way anyway.
What doesn't (but will for 1.0)
Don't worry, it'll fit together
The following are the (currently identified) things I need to add before I'll be willing to declare this project at 1.0 status:
- ReplyTo
- Delivery notifications
- Encoding options
- SSL
- Authentication credentials
- Parameter aliases to match
Send-MailMessage
- Documentation and help files
Open to help
While I doubt anyone's going to jump in to help with this, at least not until (and unless) it becomes popular/well-known/in-use enough, if anyone is interested, I'd be open to entertaining pull requests addressing outstanding issues, or even just people adding issues to request features or report bugs.
Hopefully it won't be too long before I have it ready for a 1.0 release.
Image attribution
See links to origin sites for proper attribution to creators
The rest I made myself (poorly)