├── .editorconfig ├── .github └── FUNDING.yml ├── .gitignore ├── Build └── Manage-Mailozaurr.ps1 ├── CHANGELOG.MD ├── Docs ├── Connect-IMAP.md ├── Connect-POP.md ├── Connect-oAuthGoogle.md ├── Connect-oAuthO365.md ├── ConvertTo-GraphCredential.md ├── ConvertTo-OAuth2Credential.md ├── ConvertTo-SendGridCredential.md ├── Disconnect-IMAP.md ├── Disconnect-POP.md ├── Find-DKIMRecord.md ├── Find-DMARCRecord.md ├── Find-DNSBL.md ├── Find-MxRecord.md ├── Find-SPFRecord.md ├── Get-IMAPFolder.md ├── Get-IMAPMessage.md ├── Get-MailFolder.md ├── Get-MailMessage.md ├── Get-POPMessage.md ├── Images │ └── MicrosoftGraphPermissions.png ├── Readme.md ├── Resolve-DnsQuery.md ├── Resolve-DnsQueryRest.md ├── Save-MailMessage.md ├── Save-POPMessage.md ├── Send-EmailMessage.md └── Test-EmailAddress.md ├── Examples ├── Example-ConnecToImap-01.ps1 ├── Example-ConnecToImap-02.ps1 ├── Example-ConnecToImap-03-oAuth.ps1 ├── Example-ConnecToPop3-01.ps1 ├── Example-ConnecToPop3-02.ps1 ├── Example-ConnecToPop3-03-oAuth.ps1 ├── Example-ConvertFromEmlToMsg.ps1 ├── Example-ImportMSG.ps1 ├── Example-SendEmail-01-Text.ps1 ├── Example-SendEmail-01.ps1 ├── Example-SendEmail-02.ps1 ├── Example-SendEmail-Graph.ps1 ├── Example-SendEmail-GraphWithMgRequest.ps1 ├── Example-SendEmail-OAuthGmail.ps1 ├── Example-SendEmail-OAuthO365.ps1 ├── Example-SendEmail-SendGrid01.ps1 ├── Example-SendEmail-SendGrid02.ps1 ├── Example-ValidateEmail.ps1 └── Input │ └── Test.txt ├── LICENSE ├── Mailozaurr.AzurePipelines.yml ├── Mailozaurr.Tests.ps1 ├── Mailozaurr.psd1 ├── Mailozaurr.psm1 ├── README.MD ├── Sources ├── Mailozaurr.Examples │ ├── Mailozaurr.Examples.csproj │ └── Program.cs ├── Mailozaurr.PowerShell │ ├── CmdletConnectIMAP.cs │ ├── CmdletConnectOAuthGoogle.cs │ ├── CmdletConnectOAuthO365.cs │ ├── CmdletConnectPOP.cs │ ├── CmdletConvertFromEmlToMsg.cs │ ├── CmdletConvertToGraphCredential.cs │ ├── CmdletConvertToOAuth2Credential.cs │ ├── CmdletConvertToSendGridCredential.cs │ ├── CmdletDisconnectIMAP.cs │ ├── CmdletDisconnectPOP.cs │ ├── CmdletGetIMAPFolder.cs │ ├── CmdletGetIMAPMessage.cs │ ├── CmdletGetMailFolder.cs │ ├── CmdletGetMailMessage.cs │ ├── CmdletGetMailMessageAttachment.cs │ ├── CmdletGetPOPMessage.cs │ ├── CmdletImportMailFile.cs │ ├── CmdletSaveMailMessage.cs │ ├── CmdletSavePOPMessage.cs │ ├── CmdletSendEmailMessage.cs │ ├── CmdletTestEmailAddress.cs │ ├── Communication │ │ ├── AsyncPSCmdlet.cs │ │ ├── InternalLoggerPowerShell.cs │ │ └── LogEmitter.cs │ ├── CredentialHelpers.cs │ ├── Definitions │ │ ├── EmlConversionResult.cs │ │ ├── ImapConnectionInfo.cs │ │ └── PopConnectionInfo.cs │ ├── Mailozaurr.PowerShell.csproj │ ├── Mailozaurr.PowerShell.csproj.DotSettings │ └── OnImportAndRemove.cs ├── Mailozaurr.sln ├── Mailozaurr.sln.DotSettings └── Mailozaurr │ ├── Authentication │ ├── OAuthHelpers.cs │ └── SaslMechanismNtlmIntegrated.cs │ ├── Definitions │ ├── EmlConversionResult.cs │ ├── OAuthCredential.cs │ └── ValidatedEmail.cs │ ├── EmailMessage.cs │ ├── Enums │ ├── ActionPreference.cs │ ├── DeliveryNotification.cs │ ├── EmailAction.cs │ ├── EmailActionEncryption.cs │ ├── EmailProvider.cs │ └── MessagePriority.cs │ ├── Helpers │ ├── Helpers.cs │ └── SecureStringHelper.cs │ ├── Imap.cs │ ├── Logging │ ├── InternalLogger.cs │ ├── LogCollector.cs │ ├── LogEntry.cs │ ├── LoggingConfigurator.cs │ └── LoggingMessages.cs │ ├── Mailgun │ └── Mailgun.cs │ ├── Mailozaurr.csproj │ ├── Mailozaurr.csproj.DotSettings │ ├── MicrosoftGraph │ ├── Graph.cs │ ├── GraphAttachment.cs │ ├── GraphAuthorization.cs │ ├── GraphErrors.cs │ └── GraphMessage.cs │ ├── MicrosoftGraphUtils.cs │ ├── Pop.cs │ ├── README.md │ ├── SendGrid │ ├── SendGridClient.cs │ └── SendGridMessage.cs │ ├── Smtp │ ├── ClientSmtp.cs │ ├── Smtp.cs │ ├── SmtpResult.cs │ └── SmtpSecureMime.cs │ └── Validator.cs └── Tests └── Send-EmailMessage.Tests.ps1 /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: PrzemyslawKlys 4 | custom: https://paypal.me/PrzemyslawKlys -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Ignore/* 2 | .vs/* 3 | .vscode/* 4 | Examples/Output/* 5 | Examples/Input/* 6 | Examples/Documents/* 7 | Releases/* 8 | Artefacts/* 9 | ReleasedUnpacked/* 10 | Sources/.vs 11 | Sources/*/.vs 12 | Sources/*/obj 13 | Sources/*/bin 14 | Sources/*/*/obj 15 | Sources/*/*/bin 16 | Sources/packages/* 17 | Lib/Default/* 18 | Lib/Standard/* 19 | Lib/Core/* -------------------------------------------------------------------------------- /Build/Manage-Mailozaurr.ps1: -------------------------------------------------------------------------------- 1 | # Install-Module PSPublishModule -Force 2 | Import-Module PSPublishModule -Force 3 | 4 | Build-Module -ModuleName 'Mailozaurr' { 5 | # Usual defaults as per standard module 6 | $Manifest = [ordered] @{ 7 | ModuleVersion = '2.0.0' 8 | # Supported PSEditions 9 | CompatiblePSEditions = @('Desktop', 'Core') 10 | # ID used to uniquely identify this module 11 | GUID = '2b0ea9f1-3ff1-4300-b939-106d5da608fa' 12 | # Author of this module 13 | Author = 'Przemyslaw Klys' 14 | # Company or vendor of this module 15 | CompanyName = 'Evotec' 16 | # Copyright statement for this module 17 | Copyright = "(c) 2011 - $((Get-Date).Year) Przemyslaw Klys @ Evotec. All rights reserved." 18 | # Description of the functionality provided by this module 19 | Description = '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. ' 20 | # Minimum version of the Windows PowerShell engine required by this module 21 | PowerShellVersion = '5.1' 22 | # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. 23 | Tags = @('Windows', 'MacOS', 'Linux', 'Mail', 'Email', 'MX', 'SPF', 'DMARC', 'DKIM', 'GraphApi', 'SendGrid', 'Graph', 'IMAP', 'POP3') 24 | 25 | IconUri = 'https://evotec.xyz/wp-content/uploads/2020/07/MailoZaurr.png' 26 | 27 | ProjectUri = 'https://github.com/EvotecIT/MailoZaurr' 28 | 29 | PreReleaseTag = 'Preview5' 30 | } 31 | New-ConfigurationManifest @Manifest 32 | 33 | $ConfigurationFormat = [ordered] @{ 34 | RemoveComments = $false 35 | 36 | PlaceOpenBraceEnable = $true 37 | PlaceOpenBraceOnSameLine = $true 38 | PlaceOpenBraceNewLineAfter = $true 39 | PlaceOpenBraceIgnoreOneLineBlock = $false 40 | 41 | PlaceCloseBraceEnable = $true 42 | PlaceCloseBraceNewLineAfter = $false 43 | PlaceCloseBraceIgnoreOneLineBlock = $false 44 | PlaceCloseBraceNoEmptyLineBefore = $true 45 | 46 | UseConsistentIndentationEnable = $true 47 | UseConsistentIndentationKind = 'space' 48 | UseConsistentIndentationPipelineIndentation = 'IncreaseIndentationAfterEveryPipeline' 49 | UseConsistentIndentationIndentationSize = 4 50 | 51 | UseConsistentWhitespaceEnable = $true 52 | UseConsistentWhitespaceCheckInnerBrace = $true 53 | UseConsistentWhitespaceCheckOpenBrace = $true 54 | UseConsistentWhitespaceCheckOpenParen = $true 55 | UseConsistentWhitespaceCheckOperator = $true 56 | UseConsistentWhitespaceCheckPipe = $true 57 | UseConsistentWhitespaceCheckSeparator = $true 58 | 59 | AlignAssignmentStatementEnable = $true 60 | AlignAssignmentStatementCheckHashtable = $true 61 | 62 | UseCorrectCasingEnable = $true 63 | } 64 | # format PSD1 and PSM1 files when merging into a single file 65 | # enable formatting is not required as Configuration is provided 66 | New-ConfigurationFormat -ApplyTo 'OnMergePSM1', 'OnMergePSD1' -Sort None @ConfigurationFormat 67 | # format PSD1 and PSM1 files within the module 68 | # enable formatting is required to make sure that formatting is applied (with default settings) 69 | New-ConfigurationFormat -ApplyTo 'DefaultPSD1', 'DefaultPSM1' -EnableFormatting -Sort None 70 | # when creating PSD1 use special style without comments and with only required parameters 71 | New-ConfigurationFormat -ApplyTo 'DefaultPSD1', 'OnMergePSD1' -PSD1Style 'Minimal' 72 | 73 | # configuration for documentation, at the same time it enables documentation processing 74 | New-ConfigurationDocumentation -Enable:$false -StartClean -UpdateWhenNew -PathReadme 'Docs\Readme.md' -Path 'Docs' 75 | 76 | New-ConfigurationImportModule -ImportSelf #-ImportRequiredModules 77 | 78 | 79 | $newConfigurationBuildSplat = @{ 80 | Enable = $true 81 | SignModule = $true 82 | MergeModuleOnBuild = $true 83 | MergeFunctionsFromApprovedModules = $true 84 | CertificateThumbprint = '483292C9E317AA13B07BB7A96AE9D1A5ED9E7703' 85 | ResolveBinaryConflicts = $true 86 | ResolveBinaryConflictsName = 'Mailozaurr.PowerShell' 87 | NETProjectName = 'Mailozaurr.PowerShell' 88 | NETConfiguration = 'Release' 89 | NETFramework = 'net8.0', 'net472' 90 | NETHandleAssemblyWithSameName = $true 91 | #NETMergeLibraryDebugging = $true 92 | DotSourceLibraries = $true 93 | DotSourceClasses = $true 94 | DeleteTargetModuleBeforeBuild = $true 95 | 96 | #RefreshPSD1Only = $true 97 | } 98 | 99 | New-ConfigurationBuild @newConfigurationBuildSplat #-DotSourceLibraries -DotSourceClasses -MergeModuleOnBuild -Enable -SignModule -DeleteTargetModuleBeforeBuild -CertificateThumbprint '483292C9E317AA13B07BB7A96AE9D1A5ED9E7703' -MergeFunctionsFromApprovedModules 100 | 101 | New-ConfigurationArtefact -Type Unpacked -Enable -Path "$PSScriptRoot\..\Artefacts" -RequiredModulesPath "$PSScriptRoot\..\Artefacts\Modules" 102 | New-ConfigurationArtefact -Type Packed -Enable -Path "$PSScriptRoot\..\Releases" -IncludeTagName 103 | 104 | #New-ConfigurationTest -TestsPath "$PSScriptRoot\..\Tests" -Enable 105 | 106 | # global options for publishing to github/psgallery 107 | #New-ConfigurationPublish -Type PowerShellGallery -FilePath 'C:\Support\Important\PowerShellGalleryAPI.txt' -Enabled:$true 108 | #New-ConfigurationPublish -Type GitHub -FilePath 'C:\Support\Important\GitHubAPI.txt' -UserName 'EvotecIT' -Enabled:$true 109 | } -ExitCode -------------------------------------------------------------------------------- /Docs/Connect-IMAP.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Mailozaurr-help.xml 3 | Module Name: Mailozaurr 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Connect-IMAP 9 | 10 | ## SYNOPSIS 11 | {{ Fill in the Synopsis }} 12 | 13 | ## SYNTAX 14 | 15 | ### Credential (Default) 16 | ``` 17 | Connect-IMAP [-Server ] [-Port ] [-Credential ] [-Options ] 18 | [-TimeOut ] [] 19 | ``` 20 | 21 | ### ClearText 22 | ``` 23 | Connect-IMAP [-Server ] [-Port ] -UserName -Password 24 | [-Options ] [-TimeOut ] [] 25 | ``` 26 | 27 | ### oAuth2 28 | ``` 29 | Connect-IMAP [-Server ] [-Port ] [-Credential ] [-Options ] 30 | [-TimeOut ] [-oAuth2] [] 31 | ``` 32 | 33 | ## DESCRIPTION 34 | {{ Fill in the Description }} 35 | 36 | ## EXAMPLES 37 | 38 | ### Example 1 39 | ```powershell 40 | PS C:\> {{ Add example code here }} 41 | ``` 42 | 43 | {{ Add example description here }} 44 | 45 | ## PARAMETERS 46 | 47 | ### -Credential 48 | {{ Fill Credential Description }} 49 | 50 | ```yaml 51 | Type: PSCredential 52 | Parameter Sets: Credential, oAuth2 53 | Aliases: 54 | 55 | Required: False 56 | Position: Named 57 | Default value: None 58 | Accept pipeline input: False 59 | Accept wildcard characters: False 60 | ``` 61 | 62 | ### -Options 63 | {{ Fill Options Description }} 64 | 65 | ```yaml 66 | Type: SecureSocketOptions 67 | Parameter Sets: (All) 68 | Aliases: 69 | Accepted values: None, Auto, SslOnConnect, StartTls, StartTlsWhenAvailable 70 | 71 | Required: False 72 | Position: Named 73 | Default value: None 74 | Accept pipeline input: False 75 | Accept wildcard characters: False 76 | ``` 77 | 78 | ### -Password 79 | {{ Fill Password Description }} 80 | 81 | ```yaml 82 | Type: String 83 | Parameter Sets: ClearText 84 | Aliases: 85 | 86 | Required: True 87 | Position: Named 88 | Default value: None 89 | Accept pipeline input: False 90 | Accept wildcard characters: False 91 | ``` 92 | 93 | ### -Port 94 | {{ Fill Port Description }} 95 | 96 | ```yaml 97 | Type: Int32 98 | Parameter Sets: (All) 99 | Aliases: 100 | 101 | Required: False 102 | Position: Named 103 | Default value: None 104 | Accept pipeline input: False 105 | Accept wildcard characters: False 106 | ``` 107 | 108 | ### -Server 109 | {{ Fill Server Description }} 110 | 111 | ```yaml 112 | Type: String 113 | Parameter Sets: (All) 114 | Aliases: 115 | 116 | Required: False 117 | Position: Named 118 | Default value: None 119 | Accept pipeline input: False 120 | Accept wildcard characters: False 121 | ``` 122 | 123 | ### -TimeOut 124 | {{ Fill TimeOut Description }} 125 | 126 | ```yaml 127 | Type: Int32 128 | Parameter Sets: (All) 129 | Aliases: 130 | 131 | Required: False 132 | Position: Named 133 | Default value: None 134 | Accept pipeline input: False 135 | Accept wildcard characters: False 136 | ``` 137 | 138 | ### -UserName 139 | {{ Fill UserName Description }} 140 | 141 | ```yaml 142 | Type: String 143 | Parameter Sets: ClearText 144 | Aliases: 145 | 146 | Required: True 147 | Position: Named 148 | Default value: None 149 | Accept pipeline input: False 150 | Accept wildcard characters: False 151 | ``` 152 | 153 | ### -oAuth2 154 | {{ Fill oAuth2 Description }} 155 | 156 | ```yaml 157 | Type: SwitchParameter 158 | Parameter Sets: oAuth2 159 | Aliases: 160 | 161 | Required: False 162 | Position: Named 163 | Default value: None 164 | Accept pipeline input: False 165 | Accept wildcard characters: False 166 | ``` 167 | 168 | ### CommonParameters 169 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 170 | 171 | ## INPUTS 172 | 173 | ### None 174 | 175 | ## OUTPUTS 176 | 177 | ### System.Object 178 | ## NOTES 179 | 180 | ## RELATED LINKS 181 | -------------------------------------------------------------------------------- /Docs/Connect-POP.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Mailozaurr-help.xml 3 | Module Name: Mailozaurr 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Connect-POP 9 | 10 | ## SYNOPSIS 11 | {{ Fill in the Synopsis }} 12 | 13 | ## SYNTAX 14 | 15 | ### ClearText 16 | ``` 17 | Connect-POP [-Server ] [-Port ] -UserName -Password 18 | [-Options ] [-TimeOut ] [] 19 | ``` 20 | 21 | ### Credential 22 | ``` 23 | Connect-POP [-Server ] [-Port ] [-Credential ] [-Options ] 24 | [-TimeOut ] [] 25 | ``` 26 | 27 | ### oAuth2 28 | ``` 29 | Connect-POP [-Server ] [-Port ] -Credential [-Options ] 30 | [-TimeOut ] [-oAuth2] [] 31 | ``` 32 | 33 | ## DESCRIPTION 34 | {{ Fill in the Description }} 35 | 36 | ## EXAMPLES 37 | 38 | ### Example 1 39 | ```powershell 40 | PS C:\> {{ Add example code here }} 41 | ``` 42 | 43 | {{ Add example description here }} 44 | 45 | ## PARAMETERS 46 | 47 | ### -Credential 48 | {{ Fill Credential Description }} 49 | 50 | ```yaml 51 | Type: PSCredential 52 | Parameter Sets: Credential 53 | Aliases: 54 | 55 | Required: False 56 | Position: Named 57 | Default value: None 58 | Accept pipeline input: False 59 | Accept wildcard characters: False 60 | ``` 61 | 62 | ```yaml 63 | Type: PSCredential 64 | Parameter Sets: oAuth2 65 | Aliases: 66 | 67 | Required: True 68 | Position: Named 69 | Default value: None 70 | Accept pipeline input: False 71 | Accept wildcard characters: False 72 | ``` 73 | 74 | ### -Options 75 | {{ Fill Options Description }} 76 | 77 | ```yaml 78 | Type: SecureSocketOptions 79 | Parameter Sets: (All) 80 | Aliases: 81 | Accepted values: None, Auto, SslOnConnect, StartTls, StartTlsWhenAvailable 82 | 83 | Required: False 84 | Position: Named 85 | Default value: None 86 | Accept pipeline input: False 87 | Accept wildcard characters: False 88 | ``` 89 | 90 | ### -Password 91 | {{ Fill Password Description }} 92 | 93 | ```yaml 94 | Type: String 95 | Parameter Sets: ClearText 96 | Aliases: 97 | 98 | Required: True 99 | Position: Named 100 | Default value: None 101 | Accept pipeline input: False 102 | Accept wildcard characters: False 103 | ``` 104 | 105 | ### -Port 106 | {{ Fill Port Description }} 107 | 108 | ```yaml 109 | Type: Int32 110 | Parameter Sets: (All) 111 | Aliases: 112 | 113 | Required: False 114 | Position: Named 115 | Default value: None 116 | Accept pipeline input: False 117 | Accept wildcard characters: False 118 | ``` 119 | 120 | ### -Server 121 | {{ Fill Server Description }} 122 | 123 | ```yaml 124 | Type: String 125 | Parameter Sets: (All) 126 | Aliases: 127 | 128 | Required: False 129 | Position: Named 130 | Default value: None 131 | Accept pipeline input: False 132 | Accept wildcard characters: False 133 | ``` 134 | 135 | ### -TimeOut 136 | {{ Fill TimeOut Description }} 137 | 138 | ```yaml 139 | Type: Int32 140 | Parameter Sets: (All) 141 | Aliases: 142 | 143 | Required: False 144 | Position: Named 145 | Default value: None 146 | Accept pipeline input: False 147 | Accept wildcard characters: False 148 | ``` 149 | 150 | ### -UserName 151 | {{ Fill UserName Description }} 152 | 153 | ```yaml 154 | Type: String 155 | Parameter Sets: ClearText 156 | Aliases: 157 | 158 | Required: True 159 | Position: Named 160 | Default value: None 161 | Accept pipeline input: False 162 | Accept wildcard characters: False 163 | ``` 164 | 165 | ### -oAuth2 166 | {{ Fill oAuth2 Description }} 167 | 168 | ```yaml 169 | Type: SwitchParameter 170 | Parameter Sets: oAuth2 171 | Aliases: 172 | 173 | Required: False 174 | Position: Named 175 | Default value: None 176 | Accept pipeline input: False 177 | Accept wildcard characters: False 178 | ``` 179 | 180 | ### CommonParameters 181 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 182 | 183 | ## INPUTS 184 | 185 | ### None 186 | 187 | ## OUTPUTS 188 | 189 | ### System.Object 190 | ## NOTES 191 | 192 | ## RELATED LINKS 193 | -------------------------------------------------------------------------------- /Docs/Connect-oAuthGoogle.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Mailozaurr-help.xml 3 | Module Name: Mailozaurr 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Connect-oAuthGoogle 9 | 10 | ## SYNOPSIS 11 | {{ Fill in the Synopsis }} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Connect-oAuthGoogle [-GmailAccount] [-ClientID] [-ClientSecret] 17 | [[-Scope] ] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | {{ Fill in the Description }} 22 | 23 | ## EXAMPLES 24 | 25 | ### Example 1 26 | ```powershell 27 | PS C:\> {{ Add example code here }} 28 | ``` 29 | 30 | {{ Add example description here }} 31 | 32 | ## PARAMETERS 33 | 34 | ### -ClientID 35 | {{ Fill ClientID Description }} 36 | 37 | ```yaml 38 | Type: String 39 | Parameter Sets: (All) 40 | Aliases: 41 | 42 | Required: True 43 | Position: 1 44 | Default value: None 45 | Accept pipeline input: False 46 | Accept wildcard characters: False 47 | ``` 48 | 49 | ### -ClientSecret 50 | {{ Fill ClientSecret Description }} 51 | 52 | ```yaml 53 | Type: String 54 | Parameter Sets: (All) 55 | Aliases: 56 | 57 | Required: True 58 | Position: 2 59 | Default value: None 60 | Accept pipeline input: False 61 | Accept wildcard characters: False 62 | ``` 63 | 64 | ### -GmailAccount 65 | {{ Fill GmailAccount Description }} 66 | 67 | ```yaml 68 | Type: String 69 | Parameter Sets: (All) 70 | Aliases: 71 | 72 | Required: True 73 | Position: 0 74 | Default value: None 75 | Accept pipeline input: False 76 | Accept wildcard characters: False 77 | ``` 78 | 79 | ### -Scope 80 | {{ Fill Scope Description }} 81 | 82 | ```yaml 83 | Type: String[] 84 | Parameter Sets: (All) 85 | Aliases: 86 | Accepted values: https://mail.google.com/ 87 | 88 | Required: False 89 | Position: 3 90 | Default value: None 91 | Accept pipeline input: False 92 | Accept wildcard characters: False 93 | ``` 94 | 95 | ### CommonParameters 96 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 97 | 98 | ## INPUTS 99 | 100 | ### None 101 | 102 | ## OUTPUTS 103 | 104 | ### System.Object 105 | ## NOTES 106 | 107 | ## RELATED LINKS 108 | -------------------------------------------------------------------------------- /Docs/Connect-oAuthO365.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Mailozaurr-help.xml 3 | Module Name: Mailozaurr 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Connect-oAuthO365 9 | 10 | ## SYNOPSIS 11 | {{ Fill in the Synopsis }} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Connect-oAuthO365 [[-Login] ] [-ClientID] [-TenantID] [[-RedirectUri] ] 17 | [[-Scopes] ] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | {{ Fill in the Description }} 22 | 23 | ## EXAMPLES 24 | 25 | ### Example 1 26 | ```powershell 27 | PS C:\> {{ Add example code here }} 28 | ``` 29 | 30 | {{ Add example description here }} 31 | 32 | ## PARAMETERS 33 | 34 | ### -ClientID 35 | {{ Fill ClientID Description }} 36 | 37 | ```yaml 38 | Type: String 39 | Parameter Sets: (All) 40 | Aliases: 41 | 42 | Required: True 43 | Position: 1 44 | Default value: None 45 | Accept pipeline input: False 46 | Accept wildcard characters: False 47 | ``` 48 | 49 | ### -Login 50 | {{ Fill Login Description }} 51 | 52 | ```yaml 53 | Type: String 54 | Parameter Sets: (All) 55 | Aliases: 56 | 57 | Required: False 58 | Position: 0 59 | Default value: None 60 | Accept pipeline input: False 61 | Accept wildcard characters: False 62 | ``` 63 | 64 | ### -RedirectUri 65 | {{ Fill RedirectUri Description }} 66 | 67 | ```yaml 68 | Type: Uri 69 | Parameter Sets: (All) 70 | Aliases: 71 | 72 | Required: False 73 | Position: 3 74 | Default value: None 75 | Accept pipeline input: False 76 | Accept wildcard characters: False 77 | ``` 78 | 79 | ### -Scopes 80 | {{ Fill Scopes Description }} 81 | 82 | ```yaml 83 | Type: String[] 84 | Parameter Sets: (All) 85 | Aliases: 86 | Accepted values: email, offline_access, https://outlook.office.com/IMAP.AccessAsUser.All, https://outlook.office.com/POP.AccessAsUser.All, https://outlook.office.com/SMTP.Send 87 | 88 | Required: False 89 | Position: 4 90 | Default value: None 91 | Accept pipeline input: False 92 | Accept wildcard characters: False 93 | ``` 94 | 95 | ### -TenantID 96 | {{ Fill TenantID Description }} 97 | 98 | ```yaml 99 | Type: String 100 | Parameter Sets: (All) 101 | Aliases: 102 | 103 | Required: True 104 | Position: 2 105 | Default value: None 106 | Accept pipeline input: False 107 | Accept wildcard characters: False 108 | ``` 109 | 110 | ### CommonParameters 111 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 112 | 113 | ## INPUTS 114 | 115 | ### None 116 | 117 | ## OUTPUTS 118 | 119 | ### System.Object 120 | ## NOTES 121 | 122 | ## RELATED LINKS 123 | -------------------------------------------------------------------------------- /Docs/ConvertTo-GraphCredential.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Mailozaurr-help.xml 3 | Module Name: Mailozaurr 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # ConvertTo-GraphCredential 9 | 10 | ## SYNOPSIS 11 | {{ Fill in the Synopsis }} 12 | 13 | ## SYNTAX 14 | 15 | ### ClearText (Default) 16 | ``` 17 | ConvertTo-GraphCredential -ClientID -ClientSecret -DirectoryID [] 18 | ``` 19 | 20 | ### Encrypted 21 | ``` 22 | ConvertTo-GraphCredential -ClientID -ClientSecretEncrypted -DirectoryID 23 | [] 24 | ``` 25 | 26 | ### MsalToken 27 | ``` 28 | ConvertTo-GraphCredential -MsalToken [] 29 | ``` 30 | 31 | ### MsalTokenEncrypted 32 | ``` 33 | ConvertTo-GraphCredential -MsalTokenEncrypted [] 34 | ``` 35 | 36 | ## DESCRIPTION 37 | {{ Fill in the Description }} 38 | 39 | ## EXAMPLES 40 | 41 | ### Example 1 42 | ```powershell 43 | PS C:\> {{ Add example code here }} 44 | ``` 45 | 46 | {{ Add example description here }} 47 | 48 | ## PARAMETERS 49 | 50 | ### -ClientID 51 | {{ Fill ClientID Description }} 52 | 53 | ```yaml 54 | Type: String 55 | Parameter Sets: ClearText, Encrypted 56 | Aliases: 57 | 58 | Required: True 59 | Position: Named 60 | Default value: None 61 | Accept pipeline input: False 62 | Accept wildcard characters: False 63 | ``` 64 | 65 | ### -ClientSecret 66 | {{ Fill ClientSecret Description }} 67 | 68 | ```yaml 69 | Type: String 70 | Parameter Sets: ClearText 71 | Aliases: 72 | 73 | Required: True 74 | Position: Named 75 | Default value: None 76 | Accept pipeline input: False 77 | Accept wildcard characters: False 78 | ``` 79 | 80 | ### -ClientSecretEncrypted 81 | {{ Fill ClientSecretEncrypted Description }} 82 | 83 | ```yaml 84 | Type: String 85 | Parameter Sets: Encrypted 86 | Aliases: 87 | 88 | Required: True 89 | Position: Named 90 | Default value: None 91 | Accept pipeline input: False 92 | Accept wildcard characters: False 93 | ``` 94 | 95 | ### -DirectoryID 96 | {{ Fill DirectoryID Description }} 97 | 98 | ```yaml 99 | Type: String 100 | Parameter Sets: ClearText, Encrypted 101 | Aliases: 102 | 103 | Required: True 104 | Position: Named 105 | Default value: None 106 | Accept pipeline input: False 107 | Accept wildcard characters: False 108 | ``` 109 | 110 | ### -MsalToken 111 | {{ Fill MsalToken Description }} 112 | 113 | ```yaml 114 | Type: String 115 | Parameter Sets: MsalToken 116 | Aliases: Token 117 | 118 | Required: True 119 | Position: Named 120 | Default value: None 121 | Accept pipeline input: False 122 | Accept wildcard characters: False 123 | ``` 124 | 125 | ### -MsalTokenEncrypted 126 | {{ Fill MsalTokenEncrypted Description }} 127 | 128 | ```yaml 129 | Type: String 130 | Parameter Sets: MsalTokenEncrypted 131 | Aliases: TokenEncrypted 132 | 133 | Required: True 134 | Position: Named 135 | Default value: None 136 | Accept pipeline input: False 137 | Accept wildcard characters: False 138 | ``` 139 | 140 | ### CommonParameters 141 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 142 | 143 | ## INPUTS 144 | 145 | ### None 146 | 147 | ## OUTPUTS 148 | 149 | ### System.Object 150 | ## NOTES 151 | 152 | ## RELATED LINKS 153 | -------------------------------------------------------------------------------- /Docs/ConvertTo-OAuth2Credential.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Mailozaurr-help.xml 3 | Module Name: Mailozaurr 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # ConvertTo-OAuth2Credential 9 | 10 | ## SYNOPSIS 11 | {{ Fill in the Synopsis }} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | ConvertTo-OAuth2Credential [-UserName] [-Token] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | {{ Fill in the Description }} 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> {{ Add example code here }} 27 | ``` 28 | 29 | {{ Add example description here }} 30 | 31 | ## PARAMETERS 32 | 33 | ### -Token 34 | {{ Fill Token Description }} 35 | 36 | ```yaml 37 | Type: String 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: True 42 | Position: 1 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### -UserName 49 | {{ Fill UserName Description }} 50 | 51 | ```yaml 52 | Type: String 53 | Parameter Sets: (All) 54 | Aliases: 55 | 56 | Required: True 57 | Position: 0 58 | Default value: None 59 | Accept pipeline input: False 60 | Accept wildcard characters: False 61 | ``` 62 | 63 | ### CommonParameters 64 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 65 | 66 | ## INPUTS 67 | 68 | ### None 69 | 70 | ## OUTPUTS 71 | 72 | ### System.Object 73 | ## NOTES 74 | 75 | ## RELATED LINKS 76 | -------------------------------------------------------------------------------- /Docs/ConvertTo-SendGridCredential.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Mailozaurr-help.xml 3 | Module Name: Mailozaurr 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # ConvertTo-SendGridCredential 9 | 10 | ## SYNOPSIS 11 | {{ Fill in the Synopsis }} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | ConvertTo-SendGridCredential [-ApiKey] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | {{ Fill in the Description }} 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> {{ Add example code here }} 27 | ``` 28 | 29 | {{ Add example description here }} 30 | 31 | ## PARAMETERS 32 | 33 | ### -ApiKey 34 | {{ Fill ApiKey Description }} 35 | 36 | ```yaml 37 | Type: String 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: True 42 | Position: 0 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### CommonParameters 49 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 50 | 51 | ## INPUTS 52 | 53 | ### None 54 | 55 | ## OUTPUTS 56 | 57 | ### System.Object 58 | ## NOTES 59 | 60 | ## RELATED LINKS 61 | -------------------------------------------------------------------------------- /Docs/Disconnect-IMAP.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Mailozaurr-help.xml 3 | Module Name: Mailozaurr 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Disconnect-IMAP 9 | 10 | ## SYNOPSIS 11 | {{ Fill in the Synopsis }} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Disconnect-IMAP [[-Client] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | {{ Fill in the Description }} 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> {{ Add example code here }} 27 | ``` 28 | 29 | {{ Add example description here }} 30 | 31 | ## PARAMETERS 32 | 33 | ### -Client 34 | {{ Fill Client Description }} 35 | 36 | ```yaml 37 | Type: IDictionary 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: False 42 | Position: 0 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### CommonParameters 49 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 50 | 51 | ## INPUTS 52 | 53 | ### None 54 | 55 | ## OUTPUTS 56 | 57 | ### System.Object 58 | ## NOTES 59 | 60 | ## RELATED LINKS 61 | -------------------------------------------------------------------------------- /Docs/Disconnect-POP.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Mailozaurr-help.xml 3 | Module Name: Mailozaurr 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Disconnect-POP 9 | 10 | ## SYNOPSIS 11 | {{ Fill in the Synopsis }} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Disconnect-POP [[-Client] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | {{ Fill in the Description }} 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> {{ Add example code here }} 27 | ``` 28 | 29 | {{ Add example description here }} 30 | 31 | ## PARAMETERS 32 | 33 | ### -Client 34 | {{ Fill Client Description }} 35 | 36 | ```yaml 37 | Type: IDictionary 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: False 42 | Position: 0 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### CommonParameters 49 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 50 | 51 | ## INPUTS 52 | 53 | ### None 54 | 55 | ## OUTPUTS 56 | 57 | ### System.Object 58 | ## NOTES 59 | 60 | ## RELATED LINKS 61 | -------------------------------------------------------------------------------- /Docs/Find-DKIMRecord.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Mailozaurr-help.xml 3 | Module Name: Mailozaurr 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Find-DKIMRecord 9 | 10 | ## SYNOPSIS 11 | Queries DNS to provide DKIM information 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Find-DKIMRecord [-DomainName] [-Selector ] [-DnsServer ] [-DNSProvider ] 17 | [-AsHashTable] [-AsObject] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | Queries DNS to provide DKIM information 22 | 23 | ## EXAMPLES 24 | 25 | ### EXAMPLE 1 26 | ``` 27 | # Standard way 28 | ``` 29 | 30 | Find-DKIMRecord -DomainName 'evotec.pl', 'evotec.xyz' | Format-Table * 31 | 32 | ### EXAMPLE 2 33 | ``` 34 | # Https way via Cloudflare 35 | ``` 36 | 37 | Find-DKIMRecord -DomainName 'evotec.pl', 'evotec.xyz' -DNSProvider Cloudflare | Format-Table * 38 | 39 | ### EXAMPLE 3 40 | ``` 41 | # Https way via Google 42 | ``` 43 | 44 | Find-DKIMRecord -DomainName 'evotec.pl', 'evotec.xyz' -Selector 'selector1' -DNSProvider Google | Format-Table * 45 | 46 | ## PARAMETERS 47 | 48 | ### -DomainName 49 | Name/DomainName to query for DKIM record 50 | 51 | ```yaml 52 | Type: Array 53 | Parameter Sets: (All) 54 | Aliases: 55 | 56 | Required: True 57 | Position: 1 58 | Default value: None 59 | Accept pipeline input: True (ByPropertyName, ByValue) 60 | Accept wildcard characters: False 61 | ``` 62 | 63 | ### -Selector 64 | Selector name. 65 | Default: selector1 66 | 67 | ```yaml 68 | Type: String 69 | Parameter Sets: (All) 70 | Aliases: 71 | 72 | Required: False 73 | Position: Named 74 | Default value: Selector1 75 | Accept pipeline input: False 76 | Accept wildcard characters: False 77 | ``` 78 | 79 | ### -DnsServer 80 | Allows to choose DNS IP address to ask for DNS query. 81 | By default uses system ones. 82 | 83 | ```yaml 84 | Type: String 85 | Parameter Sets: (All) 86 | Aliases: 87 | 88 | Required: False 89 | Position: Named 90 | Default value: None 91 | Accept pipeline input: False 92 | Accept wildcard characters: False 93 | ``` 94 | 95 | ### -DNSProvider 96 | Allows to choose DNS Provider that will be used for HTTPS based DNS query (Cloudlare or Google) 97 | 98 | ```yaml 99 | Type: String 100 | Parameter Sets: (All) 101 | Aliases: 102 | 103 | Required: False 104 | Position: Named 105 | Default value: None 106 | Accept pipeline input: False 107 | Accept wildcard characters: False 108 | ``` 109 | 110 | ### -AsHashTable 111 | Returns Hashtable instead of PSCustomObject 112 | 113 | ```yaml 114 | Type: SwitchParameter 115 | Parameter Sets: (All) 116 | Aliases: 117 | 118 | Required: False 119 | Position: Named 120 | Default value: False 121 | Accept pipeline input: False 122 | Accept wildcard characters: False 123 | ``` 124 | 125 | ### -AsObject 126 | Returns an object rather than string based represantation for name servers (for easier display purposes) 127 | 128 | ```yaml 129 | Type: SwitchParameter 130 | Parameter Sets: (All) 131 | Aliases: 132 | 133 | Required: False 134 | Position: Named 135 | Default value: False 136 | Accept pipeline input: False 137 | Accept wildcard characters: False 138 | ``` 139 | 140 | ### CommonParameters 141 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 142 | 143 | ## INPUTS 144 | 145 | ## OUTPUTS 146 | 147 | ## NOTES 148 | General notes 149 | 150 | ## RELATED LINKS 151 | -------------------------------------------------------------------------------- /Docs/Find-DMARCRecord.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Mailozaurr-help.xml 3 | Module Name: Mailozaurr 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Find-DMARCRecord 9 | 10 | ## SYNOPSIS 11 | Queries DNS to provide DMARC information 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Find-DMARCRecord [-DomainName] [-DnsServer ] [-DNSProvider ] [-AsHashTable] [-AsObject] 17 | [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | Queries DNS to provide DMARC information 22 | 23 | ## EXAMPLES 24 | 25 | ### EXAMPLE 1 26 | ``` 27 | # Standard way 28 | ``` 29 | 30 | Find-DMARCRecord -DomainName 'evotec.pl', 'evotec.xyz' | Format-Table * 31 | 32 | ### EXAMPLE 2 33 | ``` 34 | # Https way via Cloudflare 35 | ``` 36 | 37 | Find-DMARCRecord -DomainName 'evotec.pl', 'evotec.xyz' -DNSProvider Cloudflare | Format-Table * 38 | 39 | ### EXAMPLE 3 40 | ``` 41 | # Https way via Google 42 | ``` 43 | 44 | Find-DMARCRecord -DomainName 'evotec.pl', 'evotec.xyz' -DNSProvider Google | Format-Table * 45 | 46 | ## PARAMETERS 47 | 48 | ### -DomainName 49 | Name/DomainName to query for DMARC record 50 | 51 | ```yaml 52 | Type: Array 53 | Parameter Sets: (All) 54 | Aliases: 55 | 56 | Required: True 57 | Position: 1 58 | Default value: None 59 | Accept pipeline input: True (ByPropertyName, ByValue) 60 | Accept wildcard characters: False 61 | ``` 62 | 63 | ### -DnsServer 64 | Allows to choose DNS IP address to ask for DNS query. 65 | By default uses system ones. 66 | 67 | ```yaml 68 | Type: String 69 | Parameter Sets: (All) 70 | Aliases: 71 | 72 | Required: False 73 | Position: Named 74 | Default value: None 75 | Accept pipeline input: False 76 | Accept wildcard characters: False 77 | ``` 78 | 79 | ### -DNSProvider 80 | Allows to choose DNS Provider that will be used for HTTPS based DNS query (Cloudlare or Google) 81 | 82 | ```yaml 83 | Type: String 84 | Parameter Sets: (All) 85 | Aliases: 86 | 87 | Required: False 88 | Position: Named 89 | Default value: None 90 | Accept pipeline input: False 91 | Accept wildcard characters: False 92 | ``` 93 | 94 | ### -AsHashTable 95 | Returns Hashtable instead of PSCustomObject 96 | 97 | ```yaml 98 | Type: SwitchParameter 99 | Parameter Sets: (All) 100 | Aliases: 101 | 102 | Required: False 103 | Position: Named 104 | Default value: False 105 | Accept pipeline input: False 106 | Accept wildcard characters: False 107 | ``` 108 | 109 | ### -AsObject 110 | Returns an object rather than string based represantation for name servers (for easier display purposes) 111 | 112 | ```yaml 113 | Type: SwitchParameter 114 | Parameter Sets: (All) 115 | Aliases: 116 | 117 | Required: False 118 | Position: Named 119 | Default value: False 120 | Accept pipeline input: False 121 | Accept wildcard characters: False 122 | ``` 123 | 124 | ### CommonParameters 125 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 126 | 127 | ## INPUTS 128 | 129 | ## OUTPUTS 130 | 131 | ## NOTES 132 | General notes 133 | 134 | ## RELATED LINKS 135 | -------------------------------------------------------------------------------- /Docs/Find-DNSBL.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Mailozaurr-help.xml 3 | Module Name: Mailozaurr 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Find-DNSBL 9 | 10 | ## SYNOPSIS 11 | Searches DNSBL if particular IP is blocked on DNSBL. 12 | 13 | ## SYNTAX 14 | 15 | ### Default (Default) 16 | ``` 17 | Find-DNSBL -IP [-BlockListServers ] [-All] [] 18 | ``` 19 | 20 | ### DNSServer 21 | ``` 22 | Find-DNSBL -IP [-BlockListServers ] [-All] [-DNSServer ] [] 23 | ``` 24 | 25 | ### DNSProvider 26 | ``` 27 | Find-DNSBL -IP [-BlockListServers ] [-All] [-DNSProvider ] [] 28 | ``` 29 | 30 | ## DESCRIPTION 31 | Searches DNSBL if particular IP is blocked on DNSBL. 32 | 33 | ## EXAMPLES 34 | 35 | ### EXAMPLE 1 36 | ``` 37 | Find-DNSBL -IP '89.74.48.96' | Format-Table 38 | ``` 39 | 40 | ### EXAMPLE 2 41 | ``` 42 | Find-DNSBL -IP '89.74.48.96', '89.74.48.97', '89.74.48.98' | Format-Table 43 | ``` 44 | 45 | ### EXAMPLE 3 46 | ``` 47 | Find-DNSBL -IP '89.74.48.96' -DNSServer 1.1.1.1 | Format-Table 48 | ``` 49 | 50 | ### EXAMPLE 4 51 | ``` 52 | Find-DNSBL -IP '89.74.48.96' -DNSProvider Cloudflare | Format-Table 53 | ``` 54 | 55 | ## PARAMETERS 56 | 57 | ### -IP 58 | IP to check if it exists on DNSBL 59 | 60 | ```yaml 61 | Type: String[] 62 | Parameter Sets: (All) 63 | Aliases: 64 | 65 | Required: True 66 | Position: Named 67 | Default value: None 68 | Accept pipeline input: False 69 | Accept wildcard characters: False 70 | ``` 71 | 72 | ### -BlockListServers 73 | Provide your own blocklist of servers 74 | 75 | ```yaml 76 | Type: String[] 77 | Parameter Sets: (All) 78 | Aliases: 79 | 80 | Required: False 81 | Position: Named 82 | Default value: $Script:BlockList 83 | Accept pipeline input: False 84 | Accept wildcard characters: False 85 | ``` 86 | 87 | ### -All 88 | Return All entries. 89 | By default it returns only those on DNSBL. 90 | 91 | ```yaml 92 | Type: SwitchParameter 93 | Parameter Sets: (All) 94 | Aliases: 95 | 96 | Required: False 97 | Position: Named 98 | Default value: False 99 | Accept pipeline input: False 100 | Accept wildcard characters: False 101 | ``` 102 | 103 | ### -DNSServer 104 | Allows to choose DNS IP address to ask for DNS query. 105 | By default uses system ones. 106 | 107 | ```yaml 108 | Type: String 109 | Parameter Sets: DNSServer 110 | Aliases: 111 | 112 | Required: False 113 | Position: Named 114 | Default value: None 115 | Accept pipeline input: False 116 | Accept wildcard characters: False 117 | ``` 118 | 119 | ### -DNSProvider 120 | Allows to choose DNS Provider that will be used for HTTPS based DNS query (Cloudlare or Google) 121 | 122 | ```yaml 123 | Type: String 124 | Parameter Sets: DNSProvider 125 | Aliases: 126 | 127 | Required: False 128 | Position: Named 129 | Default value: None 130 | Accept pipeline input: False 131 | Accept wildcard characters: False 132 | ``` 133 | 134 | ### CommonParameters 135 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 136 | 137 | ## INPUTS 138 | 139 | ## OUTPUTS 140 | 141 | ## NOTES 142 | General notes 143 | 144 | ## RELATED LINKS 145 | -------------------------------------------------------------------------------- /Docs/Find-MxRecord.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Mailozaurr-help.xml 3 | Module Name: Mailozaurr 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Find-MxRecord 9 | 10 | ## SYNOPSIS 11 | Queries DNS to provide MX information 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Find-MxRecord [-DomainName] [-DnsServer ] [-DNSProvider ] [-ResolvePTR] [-AsHashTable] 17 | [-Separate] [-AsObject] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | Queries DNS to provide MX information 22 | 23 | ## EXAMPLES 24 | 25 | ### EXAMPLE 1 26 | ``` 27 | # Standard way 28 | ``` 29 | 30 | Find-MxRecord -DomainName 'evotec.pl', 'evotec.xyz' | Format-Table * 31 | 32 | ### EXAMPLE 2 33 | ``` 34 | # Https way via Cloudflare 35 | ``` 36 | 37 | Find-MxRecord -DomainName 'evotec.pl', 'evotec.xyz' -DNSProvider Cloudflare | Format-Table * 38 | 39 | ### EXAMPLE 3 40 | ``` 41 | # Https way via Google 42 | ``` 43 | 44 | Find-MxRecord -DomainName 'evotec.pl', 'evotec.xyz' -DNSProvider Google | Format-Table * 45 | 46 | ### EXAMPLE 4 47 | ``` 48 | # Standard way with ResolvePTR 49 | ``` 50 | 51 | Find-MxRecord -DomainName 'evotec.pl', 'evotec.xyz' -ResolvePTR | Format-Table * 52 | 53 | ### EXAMPLE 5 54 | ``` 55 | # Https way via Cloudflare with ResolvePTR 56 | ``` 57 | 58 | Find-MxRecord -DomainName 'evotec.pl', 'evotec.xyz' -DNSProvider Cloudflare -ResolvePTR | Format-Table * 59 | 60 | ### EXAMPLE 6 61 | ``` 62 | # Https way via Google with ResolvePTR 63 | ``` 64 | 65 | Find-MxRecord -DomainName 'evotec.pl', 'evotec.xyz' -DNSProvider Google -ResolvePTR | Format-Table * 66 | 67 | ## PARAMETERS 68 | 69 | ### -DomainName 70 | Name/DomainName to query for MX record 71 | 72 | ```yaml 73 | Type: Array 74 | Parameter Sets: (All) 75 | Aliases: 76 | 77 | Required: True 78 | Position: 1 79 | Default value: None 80 | Accept pipeline input: True (ByPropertyName, ByValue) 81 | Accept wildcard characters: False 82 | ``` 83 | 84 | ### -DnsServer 85 | Allows to choose DNS IP address to ask for DNS query. 86 | By default uses system ones. 87 | 88 | ```yaml 89 | Type: String 90 | Parameter Sets: (All) 91 | Aliases: 92 | 93 | Required: False 94 | Position: Named 95 | Default value: None 96 | Accept pipeline input: False 97 | Accept wildcard characters: False 98 | ``` 99 | 100 | ### -DNSProvider 101 | Allows to choose DNS Provider that will be used for HTTPS based DNS query (Cloudlare or Google) 102 | 103 | ```yaml 104 | Type: String 105 | Parameter Sets: (All) 106 | Aliases: 107 | 108 | Required: False 109 | Position: Named 110 | Default value: None 111 | Accept pipeline input: False 112 | Accept wildcard characters: False 113 | ``` 114 | 115 | ### -ResolvePTR 116 | Parameter description 117 | 118 | ```yaml 119 | Type: SwitchParameter 120 | Parameter Sets: (All) 121 | Aliases: 122 | 123 | Required: False 124 | Position: Named 125 | Default value: False 126 | Accept pipeline input: False 127 | Accept wildcard characters: False 128 | ``` 129 | 130 | ### -AsHashTable 131 | Returns Hashtable instead of PSCustomObject 132 | 133 | ```yaml 134 | Type: SwitchParameter 135 | Parameter Sets: (All) 136 | Aliases: 137 | 138 | Required: False 139 | Position: Named 140 | Default value: False 141 | Accept pipeline input: False 142 | Accept wildcard characters: False 143 | ``` 144 | 145 | ### -Separate 146 | Returns each MX record separatly 147 | 148 | ```yaml 149 | Type: SwitchParameter 150 | Parameter Sets: (All) 151 | Aliases: 152 | 153 | Required: False 154 | Position: Named 155 | Default value: False 156 | Accept pipeline input: False 157 | Accept wildcard characters: False 158 | ``` 159 | 160 | ### -AsObject 161 | Returns an object rather than string based represantation for name servers (for easier display purposes) 162 | 163 | ```yaml 164 | Type: SwitchParameter 165 | Parameter Sets: (All) 166 | Aliases: 167 | 168 | Required: False 169 | Position: Named 170 | Default value: False 171 | Accept pipeline input: False 172 | Accept wildcard characters: False 173 | ``` 174 | 175 | ### CommonParameters 176 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 177 | 178 | ## INPUTS 179 | 180 | ## OUTPUTS 181 | 182 | ## NOTES 183 | General notes 184 | 185 | ## RELATED LINKS 186 | -------------------------------------------------------------------------------- /Docs/Find-SPFRecord.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Mailozaurr-help.xml 3 | Module Name: Mailozaurr 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Find-SPFRecord 9 | 10 | ## SYNOPSIS 11 | Queries DNS to provide SPF information 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Find-SPFRecord [-DomainName] [-DnsServer ] [-DNSProvider ] [-AsHashTable] [-AsObject] 17 | [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | Queries DNS to provide SPF information 22 | 23 | ## EXAMPLES 24 | 25 | ### EXAMPLE 1 26 | ``` 27 | # Standard way 28 | ``` 29 | 30 | Find-SPFRecord -DomainName 'evotec.pl', 'evotec.xyz' | Format-Table * 31 | 32 | ### EXAMPLE 2 33 | ``` 34 | # Https way via Cloudflare 35 | ``` 36 | 37 | Find-SPFRecord -DomainName 'evotec.pl', 'evotec.xyz' -DNSProvider Cloudflare | Format-Table * 38 | 39 | ### EXAMPLE 3 40 | ``` 41 | # Https way via Google 42 | ``` 43 | 44 | Find-SPFRecord -DomainName 'evotec.pl', 'evotec.xyz' -DNSProvider Google | Format-Table * 45 | 46 | ## PARAMETERS 47 | 48 | ### -DomainName 49 | Name/DomainName to query for SPF record 50 | 51 | ```yaml 52 | Type: Array 53 | Parameter Sets: (All) 54 | Aliases: 55 | 56 | Required: True 57 | Position: 1 58 | Default value: None 59 | Accept pipeline input: True (ByPropertyName, ByValue) 60 | Accept wildcard characters: False 61 | ``` 62 | 63 | ### -DnsServer 64 | Allows to choose DNS IP address to ask for DNS query. 65 | By default uses system ones. 66 | 67 | ```yaml 68 | Type: String 69 | Parameter Sets: (All) 70 | Aliases: 71 | 72 | Required: False 73 | Position: Named 74 | Default value: None 75 | Accept pipeline input: False 76 | Accept wildcard characters: False 77 | ``` 78 | 79 | ### -DNSProvider 80 | Allows to choose DNS Provider that will be used for HTTPS based DNS query (Cloudlare or Google) 81 | 82 | ```yaml 83 | Type: String 84 | Parameter Sets: (All) 85 | Aliases: 86 | 87 | Required: False 88 | Position: Named 89 | Default value: None 90 | Accept pipeline input: False 91 | Accept wildcard characters: False 92 | ``` 93 | 94 | ### -AsHashTable 95 | Returns Hashtable instead of PSCustomObject 96 | 97 | ```yaml 98 | Type: SwitchParameter 99 | Parameter Sets: (All) 100 | Aliases: 101 | 102 | Required: False 103 | Position: Named 104 | Default value: False 105 | Accept pipeline input: False 106 | Accept wildcard characters: False 107 | ``` 108 | 109 | ### -AsObject 110 | Returns an object rather than string based represantation for name servers (for easier display purposes) 111 | 112 | ```yaml 113 | Type: SwitchParameter 114 | Parameter Sets: (All) 115 | Aliases: 116 | 117 | Required: False 118 | Position: Named 119 | Default value: False 120 | Accept pipeline input: False 121 | Accept wildcard characters: False 122 | ``` 123 | 124 | ### CommonParameters 125 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 126 | 127 | ## INPUTS 128 | 129 | ## OUTPUTS 130 | 131 | ## NOTES 132 | General notes 133 | 134 | ## RELATED LINKS 135 | -------------------------------------------------------------------------------- /Docs/Get-IMAPFolder.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Mailozaurr-help.xml 3 | Module Name: Mailozaurr 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-IMAPFolder 9 | 10 | ## SYNOPSIS 11 | {{ Fill in the Synopsis }} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-IMAPFolder [[-Client] ] [[-FolderAccess] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | {{ Fill in the Description }} 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> {{ Add example code here }} 27 | ``` 28 | 29 | {{ Add example description here }} 30 | 31 | ## PARAMETERS 32 | 33 | ### -Client 34 | {{ Fill Client Description }} 35 | 36 | ```yaml 37 | Type: IDictionary 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: False 42 | Position: 0 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### -FolderAccess 49 | {{ Fill FolderAccess Description }} 50 | 51 | ```yaml 52 | Type: FolderAccess 53 | Parameter Sets: (All) 54 | Aliases: 55 | Accepted values: None, ReadOnly, ReadWrite 56 | 57 | Required: False 58 | Position: 1 59 | Default value: None 60 | Accept pipeline input: False 61 | Accept wildcard characters: False 62 | ``` 63 | 64 | ### CommonParameters 65 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 66 | 67 | ## INPUTS 68 | 69 | ### None 70 | 71 | ## OUTPUTS 72 | 73 | ### System.Object 74 | ## NOTES 75 | 76 | ## RELATED LINKS 77 | -------------------------------------------------------------------------------- /Docs/Get-IMAPMessage.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Mailozaurr-help.xml 3 | Module Name: Mailozaurr 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-IMAPMessage 9 | 10 | ## SYNOPSIS 11 | {{ Fill in the Synopsis }} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-IMAPMessage [[-Client] ] [[-FolderAccess] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | {{ Fill in the Description }} 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> {{ Add example code here }} 27 | ``` 28 | 29 | {{ Add example description here }} 30 | 31 | ## PARAMETERS 32 | 33 | ### -Client 34 | {{ Fill Client Description }} 35 | 36 | ```yaml 37 | Type: IDictionary 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: False 42 | Position: 0 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### -FolderAccess 49 | {{ Fill FolderAccess Description }} 50 | 51 | ```yaml 52 | Type: FolderAccess 53 | Parameter Sets: (All) 54 | Aliases: 55 | Accepted values: None, ReadOnly, ReadWrite 56 | 57 | Required: False 58 | Position: 1 59 | Default value: None 60 | Accept pipeline input: False 61 | Accept wildcard characters: False 62 | ``` 63 | 64 | ### CommonParameters 65 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 66 | 67 | ## INPUTS 68 | 69 | ### None 70 | 71 | ## OUTPUTS 72 | 73 | ### System.Object 74 | ## NOTES 75 | 76 | ## RELATED LINKS 77 | -------------------------------------------------------------------------------- /Docs/Get-MailFolder.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Mailozaurr-help.xml 3 | Module Name: Mailozaurr 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-MailFolder 9 | 10 | ## SYNOPSIS 11 | {{ Fill in the Synopsis }} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-MailFolder [[-UserPrincipalName] ] [[-Credential] ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | {{ Fill in the Description }} 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> {{ Add example code here }} 27 | ``` 28 | 29 | {{ Add example description here }} 30 | 31 | ## PARAMETERS 32 | 33 | ### -Credential 34 | {{ Fill Credential Description }} 35 | 36 | ```yaml 37 | Type: PSCredential 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: False 42 | Position: 1 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### -UserPrincipalName 49 | {{ Fill UserPrincipalName Description }} 50 | 51 | ```yaml 52 | Type: String 53 | Parameter Sets: (All) 54 | Aliases: 55 | 56 | Required: False 57 | Position: 0 58 | Default value: None 59 | Accept pipeline input: False 60 | Accept wildcard characters: False 61 | ``` 62 | 63 | ### CommonParameters 64 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 65 | 66 | ## INPUTS 67 | 68 | ### None 69 | 70 | ## OUTPUTS 71 | 72 | ### System.Object 73 | ## NOTES 74 | 75 | ## RELATED LINKS 76 | -------------------------------------------------------------------------------- /Docs/Get-MailMessage.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Mailozaurr-help.xml 3 | Module Name: Mailozaurr 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-MailMessage 9 | 10 | ## SYNOPSIS 11 | {{ Fill in the Synopsis }} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-MailMessage [[-UserPrincipalName] ] [[-Credential] ] [-All] [[-Limit] ] 17 | [[-Property] ] [[-Filter] ] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | {{ Fill in the Description }} 22 | 23 | ## EXAMPLES 24 | 25 | ### Example 1 26 | ```powershell 27 | PS C:\> {{ Add example code here }} 28 | ``` 29 | 30 | {{ Add example description here }} 31 | 32 | ## PARAMETERS 33 | 34 | ### -All 35 | {{ Fill All Description }} 36 | 37 | ```yaml 38 | Type: SwitchParameter 39 | Parameter Sets: (All) 40 | Aliases: 41 | 42 | Required: False 43 | Position: Named 44 | Default value: None 45 | Accept pipeline input: False 46 | Accept wildcard characters: False 47 | ``` 48 | 49 | ### -Credential 50 | {{ Fill Credential Description }} 51 | 52 | ```yaml 53 | Type: PSCredential 54 | Parameter Sets: (All) 55 | Aliases: 56 | 57 | Required: False 58 | Position: 1 59 | Default value: None 60 | Accept pipeline input: False 61 | Accept wildcard characters: False 62 | ``` 63 | 64 | ### -Filter 65 | {{ Fill Filter Description }} 66 | 67 | ```yaml 68 | Type: String 69 | Parameter Sets: (All) 70 | Aliases: 71 | 72 | Required: False 73 | Position: 4 74 | Default value: None 75 | Accept pipeline input: False 76 | Accept wildcard characters: False 77 | ``` 78 | 79 | ### -Limit 80 | {{ Fill Limit Description }} 81 | 82 | ```yaml 83 | Type: Int32 84 | Parameter Sets: (All) 85 | Aliases: 86 | 87 | Required: False 88 | Position: 2 89 | Default value: None 90 | Accept pipeline input: False 91 | Accept wildcard characters: False 92 | ``` 93 | 94 | ### -Property 95 | {{ Fill Property Description }} 96 | 97 | ```yaml 98 | Type: String[] 99 | Parameter Sets: (All) 100 | Aliases: 101 | Accepted values: createdDateTime, lastModifiedDateTime, changeKey, categories, receivedDateTime, sentDateTime, hasAttachments, internetMessageId, subject, bodyPreview, importance, parentFolderId, conversationId, conversationIndex, isDeliveryReceiptRequested, isReadReceiptRequested, isRead, isDraft, webLink, inferenceClassification, body, sender, from, toRecipients, ccRecipients, bccRecipients, replyTo, flag 102 | 103 | Required: False 104 | Position: 3 105 | Default value: None 106 | Accept pipeline input: False 107 | Accept wildcard characters: False 108 | ``` 109 | 110 | ### -UserPrincipalName 111 | {{ Fill UserPrincipalName Description }} 112 | 113 | ```yaml 114 | Type: String 115 | Parameter Sets: (All) 116 | Aliases: 117 | 118 | Required: False 119 | Position: 0 120 | Default value: None 121 | Accept pipeline input: False 122 | Accept wildcard characters: False 123 | ``` 124 | 125 | ### CommonParameters 126 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 127 | 128 | ## INPUTS 129 | 130 | ### None 131 | 132 | ## OUTPUTS 133 | 134 | ### System.Object 135 | ## NOTES 136 | 137 | ## RELATED LINKS 138 | -------------------------------------------------------------------------------- /Docs/Get-POPMessage.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Mailozaurr-help.xml 3 | Module Name: Mailozaurr 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-POPMessage 9 | 10 | ## SYNOPSIS 11 | {{ Fill in the Synopsis }} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-POPMessage [[-Client] ] [[-Index] ] [[-Count] ] [-All] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | {{ Fill in the Description }} 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> {{ Add example code here }} 27 | ``` 28 | 29 | {{ Add example description here }} 30 | 31 | ## PARAMETERS 32 | 33 | ### -All 34 | {{ Fill All Description }} 35 | 36 | ```yaml 37 | Type: SwitchParameter 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: False 42 | Position: Named 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### -Client 49 | {{ Fill Client Description }} 50 | 51 | ```yaml 52 | Type: IDictionary 53 | Parameter Sets: (All) 54 | Aliases: 55 | 56 | Required: False 57 | Position: 0 58 | Default value: None 59 | Accept pipeline input: False 60 | Accept wildcard characters: False 61 | ``` 62 | 63 | ### -Count 64 | {{ Fill Count Description }} 65 | 66 | ```yaml 67 | Type: Int32 68 | Parameter Sets: (All) 69 | Aliases: 70 | 71 | Required: False 72 | Position: 2 73 | Default value: None 74 | Accept pipeline input: False 75 | Accept wildcard characters: False 76 | ``` 77 | 78 | ### -Index 79 | {{ Fill Index Description }} 80 | 81 | ```yaml 82 | Type: Int32 83 | Parameter Sets: (All) 84 | Aliases: 85 | 86 | Required: False 87 | Position: 1 88 | Default value: None 89 | Accept pipeline input: False 90 | Accept wildcard characters: False 91 | ``` 92 | 93 | ### CommonParameters 94 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 95 | 96 | ## INPUTS 97 | 98 | ### None 99 | 100 | ## OUTPUTS 101 | 102 | ### System.Object 103 | ## NOTES 104 | 105 | ## RELATED LINKS 106 | -------------------------------------------------------------------------------- /Docs/Images/MicrosoftGraphPermissions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EvotecIT/Mailozaurr/b529233bac1f9ef5c2465a78969cb35bb06cd5b1/Docs/Images/MicrosoftGraphPermissions.png -------------------------------------------------------------------------------- /Docs/Readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | Module Name: Mailozaurr 3 | Module Guid: 2b0ea9f1-3ff1-4300-b939-106d5da608fa 4 | Download Help Link: {{ Update Download Link }} 5 | Help Version: {{ Please enter version of help manually (X.X.X.X) format }} 6 | Locale: en-US 7 | --- 8 | 9 | # Mailozaurr Module 10 | ## Description 11 | {{ Fill in the Description }} 12 | 13 | ## Mailozaurr Cmdlets 14 | ### [Connect-IMAP](Connect-IMAP.md) 15 | {{ Fill in the Description }} 16 | 17 | ### [Connect-oAuthGoogle](Connect-oAuthGoogle.md) 18 | {{ Fill in the Description }} 19 | 20 | ### [Connect-oAuthO365](Connect-oAuthO365.md) 21 | {{ Fill in the Description }} 22 | 23 | ### [Connect-POP](Connect-POP.md) 24 | {{ Fill in the Description }} 25 | 26 | ### [ConvertTo-GraphCredential](ConvertTo-GraphCredential.md) 27 | {{ Fill in the Description }} 28 | 29 | ### [ConvertTo-OAuth2Credential](ConvertTo-OAuth2Credential.md) 30 | {{ Fill in the Description }} 31 | 32 | ### [ConvertTo-SendGridCredential](ConvertTo-SendGridCredential.md) 33 | {{ Fill in the Description }} 34 | 35 | ### [Disconnect-IMAP](Disconnect-IMAP.md) 36 | {{ Fill in the Description }} 37 | 38 | ### [Disconnect-POP](Disconnect-POP.md) 39 | {{ Fill in the Description }} 40 | 41 | ### [Find-DKIMRecord](Find-DKIMRecord.md) 42 | {{ Fill in the Description }} 43 | 44 | ### [Find-DMARCRecord](Find-DMARCRecord.md) 45 | {{ Fill in the Description }} 46 | 47 | ### [Find-DNSBL](Find-DNSBL.md) 48 | {{ Fill in the Description }} 49 | 50 | ### [Find-MxRecord](Find-MxRecord.md) 51 | {{ Fill in the Description }} 52 | 53 | ### [Find-SPFRecord](Find-SPFRecord.md) 54 | {{ Fill in the Description }} 55 | 56 | ### [Get-IMAPFolder](Get-IMAPFolder.md) 57 | {{ Fill in the Description }} 58 | 59 | ### [Get-IMAPMessage](Get-IMAPMessage.md) 60 | {{ Fill in the Description }} 61 | 62 | ### [Get-MailFolder](Get-MailFolder.md) 63 | {{ Fill in the Description }} 64 | 65 | ### [Get-MailMessage](Get-MailMessage.md) 66 | {{ Fill in the Description }} 67 | 68 | ### [Get-POPMessage](Get-POPMessage.md) 69 | {{ Fill in the Description }} 70 | 71 | ### [Resolve-DnsQuery](Resolve-DnsQuery.md) 72 | {{ Fill in the Description }} 73 | 74 | ### [Resolve-DnsQueryRest](Resolve-DnsQueryRest.md) 75 | {{ Fill in the Description }} 76 | 77 | ### [Save-MailMessage](Save-MailMessage.md) 78 | {{ Fill in the Description }} 79 | 80 | ### [Save-POPMessage](Save-POPMessage.md) 81 | {{ Fill in the Description }} 82 | 83 | ### [Send-EmailMessage](Send-EmailMessage.md) 84 | {{ Fill in the Description }} 85 | 86 | ### [Test-EmailAddress](Test-EmailAddress.md) 87 | {{ Fill in the Description }} 88 | 89 | -------------------------------------------------------------------------------- /Docs/Resolve-DnsQuery.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Mailozaurr-help.xml 3 | Module Name: Mailozaurr 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Resolve-DnsQuery 9 | 10 | ## SYNOPSIS 11 | {{ Fill in the Synopsis }} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Resolve-DnsQuery [-Name] [-Type] [[-Server] ] [-All] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | {{ Fill in the Description }} 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> {{ Add example code here }} 27 | ``` 28 | 29 | {{ Add example description here }} 30 | 31 | ## PARAMETERS 32 | 33 | ### -All 34 | {{ Fill All Description }} 35 | 36 | ```yaml 37 | Type: SwitchParameter 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: False 42 | Position: Named 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### -Name 49 | {{ Fill Name Description }} 50 | 51 | ```yaml 52 | Type: String 53 | Parameter Sets: (All) 54 | Aliases: Query 55 | 56 | Required: True 57 | Position: 0 58 | Default value: None 59 | Accept pipeline input: False 60 | Accept wildcard characters: False 61 | ``` 62 | 63 | ### -Server 64 | {{ Fill Server Description }} 65 | 66 | ```yaml 67 | Type: String 68 | Parameter Sets: (All) 69 | Aliases: 70 | 71 | Required: False 72 | Position: 2 73 | Default value: None 74 | Accept pipeline input: False 75 | Accept wildcard characters: False 76 | ``` 77 | 78 | ### -Type 79 | {{ Fill Type Description }} 80 | 81 | ```yaml 82 | Type: QueryType 83 | Parameter Sets: (All) 84 | Aliases: 85 | Accepted values: A, NS, MD, MF, CNAME, SOA, MB, MG, MR, NULL, WKS, PTR, HINFO, MINFO, MX, TXT, RP, AFSDB, AAAA, SRV, NAPTR, DS, SSHFP, RRSIG, NSEC, DNSKEY, NSEC3, NSEC3PARAM, TLSA, SPF, AXFR, ANY, URI, CAA 86 | 87 | Required: True 88 | Position: 1 89 | Default value: None 90 | Accept pipeline input: False 91 | Accept wildcard characters: False 92 | ``` 93 | 94 | ### CommonParameters 95 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 96 | 97 | ## INPUTS 98 | 99 | ### None 100 | 101 | ## OUTPUTS 102 | 103 | ### System.Object 104 | ## NOTES 105 | 106 | ## RELATED LINKS 107 | -------------------------------------------------------------------------------- /Docs/Resolve-DnsQueryRest.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Mailozaurr-help.xml 3 | Module Name: Mailozaurr 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Resolve-DnsQueryRest 9 | 10 | ## SYNOPSIS 11 | Provides basic DNS Query via HTTPS 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Resolve-DnsQueryRest [-Name] [-Type] [-DNSProvider ] [-All] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Provides basic DNS Query via HTTPS - tested only for use cases within Mailozaurr 21 | 22 | ## EXAMPLES 23 | 24 | ### EXAMPLE 1 25 | ``` 26 | Resolve-DnsQueryRest -Name 'evotec.pl' -Type TXT -DNSProvider Cloudflare 27 | ``` 28 | 29 | ## PARAMETERS 30 | 31 | ### -Name 32 | Name/DomainName to query DNS 33 | 34 | ```yaml 35 | Type: String 36 | Parameter Sets: (All) 37 | Aliases: Query 38 | 39 | Required: True 40 | Position: 1 41 | Default value: None 42 | Accept pipeline input: False 43 | Accept wildcard characters: False 44 | ``` 45 | 46 | ### -Type 47 | Type of a query A, PTR, MX and so on 48 | 49 | ```yaml 50 | Type: String 51 | Parameter Sets: (All) 52 | Aliases: 53 | 54 | Required: True 55 | Position: 2 56 | Default value: None 57 | Accept pipeline input: False 58 | Accept wildcard characters: False 59 | ``` 60 | 61 | ### -DNSProvider 62 | Allows to choose DNS Provider that will be used for HTTPS based DNS query (Cloudlare or Google). 63 | Default is Cloudflare 64 | 65 | ```yaml 66 | Type: String 67 | Parameter Sets: (All) 68 | Aliases: 69 | 70 | Required: False 71 | Position: Named 72 | Default value: Cloudflare 73 | Accept pipeline input: False 74 | Accept wildcard characters: False 75 | ``` 76 | 77 | ### -All 78 | Returns full output rather than just custom, translated data 79 | 80 | ```yaml 81 | Type: SwitchParameter 82 | Parameter Sets: (All) 83 | Aliases: 84 | 85 | Required: False 86 | Position: Named 87 | Default value: False 88 | Accept pipeline input: False 89 | Accept wildcard characters: False 90 | ``` 91 | 92 | ### CommonParameters 93 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 94 | 95 | ## INPUTS 96 | 97 | ## OUTPUTS 98 | 99 | ## NOTES 100 | General notes 101 | 102 | ## RELATED LINKS 103 | -------------------------------------------------------------------------------- /Docs/Save-MailMessage.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Mailozaurr-help.xml 3 | Module Name: Mailozaurr 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Save-MailMessage 9 | 10 | ## SYNOPSIS 11 | {{ Fill in the Synopsis }} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Save-MailMessage [[-Message] ] [-Path ] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | {{ Fill in the Description }} 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> {{ Add example code here }} 27 | ``` 28 | 29 | {{ Add example description here }} 30 | 31 | ## PARAMETERS 32 | 33 | ### -Message 34 | {{ Fill Message Description }} 35 | 36 | ```yaml 37 | Type: PSObject[] 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: False 42 | Position: 0 43 | Default value: None 44 | Accept pipeline input: True (ByPropertyName, ByValue) 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### -Path 49 | {{ Fill Path Description }} 50 | 51 | ```yaml 52 | Type: String 53 | Parameter Sets: (All) 54 | Aliases: 55 | 56 | Required: False 57 | Position: Named 58 | Default value: None 59 | Accept pipeline input: False 60 | Accept wildcard characters: False 61 | ``` 62 | 63 | ### CommonParameters 64 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 65 | 66 | ## INPUTS 67 | 68 | ### System.Management.Automation.PSObject[] 69 | 70 | ## OUTPUTS 71 | 72 | ### System.Object 73 | ## NOTES 74 | 75 | ## RELATED LINKS 76 | -------------------------------------------------------------------------------- /Docs/Save-POPMessage.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Mailozaurr-help.xml 3 | Module Name: Mailozaurr 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Save-POPMessage 9 | 10 | ## SYNOPSIS 11 | {{ Fill in the Synopsis }} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Save-POPMessage [[-Client] ] [-Index] [-Path] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | {{ Fill in the Description }} 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> {{ Add example code here }} 27 | ``` 28 | 29 | {{ Add example description here }} 30 | 31 | ## PARAMETERS 32 | 33 | ### -Client 34 | {{ Fill Client Description }} 35 | 36 | ```yaml 37 | Type: IDictionary 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: False 42 | Position: 0 43 | Default value: None 44 | Accept pipeline input: False 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### -Index 49 | {{ Fill Index Description }} 50 | 51 | ```yaml 52 | Type: Int32 53 | Parameter Sets: (All) 54 | Aliases: 55 | 56 | Required: True 57 | Position: 1 58 | Default value: None 59 | Accept pipeline input: False 60 | Accept wildcard characters: False 61 | ``` 62 | 63 | ### -Path 64 | {{ Fill Path Description }} 65 | 66 | ```yaml 67 | Type: String 68 | Parameter Sets: (All) 69 | Aliases: 70 | 71 | Required: True 72 | Position: 2 73 | Default value: None 74 | Accept pipeline input: False 75 | Accept wildcard characters: False 76 | ``` 77 | 78 | ### CommonParameters 79 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 80 | 81 | ## INPUTS 82 | 83 | ### None 84 | 85 | ## OUTPUTS 86 | 87 | ### System.Object 88 | ## NOTES 89 | 90 | ## RELATED LINKS 91 | -------------------------------------------------------------------------------- /Docs/Test-EmailAddress.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: Mailozaurr-help.xml 3 | Module Name: Mailozaurr 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Test-EmailAddress 9 | 10 | ## SYNOPSIS 11 | Checks if email address matches conditions to be valid email address. 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Test-EmailAddress [-EmailAddress] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | Checks if email address matches conditions to be valid email address. 21 | 22 | ## EXAMPLES 23 | 24 | ### EXAMPLE 1 25 | ``` 26 | Test-EmailAddress -EmailAddress 'przemyslaw.klys@test' 27 | ``` 28 | 29 | ### EXAMPLE 2 30 | ``` 31 | Test-EmailAddress -EmailAddress 'przemyslaw.klys@test.pl' 32 | ``` 33 | 34 | ### EXAMPLE 3 35 | ``` 36 | Test-EmailAddress -EmailAddress 'przemyslaw.klys@test','przemyslaw.klys@test.pl' 37 | ``` 38 | 39 | ## PARAMETERS 40 | 41 | ### -EmailAddress 42 | EmailAddress to check 43 | 44 | ```yaml 45 | Type: String[] 46 | Parameter Sets: (All) 47 | Aliases: 48 | 49 | Required: True 50 | Position: 1 51 | Default value: None 52 | Accept pipeline input: True (ByPropertyName, ByValue) 53 | Accept wildcard characters: False 54 | ``` 55 | 56 | ### CommonParameters 57 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 58 | 59 | ## INPUTS 60 | 61 | ## OUTPUTS 62 | 63 | ## NOTES 64 | General notes 65 | 66 | ## RELATED LINKS 67 | -------------------------------------------------------------------------------- /Examples/Example-ConnecToImap-01.ps1: -------------------------------------------------------------------------------- 1 | Import-Module $PSScriptRoot\..\Mailozaurr.psd1 -Force 2 | 3 | $UserName = 'email@gmail.com' 4 | $Password = '' 5 | 6 | $Client = Connect-IMAP -Server 'imap.gmail.com' -Password $Password -UserName $UserName -Port 993 -Options Auto 7 | 8 | Get-IMAPFolder -Client $Client -Verbose 9 | 10 | ## Not yet sure how to best process messages 11 | #Get-IMAPMessage -Client $Client -Verbose 12 | #foreach ($folder in $client.Data.Inbox.GetSubfolders($false)) { 13 | # "[folder] {0}", $folder.Name 14 | #} 15 | 16 | Disconnect-IMAP -Client $Client -------------------------------------------------------------------------------- /Examples/Example-ConnecToImap-02.ps1: -------------------------------------------------------------------------------- 1 | Import-Module $PSScriptRoot\..\Mailozaurr.psd1 -Force 2 | 3 | $Credential = Get-Credential 4 | $Client = Connect-IMAP -Server 'imap.gmail.com' -Credential $Credential -Port 993 -Options Auto 5 | Get-IMAPFolder -Client $Client -Verbose 6 | 7 | ## Not yet sure how to best process messages 8 | #Get-IMAPMessage -Client $Client -Verbose 9 | #foreach ($folder in $client.Data.Inbox.GetSubfolders($false)) { 10 | # "[folder] {0}", $folder.Name 11 | #} 12 | 13 | Disconnect-IMAP -Client $Client -------------------------------------------------------------------------------- /Examples/Example-ConnecToImap-03-oAuth.ps1: -------------------------------------------------------------------------------- 1 | Import-Module $PSScriptRoot\..\Mailozaurr.psd1 -Force 2 | 3 | $ClientID = '9393330741' 4 | $ClientSecret = 'gk2ztAGU' 5 | 6 | $oAuth2 = Connect-oAuthGoogle -ClientID $ClientID -ClientSecret $ClientSecret -GmailAccount 'evotectest@gmail.com' -Scope https://mail.google.com/ 7 | $Client = Connect-IMAP -Server 'imap.gmail.com' -Port 993 -Options Auto -Credential $oAuth2 -oAuth2 8 | 9 | Get-IMAPFolder -Client $Client -Verbose 10 | 11 | ## Not yet sure how to best process messages 12 | #Get-IMAPMessage -Client $Client -Verbose 13 | #foreach ($folder in $client.Data.Inbox.GetSubfolders($false)) { 14 | # "[folder] {0}", $folder.Name 15 | #} 16 | 17 | Disconnect-IMAP -Client $Client -Verbose -------------------------------------------------------------------------------- /Examples/Example-ConnecToPop3-01.ps1: -------------------------------------------------------------------------------- 1 | Import-Module $PSScriptRoot\..\Mailozaurr.psd1 -Force 2 | 3 | $UserName = 'Test@gmail.com' 4 | $Password = 'TextPassword' 5 | 6 | $Client = Connect-POP3 -Server 'pop.gmail.com' -Password $Password -UserName $UserName -Port 995 -Options Auto 7 | Get-POP3Message -Client $Client -Index 0 -Count 5 8 | Save-POP3Message -Client $Client -Index 6 -Path "$Env:UserProfile\Desktop\mail.eml" 9 | Disconnect-POP3 -Client $Client -------------------------------------------------------------------------------- /Examples/Example-ConnecToPop3-02.ps1: -------------------------------------------------------------------------------- 1 | Import-Module $PSScriptRoot\..\Mailozaurr.psd1 -Force 2 | 3 | $Credentials = Get-Credential 4 | $Client = Connect-POP3 -Server 'pop.gmail.com' -Credential $Credentials -Port 995 -Options Auto 5 | Get-POP3Message -Client $Client -Index 0 -Count 5 | Format-Table 6 | Save-POP3Message -Client $Client -Index 6 -Path "$Env:UserProfile\Desktop\mail.eml" 7 | Disconnect-POP3 -Client $Client -------------------------------------------------------------------------------- /Examples/Example-ConnecToPop3-03-oAuth.ps1: -------------------------------------------------------------------------------- 1 | Import-Module $PSScriptRoot\..\Mailozaurr.psd1 -Force 2 | 3 | $ClientID = '93933307418' 4 | $ClientSecret = 'gk2ztAG' 5 | 6 | $oAuth2 = Connect-oAuthGoogle -ClientID $ClientID -ClientSecret $ClientSecret -GmailAccount 'email@gmail.com' -Scope https://mail.google.com/ 7 | $Client = Connect-POP3 -Server 'pop.gmail.com' -Credential $oAuth2 -Port 995 -Options Auto -oAuth2 8 | Get-POP3Message -Client $Client -Index 0 -Count 5 | Format-Table 9 | Save-POP3Message -Client $Client -Index 7 -Path "$Env:UserProfile\Desktop\mail7.eml" 10 | Disconnect-POP3 -Client $Client -Verbose -------------------------------------------------------------------------------- /Examples/Example-ConvertFromEmlToMsg.ps1: -------------------------------------------------------------------------------- 1 | Import-Module $PSScriptRoot\..\Mailozaurr.psd1 -Force 2 | 3 | $Conversion = ConvertFrom-EmlToMsg -InputPath "$PSScriptRoot\Input\Sample.eml" -OutputFolder "$PSScriptRoot\Output" -Verbose -Force 4 | $Conversion | Format-Table 5 | if ($Conversion.Status) { 6 | $Msg = Import-MailFile -FilePath $Conversion.MsgFile 7 | $Msg | Format-Table 8 | $Msg.Dispose() 9 | } -------------------------------------------------------------------------------- /Examples/Example-ImportMSG.ps1: -------------------------------------------------------------------------------- 1 | Import-Module $PSScriptRoot\..\Mailozaurr.psd1 -Force 2 | 3 | $Msg = Import-MailFile -FilePath "$PSScriptRoot\Input\TestMessage.msg" 4 | $Msg | Format-Table 5 | 6 | $Eml = Import-MailFile -FilePath "$PSScriptRoot\Input\Sample.eml" 7 | $Eml | Format-Table -------------------------------------------------------------------------------- /Examples/Example-SendEmail-01-Text.ps1: -------------------------------------------------------------------------------- 1 | Import-Module $PSScriptRoot\..\Mailozaurr.psd1 -Force 2 | 3 | if (-not $MailCredentials) { 4 | $MailCredentials = Get-Credential 5 | } 6 | 7 | $Text = Get-Content -Path "$PSScriptRoot\Input\Test.txt" -Raw 8 | 9 | # this is simple replacement (drag & drop to Send-MailMessage) 10 | Send-EmailMessage -To 'przemyslaw.klys@test.pl' -Subject 'Test' -Text $Text -SmtpServer 'smtp.office365.com' -From 'przemyslaw.klys@test.pl' -Priority High -Credential $MailCredentials -UseSsl -Port 587 -Verbose -------------------------------------------------------------------------------- /Examples/Example-SendEmail-01.ps1: -------------------------------------------------------------------------------- 1 | Import-Module $PSScriptRoot\..\Mailozaurr.psd1 -Force 2 | 3 | if (-not $MailCredentials) { 4 | $MailCredentials = Get-Credential 5 | } 6 | # this is simple replacement (drag & drop to Send-MailMessage) 7 | Send-EmailMessage -To 'przemyslaw.klys@test.pl' -Subject 'Test' -Body 'test me' -SmtpServer 'smtp.office365.com' -From 'przemyslaw.klys@test.pl' ` 8 | -Attachments "$PSScriptRoot\..\README.MD", "$PSScriptRoot\..\Mailozaurr.psm1" -Encoding UTF8 -Cc 'przemyslaw.klys@test.pl' -Priority High -Credential $MailCredentials ` 9 | -UseSsl -Port 587 -Verbose 10 | 11 | $Body = EmailBody { 12 | EmailText -Text 'This is my text' 13 | EmailTable -DataTable (Get-Process | Select-Object -First 5 -Property Name, Id, PriorityClass, CPU, Product) 14 | } 15 | $Text = 'This is my text' 16 | 17 | Send-EmailMessage -From @{ Name = 'Przemysław Kłys'; Email = 'przemyslaw.klys@test.pl' } -To 'przemyslaw.klys@test.pl' ` 18 | -Server 'smtp.office365.com' -Credential $MailCredentials -HTML $Body -Text $Text -DeliveryNotificationOption OnSuccess -Priority High ` 19 | -Subject 'This is another test email' -SecureSocketOptions Auto -------------------------------------------------------------------------------- /Examples/Example-SendEmail-02.ps1: -------------------------------------------------------------------------------- 1 | Import-Module $PSScriptRoot\..\Mailozaurr.psd1 -Force 2 | 3 | $UserNotify = 'Przemyslaw' 4 | 5 | $Body = EmailBody -FontFamily 'Calibri' -Size 15 { 6 | EmailText -Text 'Hello ', $UserNotify, ',' -Color None, Blue, None -Verbose -LineBreak 7 | EmailText -Text 'Your password is due to expire in ', $PasswordExpiryDays, 'days.' -Color None, Green, None 8 | EmailText -LineBreak 9 | EmailText -Text 'To change your password: ' 10 | EmailText -Text '- press ', 'CTRL+ALT+DEL', ' -> ', 'Change a password...' -Color None, BlueViolet, None, Red 11 | EmailText -LineBreak 12 | EmailTextBox { 13 | 'If you have forgotten your password and need to reset it, you can do this by clicking here. ' 14 | 'In case of problems please contact the HelpDesk by visiting [Evotec Website](https://evotec.xyz) or by sending an email to Help Desk.' 15 | } 16 | EmailText -LineBreak 17 | EmailText -Text 'Alternatively you can always call ', 'Help Desk', ' at ', '+48 22 00 00 00' ` 18 | -Color None, LightSkyBlue, None, LightSkyBlue -TextDecoration none, underline, none, underline -FontWeight normal, bold, normal, bold 19 | EmailText -LineBreak 20 | EmailTextBox { 21 | 'Kind regards,' 22 | 'Evotec IT' 23 | } 24 | } 25 | 26 | if (-not $MailCredentials) { 27 | $MailCredentials = Get-Credential 28 | } 29 | 30 | Send-EmailMessage -From @{ Name = 'Przemysław Kłys'; Email = 'przemyslaw.klys@test.pl' } -To 'przemyslaw.klys@test.pl' ` 31 | -Server 'smtp.office365.com' -SecureSocketOptions Auto -Credential $MailCredentials -HTML $Body -DeliveryNotificationOption OnSuccess -Priority High ` 32 | -Subject 'This is another test email' 33 | 34 | Send-MailMessage -To 'przemyslaw.klys@test.pl' -Subject 'Test' -Body 'test me' -SmtpServer 'smtp.office365.com' -From 'przemyslaw.klys@test.pl' ` 35 | -Attachments "$PSScriptRoot\..\Mailozaurr.psd1" -Cc 'przemyslaw.klys@test.pl' -DeliveryNotificationOption OnSuccess -Priority High -Credential $MailCredentials -UseSsl -Port 587 -Verbose # -Encoding UTF8 36 | -------------------------------------------------------------------------------- /Examples/Example-SendEmail-Graph.ps1: -------------------------------------------------------------------------------- 1 | Import-Module $PSScriptRoot\..\Mailozaurr.psd1 -Force 2 | 3 | $Body = EmailBody { 4 | EmailText -Text 'This is my text' 5 | EmailTable -DataTable (Get-Process | Select-Object -First 5 -Property Name, Id, PriorityClass, CPU, Product) 6 | } -Online 7 | 8 | # Credentials for Graph 9 | $ClientID = 'f8f134f3-78c7-48f4-a371-5d6eefa447cd' 10 | $DirectoryID = 'ceb371f6-8745-4876-a040-69f2d10a9d1a' 11 | $ClientSecret = Get-Content -Raw -Path "C:\Support\Important\Secretf8f134f3-78c7-48f4-a371-5d6eefa447cd.txt" 12 | 13 | $Credential = ConvertTo-GraphCredential -ClientID $ClientID -ClientSecret $ClientSecret -DirectoryID $DirectoryID 14 | 15 | # Sending email 16 | Send-EmailMessage -From @{ Name = 'Przemysław Kłys'; Email = 'przemyslaw.klys@evotec.pl' } -To 'przemyslaw.klys@evotec.pl' ` 17 | -Credential $Credential -HTML $Body -Subject 'This is another test email 1' -Graph -Verbose -Priority High 18 | 19 | # sending email with From as string (it won't matter for Exchange ) 20 | Send-EmailMessage -From 'przemyslaw.klys@evotec.pl' -To 'przemyslaw.klys@evotec.pl' ` 21 | -Credential $Credential -HTML $Body -Subject 'This is another test email 2' -Graph -Verbose -Priority Low -------------------------------------------------------------------------------- /Examples/Example-SendEmail-GraphWithMgRequest.ps1: -------------------------------------------------------------------------------- 1 | Import-Module .\Mailozaurr.psd1 -Force 2 | Import-Module Microsoft.Graph.Authentication -Force 3 | 4 | # this shows how to send email using combination of Mailozaurr and Microsoft.Graph to use Connect-MgGraph to authorize 5 | $Body = EmailBody { 6 | New-HTMLText -Text "This is test of Connect-MGGraph functionality" 7 | } 8 | 9 | # authorize via Connect-MgGraph with delegated rights or any other supported method 10 | Connect-MgGraph -Scopes Mail.Send -NoWelcome 11 | 12 | # sending email 13 | $sendEmailMessageSplat = @{ 14 | From = 'przemyslaw.klys@evotec.pl' 15 | To = 'przemyslaw.klys@evotec.pl' 16 | HTML = $Body 17 | Subject = 'This tests email as delegated' 18 | MgGraphRequest = $true 19 | Verbose = $true 20 | } 21 | Send-EmailMessage @sendEmailMessageSplat -------------------------------------------------------------------------------- /Examples/Example-SendEmail-OAuthGmail.ps1: -------------------------------------------------------------------------------- 1 | Import-Module $PSScriptRoot\..\Mailozaurr.psd1 -Force 2 | 3 | $ClientID = '939333074185' 4 | $ClientSecret = 'gk2ztAGU' 5 | 6 | $CredentialOAuth2 = Connect-oAuthGoogle -ClientID $ClientID -ClientSecret $ClientSecret -GmailAccount 'evot@gmail.com' 7 | 8 | Send-EmailMessage -From @{ Name = 'Przemysław Kłys'; Email = 'evot@gmail.com' } -To 'test@evotec.pl' ` 9 | -Server 'smtp.gmail.com' -HTML $Body -Text $Text -DeliveryNotificationOption OnSuccess -Priority High ` 10 | -Subject 'This is another test email' -SecureSocketOptions Auto -Credential $CredentialOAuth2 -oAuth -------------------------------------------------------------------------------- /Examples/Example-SendEmail-OAuthO365.ps1: -------------------------------------------------------------------------------- 1 | Import-Module $PSScriptRoot\..\Mailozaurr.psd1 -Force 2 | 3 | $ClientID = '4c1197dd-53' 4 | $TenantID = 'ceb371f6-87' 5 | 6 | $CredentialOAuth2 = Connect-oAuthO365 -ClientID $ClientID -TenantID $TenantID 7 | 8 | Send-EmailMessage -From @{ Name = 'Przemysław Kłys'; Email = 'test@evotec.pl' } -To 'test@evotec.pl' ` 9 | -Server 'smtp.office365.com' -HTML $Body -Text $Text -DeliveryNotificationOption OnSuccess -Priority High ` 10 | -Subject 'This is another test email' -SecureSocketOptions Auto -Credential $CredentialOAuth2 -oAuth2 -------------------------------------------------------------------------------- /Examples/Example-SendEmail-SendGrid01.ps1: -------------------------------------------------------------------------------- 1 | Import-Module $PSScriptRoot\..\Mailozaurr.psd1 -Force 2 | 3 | $Key = Get-Content -Raw -Path "C:\Support\Important\SendGrid.txt" 4 | 5 | # Use SendGrid via Standard SMTP 6 | # username needs to be named exactly apikey 7 | Send-EmailMessage -From 'przemyslaw.klys@evo.cool' -To 'przemyslaw.klys@evotec.pl', 'evotectest@gmail.com' ` 8 | -Username 'apikey' ` 9 | -Server 'smtp.sendgrid.net' ` 10 | -Password $Key ` 11 | -Body 'test me 🤣😍😒💖✨🎁 Przemysław Kłys' -DeliveryNotificationOption OnSuccess ` 12 | -Priority High -Subject '😒💖 This is another test email 我' -UseSsl -Port 587 -Verbose -WhatIf -------------------------------------------------------------------------------- /Examples/Example-SendEmail-SendGrid02.ps1: -------------------------------------------------------------------------------- 1 | Import-Module $PSScriptRoot\..\Mailozaurr.psd1 -Force 2 | 3 | # Use SendGrid Api 4 | $Key = Get-Content -Raw -Path "C:\Support\Important\SendGrid.txt" 5 | 6 | $Credential = ConvertTo-SendGridCredential -ApiKey $Key 7 | 8 | Send-EmailMessage -From 'przemyslaw.klys@evo.cool' ` 9 | -To 'przemyslaw.klys@evotec.pl', 'evotectest@gmail.com' ` 10 | -Body 'test me 🤣😍😒💖✨🎁 Przemysław Kłys' ` 11 | -Priority High ` 12 | -Subject '😒💖 This is another test email 我' ` 13 | -SendGrid ` 14 | -Credential $Credential ` 15 | -Verbose 16 | 17 | Send-EmailMessage -From @{ Name = 'Przemysław Kłys'; Email = 'przemyslaw.klys@evo.cool' } -To 'przemyslaw.klys@evotec.pl' -Credential $Credential -Text 'MyTest' -Priority High ` 18 | -Subject 'Second test email' -SendGrid -Verbose -------------------------------------------------------------------------------- /Examples/Example-ValidateEmail.ps1: -------------------------------------------------------------------------------- 1 | Import-Module $PSScriptRoot\..\Mailozaurr.psd1 -Force 2 | 3 | Write-Color -Text "Testing via parameter" -Color Green 4 | 5 | Test-EmailAddress -EmailAddress 'evotec@test', 'evotec@test.pl', 'evotec.@test.pl', 'evotec.p@test.pl.', 'olly@somewhere...com', 'olly@somewhere.', 'olly@somewhere', 'user@☎.com', '.@domain.tld' | Format-Table 6 | 7 | Write-Color -Text "Testing via pipeline" -Color Green 8 | 9 | 'evotec@test', 'evotec@test.pl', 'evotec.@test.pl', 'evotec.p@test.pl.', 'olly@somewhere...com', 'olly@somewhere.', 'olly@somewhere', 'user@☎.com', '.@domain.tld', "testme@zumpul.com" | Test-EmailAddress -Verbose | Format-Table -------------------------------------------------------------------------------- /Examples/Input/Test.txt: -------------------------------------------------------------------------------- 1 | Hello 2 | My Friend 3 | What's up -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Przemysław Kłys @ Evotec 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Mailozaurr.AzurePipelines.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - job: Windows_PowerShell_5 3 | pool: 4 | vmImage: windows-latest 5 | steps: 6 | - powershell: | 7 | Install-Module -Name Pester -Repository PSGallery -Force -SkipPublisherCheck 8 | .\Mailozaurr.Tests.ps1 -Verbose 9 | displayName: "Run Tests on Windows PowerShell 5.1" 10 | 11 | - job: Windows_PowerShell_7 12 | pool: 13 | vmImage: windows-latest 14 | steps: 15 | - pwsh: 'Install-Module -Name Pester -Repository PSGallery -Force -SkipPublisherCheck' 16 | displayName: "Update PESTER" 17 | - pwsh: '.\Mailozaurr.Tests.ps1 -Verbose' 18 | displayName: "Run Tests on Windows PowerShell 7" 19 | 20 | 21 | - job: Linux_Ubuntu 22 | 23 | pool: 24 | vmImage: ubuntu-latest 25 | 26 | steps: 27 | - script: | 28 | curl -sSL https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft-prod.list 29 | curl -sSL https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc 30 | sudo apt-get update 31 | sudo apt-get install -y powershell 32 | displayName: "Install PowerShell Core" 33 | 34 | - powershell: '.\Mailozaurr.Tests.ps1' 35 | displayName: "Run Tests on Linux" 36 | 37 | - job: MacOS 38 | pool: 39 | vmImage: macOS-latest 40 | steps: 41 | - script: | 42 | brew update 43 | brew tap caskroom/cask 44 | brew install mono-libgdiplus 45 | brew install --cask powershell 46 | displayName: "Install PowerShell 7" 47 | 48 | - powershell: '.\Mailozaurr.Tests.ps1' 49 | displayName: "Run Tests on MacOs" 50 | -------------------------------------------------------------------------------- /Mailozaurr.Tests.ps1: -------------------------------------------------------------------------------- 1 | $ModuleName = (Get-ChildItem $PSScriptRoot\*.psd1).BaseName 2 | $PrimaryModule = Get-ChildItem -Path $PSScriptRoot -Filter '*.psd1' -Recurse -ErrorAction SilentlyContinue -Depth 1 3 | if (-not $PrimaryModule) { 4 | throw "Path $PSScriptRoot doesn't contain PSD1 files. Failing tests." 5 | } 6 | if ($PrimaryModule.Count -ne 1) { 7 | throw 'More than one PSD1 files detected. Failing tests.' 8 | } 9 | $PSDInformation = Import-PowerShellDataFile -Path $PrimaryModule.FullName 10 | $RequiredModules = @( 11 | 'Pester' 12 | 'PSWriteColor' 13 | if ($PSDInformation.RequiredModules) { 14 | $PSDInformation.RequiredModules 15 | } 16 | ) 17 | foreach ($Module in $RequiredModules) { 18 | if ($Module -is [System.Collections.IDictionary]) { 19 | $Exists = Get-Module -ListAvailable -Name $Module.ModuleName 20 | if (-not $Exists) { 21 | Write-Warning "$ModuleName - Downloading $($Module.ModuleName) from PSGallery" 22 | Install-Module -Name $Module.ModuleName -Force -SkipPublisherCheck 23 | } 24 | } else { 25 | $Exists = Get-Module -ListAvailable $Module -ErrorAction SilentlyContinue 26 | if (-not $Exists) { 27 | Install-Module -Name $Module -Force -SkipPublisherCheck 28 | } 29 | } 30 | } 31 | 32 | Write-Color 'ModuleName: ', $ModuleName, ' Version: ', $PSDInformation.ModuleVersion -Color Yellow, Green, Yellow, Green -LinesBefore 2 33 | Write-Color 'PowerShell Version: ', $PSVersionTable.PSVersion -Color Yellow, Green 34 | Write-Color 'PowerShell Edition: ', $PSVersionTable.PSEdition -Color Yellow, Green 35 | Write-Color 'Required modules: ' -Color Yellow 36 | foreach ($Module in $PSDInformation.RequiredModules) { 37 | if ($Module -is [System.Collections.IDictionary]) { 38 | Write-Color ' [>] ', $Module.ModuleName, ' Version: ', $Module.ModuleVersion -Color Yellow, Green, Yellow, Green 39 | } else { 40 | Write-Color ' [>] ', $Module -Color Yellow, Green 41 | } 42 | } 43 | Write-Color 44 | 45 | Import-Module $PSScriptRoot\*.psd1 -Force 46 | $result = Invoke-Pester -Script $PSScriptRoot\Tests -Verbose -PassThru 47 | 48 | if ($result.FailedCount -gt 0) { 49 | throw "$($result.FailedCount) tests failed." 50 | } -------------------------------------------------------------------------------- /Mailozaurr.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | AliasesToExport = @('Connect-POP3', 'Disconnect-POP3', 'Get-POP3Message', 'Save-POP3Message') 3 | Author = 'Przemyslaw Klys' 4 | CmdletsToExport = @('Connect-IMAP', 'Connect-OAuthGoogle', 'Connect-OAuthO365', 'Connect-POP', 'ConvertFrom-EmlToMsg', 'ConvertTo-GraphCredential', 'ConvertTo-OAuth2Credential', 'ConvertTo-SendGridCredential', 'Disconnect-IMAP', 'Disconnect-POP', 'Get-IMAPFolder', 'Get-IMAPMessage', 'Get-MailFolder', 'Get-MailMessage', 'Get-MailMessageAttachment', 'Get-POPMessage', 'Import-MailFile', 'Save-MailMessage', 'Save-POPMessage', 'Send-EmailMessage', 'Test-EmailAddress') 5 | CompanyName = 'Evotec' 6 | CompatiblePSEditions = @('Desktop', 'Core') 7 | Copyright = '(c) 2011 - 2025 Przemyslaw Klys @ Evotec. All rights reserved.' 8 | Description = '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. ' 9 | FunctionsToExport = @() 10 | GUID = '2b0ea9f1-3ff1-4300-b939-106d5da608fa' 11 | ModuleVersion = '2.0.0' 12 | PowerShellVersion = '5.1' 13 | PrivateData = @{ 14 | PSData = @{ 15 | IconUri = 'https://evotec.xyz/wp-content/uploads/2020/07/MailoZaurr.png' 16 | Prerelease = 'Preview5' 17 | ProjectUri = 'https://github.com/EvotecIT/MailoZaurr' 18 | Tags = @('Windows', 'MacOS', 'Linux', 'Mail', 'Email', 'MX', 'SPF', 'DMARC', 'DKIM', 'GraphApi', 'SendGrid', 'Graph', 'IMAP', 'POP3') 19 | } 20 | } 21 | RootModule = 'Mailozaurr.psm1' 22 | } -------------------------------------------------------------------------------- /Mailozaurr.psm1: -------------------------------------------------------------------------------- 1 | # to speed up development adding direct path to binaries, instead of the the Lib folder 2 | $Development = $true 3 | $DevelopmentPath = "$PSScriptRoot\Sources\Mailozaurr.PowerShell\bin\Debug" 4 | $DevelopmentFolderCore = "net8.0" 5 | $DevelopmentFolderDefault = "net472" 6 | $BinaryModules = @( 7 | "Mailozaurr.PowerShell.dll" 8 | ) 9 | 10 | # Get public and private function definition files. 11 | $Public = @( Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue -Recurse -File) 12 | $Private = @( Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -ErrorAction SilentlyContinue -Recurse -File) 13 | $Classes = @( Get-ChildItem -Path $PSScriptRoot\Classes\*.ps1 -ErrorAction SilentlyContinue -Recurse -File) 14 | $Enums = @( Get-ChildItem -Path $PSScriptRoot\Enums\*.ps1 -ErrorAction SilentlyContinue -Recurse -File) 15 | # Get all assemblies 16 | $AssemblyFolders = Get-ChildItem -Path $PSScriptRoot\Lib -Directory -ErrorAction SilentlyContinue -File 17 | 18 | # Lets find which libraries we need to load 19 | if ($Development) { 20 | $Framework = 'Core' 21 | $FrameworkNet = 'Default' 22 | } else { 23 | $Default = $false 24 | $Core = $false 25 | $Standard = $false 26 | foreach ($A in $AssemblyFolders.Name) { 27 | if ($A -eq 'Default') { 28 | $Default = $true 29 | } elseif ($A -eq 'Core') { 30 | $Core = $true 31 | } elseif ($A -eq 'Standard') { 32 | $Standard = $true 33 | } 34 | } 35 | if ($Standard -and $Core -and $Default) { 36 | $FrameworkNet = 'Default' 37 | $Framework = 'Standard' 38 | } elseif ($Standard -and $Core) { 39 | $Framework = 'Standard' 40 | $FrameworkNet = 'Standard' 41 | } elseif ($Core -and $Default) { 42 | $Framework = 'Core' 43 | $FrameworkNet = 'Default' 44 | } elseif ($Standard -and $Default) { 45 | $Framework = 'Standard' 46 | $FrameworkNet = 'Default' 47 | } elseif ($Standard) { 48 | $Framework = 'Standard' 49 | $FrameworkNet = 'Standard' 50 | } elseif ($Core) { 51 | $Framework = 'Core' 52 | $FrameworkNet = '' 53 | } elseif ($Default) { 54 | $Framework = '' 55 | $FrameworkNet = 'Default' 56 | } 57 | } 58 | 59 | 60 | $BinaryDev = @( 61 | foreach ($BinaryModule in $BinaryModules) { 62 | if ($PSEdition -eq 'Core') { 63 | $Variable = Resolve-Path "$DevelopmentPath\$DevelopmentFolderCore\$BinaryModule" 64 | $DevelopmentAssemblyFolder = Resolve-Path "$DevelopmentPath\$DevelopmentFolderCore" 65 | } else { 66 | $Variable = Resolve-Path "$DevelopmentPath\$DevelopmentFolderDefault\$BinaryModule" 67 | $DevelopmentAssemblyFolder = Resolve-Path "$DevelopmentPath\$DevelopmentFolderDefault" 68 | } 69 | $Variable 70 | Write-Warning "Development mode: Using binaries from $Variable" 71 | } 72 | ) 73 | 74 | if ($Development) { 75 | $Assembly = Get-ChildItem -Path "$($DevelopmentAssemblyFolder.Path)\*.dll" -ErrorAction SilentlyContinue -File 76 | } else { 77 | $Assembly = @( 78 | if ($Framework -and $PSEdition -eq 'Core') { 79 | Get-ChildItem -Path $PSScriptRoot\Lib\$Framework\*.dll -ErrorAction SilentlyContinue #-Recurse 80 | } 81 | if ($FrameworkNet -and $PSEdition -ne 'Core') { 82 | Get-ChildItem -Path $PSScriptRoot\Lib\$FrameworkNet\*.dll -ErrorAction SilentlyContinue #-Recurse 83 | } 84 | ) 85 | } 86 | 87 | $FoundErrors = @( 88 | if ($Development) { 89 | foreach ($BinaryModule in $BinaryDev) { 90 | try { 91 | Import-Module -Name $BinaryModule -Force -ErrorAction Stop 92 | } catch { 93 | Write-Warning "Failed to import module $($BinaryModule): $($_.Exception.Message)" 94 | $true 95 | } 96 | } 97 | } else { 98 | foreach ($BinaryModule in $BinaryModules) { 99 | try { 100 | if ($Framework -and $PSEdition -eq 'Core') { 101 | Import-Module -Name "$PSScriptRoot\Lib\$Framework\$BinaryModule" -Force -ErrorAction Stop 102 | } 103 | if ($FrameworkNet -and $PSEdition -ne 'Core') { 104 | Import-Module -Name "$PSScriptRoot\Lib\$FrameworkNet\$BinaryModule" -Force -ErrorAction Stop 105 | } 106 | } catch { 107 | Write-Warning "Failed to import module $($BinaryModule): $($_.Exception.Message)" 108 | $true 109 | } 110 | } 111 | } 112 | foreach ($Import in @($Assembly)) { 113 | try { 114 | # Write-Warning -Message $Import.FullName 115 | Add-Type -Path $Import.Fullname -ErrorAction Stop 116 | } catch [System.Reflection.ReflectionTypeLoadException] { 117 | Write-Warning "Processing $($Import.Name) Exception: $($_.Exception.Message)" 118 | $LoaderExceptions = $($_.Exception.LoaderExceptions) | Sort-Object -Unique 119 | foreach ($E in $LoaderExceptions) { 120 | Write-Warning "Processing $($Import.Name) LoaderExceptions: $($E.Message)" 121 | } 122 | $true 123 | #Write-Error -Message "StackTrace: $($_.Exception.StackTrace)" 124 | } catch { 125 | Write-Warning "Processing $($Import.Name) Exception: $($_.Exception.Message)" 126 | $LoaderExceptions = $($_.Exception.LoaderExceptions) | Sort-Object -Unique 127 | foreach ($E in $LoaderExceptions) { 128 | Write-Warning "Processing $($Import.Name) LoaderExceptions: $($E.Message)" 129 | } 130 | $true 131 | #Write-Error -Message "StackTrace: $($_.Exception.StackTrace)" 132 | } 133 | } 134 | #Dot source the files 135 | foreach ($Import in @($Classes + $Enums + $Private + $Public)) { 136 | try { 137 | . $Import.Fullname 138 | } catch { 139 | Write-Error -Message "Failed to import functions from $($import.Fullname): $_" 140 | $true 141 | } 142 | } 143 | ) 144 | 145 | if ($FoundErrors.Count -gt 0) { 146 | $ModuleName = (Get-ChildItem $PSScriptRoot\*.psd1).BaseName 147 | Write-Warning "Importing module $ModuleName failed. Fix errors before continuing." 148 | break 149 | } 150 | 151 | Export-ModuleMember -Function '*' -Alias '*' -Cmdlet '*' -------------------------------------------------------------------------------- /Sources/Mailozaurr.Examples/Mailozaurr.Examples.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Sources/Mailozaurr.Examples/Program.cs: -------------------------------------------------------------------------------- 1 | using Mailozaurr; 2 | 3 | Console.WriteLine("Hello, World!"); 4 | 5 | var client = new ClientSmtp(); ; -------------------------------------------------------------------------------- /Sources/Mailozaurr.PowerShell/CmdletConnectOAuthGoogle.cs: -------------------------------------------------------------------------------- 1 | using System.Management.Automation; 2 | using System.Threading.Tasks; 3 | 4 | namespace Mailozaurr.PowerShell; 5 | 6 | /// 7 | /// Obtains an OAuth2 access token for a Google (Gmail) account for use with IMAP, SMTP, or other Google APIs. 8 | /// The Connect-OAuthGoogle cmdlet initiates an interactive OAuth2 authentication flow for a Gmail account, returning a object containing the access token. This credential can be used with other cmdlets (such as Connect-IMAP) that support OAuth2 authentication. 9 | /// 10 | /// Obtain an OAuth2 credential for Gmail 11 | /// Connect-OAuthGoogle -GmailAccount "user@gmail.com" -ClientID "id" -ClientSecret "secret" 12 | /// 13 | /// 14 | /// The returned PSCredential contains the access token as the password. Use with IMAP/SMTP cmdlets that support OAuth2. 15 | /// 16 | /// 17 | /// Mailozaurr Documentation 18 | /// 19 | [Cmdlet(VerbsCommunications.Connect, "OAuthGoogle")] 20 | [OutputType(typeof(PSCredential))] 21 | public class CmdletConnectOAuthGoogle : PSCmdlet { 22 | /// 23 | /// Specifies the Gmail account (email address) to authenticate. 24 | /// 25 | [Parameter(Mandatory = true)] 26 | public string? GmailAccount { get; set; } 27 | 28 | /// 29 | /// Specifies the OAuth2 client ID from the Google Developer Console. 30 | /// 31 | [Parameter(Mandatory = true)] 32 | public string? ClientID { get; set; } 33 | 34 | /// 35 | /// Specifies the OAuth2 client secret from the Google Developer Console. 36 | /// 37 | [Parameter(Mandatory = true)] 38 | public string? ClientSecret { get; set; } 39 | 40 | /// 41 | /// Specifies the OAuth2 scopes to request. Default is "https://mail.google.com/". 42 | /// 43 | [Parameter(Mandatory = false)] 44 | public string[]? Scope { get; set; } = new[] { "https://mail.google.com/" }; 45 | 46 | /// 47 | /// Performs the interactive OAuth2 authentication and returns a PSCredential with the access token. 48 | /// 49 | protected override void ProcessRecord() { 50 | OAuthCredential? cred = null; 51 | try { 52 | cred = Task.Run(() => Mailozaurr.OAuthHelpers.AcquireGoogleTokenInteractiveAsync(GmailAccount, ClientID, ClientSecret, Scope)).GetAwaiter().GetResult(); 53 | } catch (System.Exception ex) { 54 | WriteError(new ErrorRecord(ex, "OAuthGoogleAuthFailed", ErrorCategory.AuthenticationError, null)); 55 | return; 56 | } 57 | if (cred != null) { 58 | var secure = new System.Security.SecureString(); 59 | foreach (var c in cred.AccessToken) secure.AppendChar(c); 60 | var psCred = new PSCredential(cred.UserName, secure); 61 | WriteObject(psCred); 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr.PowerShell/CmdletConnectOAuthO365.cs: -------------------------------------------------------------------------------- 1 | using System.Management.Automation; 2 | using System.Threading.Tasks; 3 | using System.Collections.Generic; 4 | 5 | namespace Mailozaurr.PowerShell; 6 | 7 | /// 8 | /// Obtains an OAuth2 access token for an Office 365 (Microsoft 365) account for use with IMAP, SMTP, or Microsoft Graph. 9 | /// The Connect-OAuthO365 cmdlet initiates an interactive OAuth2 authentication flow for an Office 365 account, returning a object containing the access token. This credential can be used with other cmdlets (such as Connect-IMAP or Send-EmailMessage) that support OAuth2 authentication. 10 | /// 11 | /// Obtain an OAuth2 credential for Office 365 12 | /// Connect-OAuthO365 -Login "user@tenant.onmicrosoft.com" -ClientID "id" -TenantID "tenant" 13 | /// 14 | /// 15 | /// The returned PSCredential contains the access token as the password. Use with IMAP/SMTP/Graph cmdlets that support OAuth2. 16 | /// 17 | /// 18 | /// Mailozaurr Documentation 19 | /// 20 | [Cmdlet(VerbsCommunications.Connect, "OAuthO365")] 21 | [OutputType(typeof(PSCredential))] 22 | public class CmdletConnectOAuthO365 : PSCmdlet { 23 | /// 24 | /// Specifies the login (user principal name) for the Office 365 account. Optional; if not provided, interactive login is used. 25 | /// 26 | [Parameter(Mandatory = false)] 27 | public string? Login { get; set; } 28 | 29 | /// 30 | /// Specifies the OAuth2 client ID from Azure AD App Registration. 31 | /// 32 | [Parameter(Mandatory = true)] 33 | public string? ClientID { get; set; } 34 | 35 | /// 36 | /// Specifies the Azure AD tenant ID (Directory ID). 37 | /// 38 | [Parameter(Mandatory = true)] 39 | public string? TenantID { get; set; } 40 | 41 | /// 42 | /// Specifies the redirect URI for the OAuth2 flow. Default is the recommended Microsoft URI. 43 | /// 44 | [Parameter(Mandatory = false)] 45 | public string? RedirectUri { get; set; } = "https://login.microsoftonline.com/common/oauth2/nativeclient"; 46 | 47 | /// 48 | /// Specifies the OAuth2 scopes to request. Default includes IMAP, POP, and SMTP permissions. 49 | /// 50 | [Parameter(Mandatory = false)] 51 | public string[]? Scopes { get; set; } = new[] { 52 | "email", 53 | "offline_access", 54 | "https://outlook.office.com/IMAP.AccessAsUser.All", 55 | "https://outlook.office.com/POP.AccessAsUser.All", 56 | "https://outlook.office.com/SMTP.Send" 57 | }; 58 | 59 | /// 60 | /// Performs the interactive OAuth2 authentication and returns a PSCredential with the access token. 61 | /// 62 | protected override void ProcessRecord() { 63 | Mailozaurr.OAuthCredential cred = null; 64 | try { 65 | cred = Task.Run(() => Mailozaurr.OAuthHelpers.AcquireO365TokenInteractiveAsync(Login, ClientID, TenantID, RedirectUri, Scopes)).GetAwaiter().GetResult(); 66 | } catch (System.Exception ex) { 67 | WriteError(new ErrorRecord(ex, "OAuthO365AuthFailed", ErrorCategory.AuthenticationError, null)); 68 | return; 69 | } 70 | if (cred != null) { 71 | var secure = new System.Security.SecureString(); 72 | foreach (var c in cred.AccessToken) secure.AppendChar(c); 73 | var psCred = new PSCredential(cred.UserName, secure); 74 | WriteObject(psCred); 75 | } 76 | } 77 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr.PowerShell/CmdletConvertFromEmlToMsg.cs: -------------------------------------------------------------------------------- 1 | namespace Mailozaurr.PowerShell; 2 | 3 | /// 4 | /// Converts EML files to MSG format for compatibility with Microsoft Outlook and other clients. 5 | /// The ConvertFrom-EmlToMsg cmdlet converts one or more EML files to MSG format. Specify the input EML file paths and the output folder. The cmdlet processes each EML file and saves the converted MSG file in the specified output folder. Supports overwriting existing files with the -Force parameter. 6 | /// 7 | /// Convert multiple EML files to MSG format 8 | /// ConvertFrom-EmlToMsg -InputPath "C:\Mail\mail1.eml","C:\Mail\mail2.eml" -OutputFolder "C:\Converted" 9 | /// 10 | /// 11 | /// Convert EML files and overwrite existing MSG files 12 | /// ConvertFrom-EmlToMsg -InputPath "C:\Mail\*.eml" -OutputFolder "C:\Converted" -Force 13 | /// 14 | /// 15 | /// MSG format is commonly used by Microsoft Outlook. Use this cmdlet to migrate or archive EML messages for Outlook compatibility. 16 | /// 17 | /// Mailozaurr Documentation 18 | /// 19 | [Cmdlet(VerbsData.ConvertFrom, "EmlToMsg")] 20 | public sealed class CmdletConvertFromEmlToMsg : AsyncPSCmdlet { 21 | 22 | /// 23 | /// Specifies the paths to the EML files to convert. Accepts an array of strings. This parameter is mandatory. 24 | /// 25 | [Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)] 26 | public string[]? InputPath; 27 | 28 | /// 29 | /// Specifies the folder where the converted MSG files will be saved. This parameter is mandatory. 30 | /// 31 | [Alias("OutputPath")] 32 | [Parameter(Mandatory = true, Position = 1)] 33 | public string? OutputFolder { get; set; } 34 | 35 | /// 36 | /// If set, the cmdlet will overwrite existing MSG files without prompting. 37 | /// 38 | [Parameter(Mandatory = false, Position = 2)] 39 | public SwitchParameter Force { get; set; } 40 | 41 | /// 42 | /// Initializes logging for the conversion process. 43 | /// 44 | protected override Task BeginProcessingAsync() { 45 | // Initialize the logger to be able to see verbose, warning, debug, error, progress, and information messages. 46 | var internalLogger = new InternalLogger(); 47 | var internalLoggerPowerShell = new InternalLoggerPowerShell(internalLogger, this.WriteVerbose, this.WriteWarning, this.WriteDebug, this.WriteError, this.WriteProgress, this.WriteInformation); 48 | LoggingMessages.Logger = internalLogger; 49 | return Task.CompletedTask; 50 | } 51 | /// 52 | /// Converts the specified EML files to MSG format and writes the results to the output folder. 53 | /// 54 | protected override Task ProcessRecordAsync() { 55 | var outputMessage = EmailMessage.ConvertEmlToMsg(InputPath, OutputFolder, Force); 56 | foreach (var obj in outputMessage) { 57 | WriteObject(obj); 58 | } 59 | return Task.CompletedTask; 60 | } 61 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr.PowerShell/CmdletConvertToGraphCredential.cs: -------------------------------------------------------------------------------- 1 | namespace Mailozaurr.PowerShell; 2 | 3 | using System.Management.Automation; 4 | using System.Security; 5 | 6 | /// 7 | /// Creates a PSCredential object for Microsoft Graph authentication from client ID, secret, and directory ID. 8 | /// The ConvertTo-GraphCredential cmdlet creates a object suitable for Microsoft Graph authentication, using the provided client ID, client secret (clear or encrypted), and directory (tenant) ID. The resulting credential can be used with cmdlets that require Graph authentication. 9 | /// 10 | /// Create a Graph credential from clear text secret 11 | /// ConvertTo-GraphCredential -ClientId "id" -ClientSecret "secret" -DirectoryId "tenant" 12 | /// 13 | /// 14 | /// Create a Graph credential from encrypted secret 15 | /// ConvertTo-GraphCredential -ClientId "id" -ClientSecretEncrypted "..." -DirectoryId "tenant" 16 | /// 17 | /// 18 | /// Use this cmdlet to prepare credentials for use with Microsoft Graph cmdlets in automation scenarios. 19 | /// 20 | /// Mailozaurr Documentation 21 | /// 22 | [Cmdlet(VerbsData.ConvertTo, "GraphCredential")] 23 | [OutputType(typeof(PSCredential))] 24 | public class CmdletConvertToGraphCredential: PSCmdlet { 25 | /// 26 | /// Specifies the client ID for Microsoft Graph authentication. 27 | /// 28 | [Parameter(Mandatory = true, ParameterSetName = "ClearText")] 29 | [Parameter(Mandatory = true, ParameterSetName = "Encrypted")] 30 | public string? ClientId { get; set; } 31 | 32 | /// 33 | /// Specifies the client secret in clear text. Use only with the ClearText parameter set. 34 | /// 35 | [Parameter(Mandatory = true, ParameterSetName = "ClearText")] 36 | public string? ClientSecret { get; set; } 37 | 38 | /// 39 | /// Specifies the client secret in encrypted form. Use only with the Encrypted parameter set. 40 | /// 41 | [Parameter(Mandatory = true, ParameterSetName = "Encrypted")] 42 | public string? ClientSecretEncrypted { get; set; } 43 | 44 | /// 45 | /// Specifies the directory (tenant) ID for Microsoft Graph authentication. 46 | /// 47 | [Parameter(Mandatory = true, ParameterSetName = "ClearText")] 48 | [Parameter(Mandatory = true, ParameterSetName = "Encrypted")] 49 | public string? DirectoryId { get; set; } 50 | 51 | /// 52 | /// Creates a PSCredential object for Microsoft Graph authentication. 53 | /// 54 | protected override void ProcessRecord() { 55 | SecureString secret = this.ParameterSetName == "Encrypted" 56 | ? CredentialHelpers.ToSecureString(ClientSecretEncrypted) 57 | : CredentialHelpers.ToSecureString(ClientSecret); 58 | var username = $"{ClientId}@{DirectoryId}"; 59 | var credential = new PSCredential(username, secret); 60 | WriteObject(credential); 61 | } 62 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr.PowerShell/CmdletConvertToOAuth2Credential.cs: -------------------------------------------------------------------------------- 1 | namespace Mailozaurr.PowerShell; 2 | 3 | using System.Management.Automation; 4 | using System.Security; 5 | 6 | /// 7 | /// Creates a PSCredential object for OAuth2 authentication from a username and token. 8 | /// The ConvertTo-OAuth2Credential cmdlet creates a object suitable for OAuth2 authentication, using the provided username and access token. The resulting credential can be used with cmdlets that require OAuth2 authentication (such as IMAP, SMTP, or POP3 with OAuth2). 9 | /// 10 | /// Create an OAuth2 credential 11 | /// ConvertTo-OAuth2Credential -UserName "user@example.com" -Token "ya29.a0Af..." 12 | /// 13 | /// 14 | /// Use this cmdlet to prepare credentials for use with OAuth2-enabled cmdlets in automation scenarios. 15 | /// 16 | /// Mailozaurr Documentation 17 | /// 18 | [Cmdlet(VerbsData.ConvertTo, "OAuth2Credential")] 19 | [OutputType(typeof(PSCredential))] 20 | public class CmdletConvertToOAuth2Credential : PSCmdlet { 21 | /// 22 | /// Specifies the username for OAuth2 authentication. 23 | /// 24 | [Parameter(Mandatory = true)] 25 | public string? UserName { get; set; } 26 | /// 27 | /// Specifies the OAuth2 access token. 28 | /// 29 | [Parameter(Mandatory = true)] 30 | public string? Token { get; set; } 31 | 32 | /// 33 | /// Creates a PSCredential object for OAuth2 authentication. 34 | /// 35 | protected override void ProcessRecord() { 36 | var secret = CredentialHelpers.ToSecureString(Token); 37 | var credential = new PSCredential(UserName, secret); 38 | WriteObject(credential); 39 | } 40 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr.PowerShell/CmdletConvertToSendGridCredential.cs: -------------------------------------------------------------------------------- 1 | namespace Mailozaurr.PowerShell; 2 | 3 | using System.Management.Automation; 4 | using System.Security; 5 | 6 | /// 7 | /// Creates a PSCredential object for SendGrid API authentication from an API key. 8 | /// The ConvertTo-SendGridCredential cmdlet creates a object suitable for SendGrid API authentication, using the provided API key. The resulting credential can be used with cmdlets that require SendGrid authentication (such as Send-EmailMessage with the -SendGrid switch). 9 | /// 10 | /// Create a SendGrid credential 11 | /// ConvertTo-SendGridCredential -ApiKey "SG.xxxxx..." 12 | /// 13 | /// 14 | /// Use this cmdlet to prepare credentials for use with SendGrid-enabled cmdlets in automation scenarios. 15 | /// 16 | /// Mailozaurr Documentation 17 | /// 18 | [Cmdlet(VerbsData.ConvertTo, "SendGridCredential")] 19 | [OutputType(typeof(PSCredential))] 20 | public class CmdletConvertToSendGridCredential : PSCmdlet { 21 | /// 22 | /// Specifies the SendGrid API key. 23 | /// 24 | [Parameter(Mandatory = true)] 25 | public string? ApiKey { get; set; } 26 | 27 | /// 28 | /// Creates a PSCredential object for SendGrid API authentication. 29 | /// 30 | protected override void ProcessRecord() { 31 | var secret = CredentialHelpers.ToSecureString(ApiKey); 32 | var credential = new PSCredential("SendGrid", secret); 33 | WriteObject(credential); 34 | } 35 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr.PowerShell/CmdletDisconnectIMAP.cs: -------------------------------------------------------------------------------- 1 | namespace Mailozaurr.PowerShell; 2 | 3 | /// 4 | /// Disconnects an active IMAP connection previously established with Connect-IMAP. 5 | /// The Disconnect-IMAP cmdlet disconnects an active MailKit IMAP client session. Pass the object returned by Connect-IMAP to this cmdlet to safely close the connection and release resources. 6 | /// 7 | /// Disconnect an IMAP client 8 | /// $client = Connect-IMAP ...; Disconnect-IMAP -Client $client 9 | /// 10 | /// 11 | /// Always disconnect IMAP sessions to avoid resource leaks and server-side session limits. 12 | /// 13 | /// 14 | /// Mailozaurr Documentation 15 | /// 16 | [Cmdlet(VerbsCommunications.Disconnect, "IMAP")] 17 | public sealed class CmdletDisconnectIMAP : AsyncPSCmdlet { 18 | /// 19 | /// The object containing the MailKit IMAP client instance to disconnect. This is the object returned by Connect-IMAP. 20 | /// 21 | [Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true)] 22 | public ImapConnectionInfo? Client { get; set; } 23 | 24 | /// 25 | /// Disconnects the provided IMAP client. Writes a warning if disconnection fails. 26 | /// 27 | protected override Task ProcessRecordAsync() { 28 | if (Client != null) { 29 | var data = Client.Data; 30 | if (data != null) { 31 | try { 32 | data.Disconnect(true); 33 | } catch (System.Exception ex) { 34 | WriteWarning($"Disconnect-IMAP - Unable to disconnect: {ex.Message}"); 35 | } 36 | } else { 37 | WriteWarning("Disconnect-IMAP - The provided object does not contain a valid Data property of type ImapClient."); 38 | } 39 | } 40 | return Task.CompletedTask; 41 | } 42 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr.PowerShell/CmdletDisconnectPOP.cs: -------------------------------------------------------------------------------- 1 | using System.Management.Automation; 2 | using System.Threading.Tasks; 3 | using MailKit.Net.Pop3; 4 | 5 | namespace Mailozaurr.PowerShell; 6 | 7 | /// 8 | /// Disconnects an active POP3 connection previously established with Connect-POP. 9 | /// The Disconnect-POP cmdlet disconnects an active MailKit POP3 client session. Pass the object returned by Connect-POP to this cmdlet to safely close the connection and release resources. 10 | /// 11 | /// Disconnect a POP3 client 12 | /// $client = Connect-POP ...; Disconnect-POP -Client $client 13 | /// 14 | /// 15 | /// Always disconnect POP3 sessions to avoid resource leaks and server-side session limits. 16 | /// 17 | /// 18 | /// Mailozaurr Documentation 19 | /// 20 | [Cmdlet(VerbsCommunications.Disconnect, "POP")] 21 | [Alias("Disconnect-POP3")] 22 | public sealed class CmdletDisconnectPOP : AsyncPSCmdlet { 23 | /// 24 | /// The object containing the MailKit POP3 client instance to disconnect. This is the object returned by Connect-POP. 25 | /// 26 | [Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true)] 27 | public PopConnectionInfo? Client { get; set; } 28 | 29 | /// 30 | /// Disconnects the provided POP3 client. Writes a warning if disconnection fails. 31 | /// 32 | protected override Task ProcessRecordAsync() { 33 | if (Client != null) { 34 | var data = Client.Data; 35 | if (data != null) { 36 | try { 37 | data.Disconnect(true); 38 | } catch (System.Exception ex) { 39 | WriteWarning($"Disconnect-POP - Unable to disconnect: {ex.Message}"); 40 | } 41 | } else { 42 | WriteWarning("Disconnect-POP - The provided object does not contain a valid Data property of type Pop3Client."); 43 | } 44 | } 45 | return Task.CompletedTask; 46 | } 47 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr.PowerShell/CmdletGetIMAPFolder.cs: -------------------------------------------------------------------------------- 1 | using System.Management.Automation; 2 | using System.Threading.Tasks; 3 | using MailKit; 4 | using Mailozaurr.PowerShell; 5 | 6 | namespace Mailozaurr.PowerShell; 7 | 8 | /// 9 | /// Retrieves the IMAP inbox folder and updates message counts for an active IMAP connection. 10 | /// The Get-IMAPFolder cmdlet opens the inbox folder for the provided object (from Connect-IMAP), updates message and recent counts, and returns the updated connection info. Use this to refresh folder state or after connecting to an IMAP server. 11 | /// 12 | /// Get the inbox folder and message counts 13 | /// $client = Connect-IMAP ...; Get-IMAPFolder -Client $client 14 | /// 15 | /// 16 | /// Use this cmdlet to refresh the folder state after connecting or to update message counts. 17 | /// 18 | /// 19 | /// Mailozaurr Documentation 20 | /// 21 | [Cmdlet(VerbsCommon.Get, "IMAPFolder")] 22 | public sealed class CmdletGetIMAPFolder : AsyncPSCmdlet { 23 | /// 24 | /// The object representing the active IMAP connection. This is the object returned by Connect-IMAP. 25 | /// 26 | [Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true)] 27 | public ImapConnectionInfo? Client { get; set; } 28 | 29 | /// 30 | /// Specifies the folder access mode (ReadOnly or ReadWrite). Default is ReadOnly. 31 | /// 32 | [Parameter(Position = 1)] 33 | public FolderAccess FolderAccess { get; set; } = FolderAccess.ReadOnly; 34 | 35 | /// 36 | /// Opens the inbox folder, updates message counts, and returns the updated connection info. 37 | /// 38 | protected override Task ProcessRecordAsync() { 39 | if (Client != null) { 40 | var folder = Client.Data.Inbox; 41 | folder.Open(FolderAccess); 42 | WriteVerbose($"Get-IMAPMessage - Total messages {folder.Count}, Recent messages {folder.Recent}"); 43 | Client.Messages = folder; 44 | Client.Count = folder.Count; 45 | Client.Recent = folder.Recent; 46 | WriteObject(Client); 47 | } else { 48 | WriteVerbose("Get-IMAPMessage - Client not connected?"); 49 | } 50 | return Task.CompletedTask; 51 | } 52 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr.PowerShell/CmdletGetIMAPMessage.cs: -------------------------------------------------------------------------------- 1 | using System.Management.Automation; 2 | using System.Threading.Tasks; 3 | using MailKit; 4 | using Mailozaurr.PowerShell; 5 | 6 | namespace Mailozaurr.PowerShell; 7 | 8 | /// 9 | /// Retrieves the IMAP inbox folder and prepares the client for message retrieval. 10 | /// The Get-IMAPMessage cmdlet opens the inbox folder for the provided object (from Connect-IMAP), sets up the folder for message retrieval, and returns the updated connection info. Use this before fetching messages from the IMAP server. 11 | /// 12 | /// Prepare the IMAP client for message retrieval 13 | /// $client = Connect-IMAP ...; Get-IMAPMessage -Client $client 14 | /// 15 | /// 16 | /// Use this cmdlet to open the inbox and prepare for message enumeration or retrieval. 17 | /// 18 | /// 19 | /// Mailozaurr Documentation 20 | /// 21 | [Cmdlet(VerbsCommon.Get, "IMAPMessage")] 22 | public sealed class CmdletGetIMAPMessage : AsyncPSCmdlet { 23 | /// 24 | /// The object representing the active IMAP connection. This is the object returned by Connect-IMAP. 25 | /// 26 | [Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true)] 27 | public ImapConnectionInfo? Client { get; set; } 28 | 29 | /// 30 | /// Specifies the folder access mode (ReadOnly or ReadWrite). Default is ReadOnly. 31 | /// 32 | [Parameter(Position = 1)] 33 | public FolderAccess FolderAccess { get; set; } = FolderAccess.ReadOnly; 34 | 35 | /// 36 | /// Opens the inbox folder and prepares the client for message retrieval. 37 | /// 38 | protected override Task ProcessRecordAsync() { 39 | if (Client != null) { 40 | var folder = Client.Data.Inbox; 41 | folder.Open(FolderAccess); 42 | WriteVerbose($"Get-IMAPMessage - Total messages {folder.Count}, Recent messages {folder.Recent}"); 43 | Client.Folder = folder as MailKit.Net.Imap.ImapFolder; 44 | WriteObject(Client); 45 | } else { 46 | WriteVerbose("Get-IMAPMessage - Client not connected?"); 47 | } 48 | return Task.CompletedTask; 49 | } 50 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr.PowerShell/CmdletGetMailFolder.cs: -------------------------------------------------------------------------------- 1 | using System.Management.Automation; 2 | using Mailozaurr; 3 | 4 | namespace Mailozaurr.PowerShell; 5 | 6 | /// 7 | /// Retrieves mail folders for a user via Microsoft Graph API. 8 | /// The Get-MailFolder cmdlet retrieves mail folders for the specified user principal name (email address) using Microsoft Graph API. You can specify client credentials directly or use a PSCredential object. Returns folder objects for use in further automation or reporting. 9 | /// 10 | /// Get mail folders for a user 11 | /// Get-MailFolder -UserPrincipalName "user@domain.com" -ClientId "id" -ClientSecret "secret" -DirectoryId "tenant" 12 | /// 13 | /// 14 | /// Use this cmdlet to enumerate mail folders for mailbox management, reporting, or migration scenarios. 15 | /// 16 | /// Mailozaurr Documentation 17 | /// 18 | [Cmdlet(VerbsCommon.Get, "MailFolder")] 19 | [OutputType(typeof(object))] 20 | public class CmdletGetMailFolder : PSCmdlet { 21 | /// 22 | /// Specifies the user principal name (email address) whose mail folders will be retrieved. 23 | /// 24 | [Parameter(Mandatory = true)] 25 | public string? UserPrincipalName { get; set; } 26 | /// 27 | /// Specifies the client ID for Microsoft Graph authentication. 28 | /// 29 | [Parameter] 30 | public string? ClientId { get; set; } 31 | /// 32 | /// Specifies the client secret for Microsoft Graph authentication. 33 | /// 34 | [Parameter] 35 | public string? ClientSecret { get; set; } 36 | /// 37 | /// Specifies the directory (tenant) ID for Microsoft Graph authentication. 38 | /// 39 | [Parameter] 40 | public string? DirectoryId { get; set; } 41 | 42 | /// 43 | /// Retrieves mail folders for the specified user via Microsoft Graph API. 44 | /// 45 | protected override void ProcessRecord() { 46 | var cred = new GraphCredential { ClientId = ClientId, ClientSecret = ClientSecret, DirectoryId = DirectoryId }; 47 | var task = MicrosoftGraphUtils.GetMailFoldersAsync(cred, UserPrincipalName); 48 | task.Wait(); 49 | foreach (var folder in task.Result) { 50 | WriteObject(folder); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Sources/Mailozaurr.PowerShell/CmdletGetMailMessage.cs: -------------------------------------------------------------------------------- 1 | using System.Management.Automation; 2 | using Mailozaurr; 3 | using System.Linq; 4 | using System.Collections.Generic; 5 | 6 | namespace Mailozaurr.PowerShell; 7 | 8 | /// 9 | /// Retrieves mail messages for a user via Microsoft Graph API. 10 | /// The Get-MailMessage cmdlet retrieves mail messages for the specified user principal name (email address) using Microsoft Graph API. You can specify client credentials directly or use a PSCredential object. Supports filtering, property selection, and limiting the number of results. Returns messages as PSObjects for further automation or reporting. 11 | /// 12 | /// Get mail messages for a user 13 | /// Get-MailMessage -UserPrincipalName "user@domain.com" -ClientId "id" -ClientSecret "secret" -DirectoryId "tenant" 14 | /// 15 | /// 16 | /// Get mail messages with a filter and limit 17 | /// Get-MailMessage -UserPrincipalName "user@domain.com" -Filter "subject eq 'Test'" -Limit 10 18 | /// 19 | /// 20 | /// Use this cmdlet to enumerate mail messages for mailbox management, reporting, or migration scenarios. 21 | /// 22 | /// Mailozaurr Documentation 23 | /// 24 | [Cmdlet(VerbsCommon.Get, "MailMessage")] 25 | [OutputType(typeof(PSObject))] 26 | public class CmdletGetMailMessage : PSCmdlet { 27 | /// 28 | /// Specifies the user principal name (email address) whose mail messages will be retrieved. 29 | /// 30 | [Parameter(Mandatory = true)] 31 | public string? UserPrincipalName { get; set; } 32 | /// 33 | /// Specifies the client ID for Microsoft Graph authentication. 34 | /// 35 | [Parameter] 36 | public string? ClientId { get; set; } 37 | /// 38 | /// Specifies the client secret for Microsoft Graph authentication. 39 | /// 40 | [Parameter] 41 | public string? ClientSecret { get; set; } 42 | /// 43 | /// Specifies the directory (tenant) ID for Microsoft Graph authentication. 44 | /// 45 | [Parameter] 46 | public string? DirectoryId { get; set; } 47 | /// 48 | /// Specifies the properties to retrieve for each mail message. 49 | /// 50 | [Parameter] 51 | public string[]? Property { get; set; } 52 | /// 53 | /// Specifies an OData filter string to filter the mail messages. 54 | /// 55 | [Parameter] 56 | public string? Filter { get; set; } 57 | /// 58 | /// Specifies the maximum number of mail messages to retrieve. 59 | /// 60 | [Parameter] 61 | public int? Limit { get; set; } 62 | /// 63 | /// Specifies a PSCredential object for Microsoft Graph authentication. Username should be in the format clientid@directoryid. 64 | /// 65 | [Parameter] 66 | public PSCredential? Credential { get; set; } 67 | 68 | /// 69 | /// Retrieves mail messages for the specified user via Microsoft Graph API. 70 | /// 71 | protected override void ProcessRecord() { 72 | GraphCredential cred; 73 | if (Credential != null) { 74 | // Username is clientid@directoryid 75 | var parts = Credential.UserName.Split('@'); 76 | if (parts.Length == 2) { 77 | cred = new GraphCredential { 78 | ClientId = parts[0], 79 | DirectoryId = parts[1], 80 | ClientSecret = Credential.GetNetworkCredential().Password 81 | }; 82 | } else { 83 | ThrowTerminatingError(new ErrorRecord(new System.ArgumentException("Credential.UserName must be in the format clientid@directoryid"), "InvalidCredentialFormat", ErrorCategory.InvalidArgument, Credential)); 84 | return; 85 | } 86 | } else { 87 | cred = new GraphCredential { ClientId = ClientId, ClientSecret = ClientSecret, DirectoryId = DirectoryId }; 88 | } 89 | var task = MicrosoftGraphUtils.GetMailMessagesAsync(cred, UserPrincipalName, Property, Filter, Limit); 90 | task.Wait(); 91 | foreach (var dict in task.Result) { 92 | WriteObject(PSObject.AsPSObject(dict)); 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /Sources/Mailozaurr.PowerShell/CmdletGetMailMessageAttachment.cs: -------------------------------------------------------------------------------- 1 | using System.Management.Automation; 2 | using Mailozaurr; 3 | using System.Linq; 4 | 5 | namespace Mailozaurr.PowerShell; 6 | 7 | /// 8 | /// Retrieves attachments for a specific mail message via Microsoft Graph API. 9 | /// The Get-MailMessageAttachment cmdlet retrieves attachments for the specified mail message ID and user principal name (email address) using Microsoft Graph API. You can specify client credentials directly. Returns attachment objects for further automation or reporting. 10 | /// 11 | /// Get attachments for a mail message 12 | /// Get-MailMessageAttachment -UserPrincipalName "user@domain.com" -MessageId "AAMk..." -ClientId "id" -ClientSecret "secret" -DirectoryId "tenant" 13 | /// 14 | /// 15 | /// Use this cmdlet to enumerate attachments for mailbox management, reporting, or migration scenarios. 16 | /// 17 | /// Mailozaurr Documentation 18 | /// 19 | [Cmdlet(VerbsCommon.Get, "MailMessageAttachment")] 20 | [OutputType(typeof(Attachment))] 21 | public class CmdletGetMailMessageAttachment : PSCmdlet { 22 | /// 23 | /// Specifies the user principal name (email address) whose mail message attachments will be retrieved. 24 | /// 25 | [Parameter(Mandatory = true)] 26 | public string? UserPrincipalName { get; set; } 27 | /// 28 | /// Specifies the message ID for which attachments will be retrieved. 29 | /// 30 | [Parameter(Mandatory = true)] 31 | public string? MessageId { get; set; } 32 | /// 33 | /// Specifies the client ID for Microsoft Graph authentication. 34 | /// 35 | [Parameter] 36 | public string? ClientId { get; set; } 37 | /// 38 | /// Specifies the client secret for Microsoft Graph authentication. 39 | /// 40 | [Parameter] 41 | public string? ClientSecret { get; set; } 42 | /// 43 | /// Specifies the directory (tenant) ID for Microsoft Graph authentication. 44 | /// 45 | [Parameter] 46 | public string? DirectoryId { get; set; } 47 | /// 48 | /// Specifies the properties to retrieve for each attachment. 49 | /// 50 | [Parameter] 51 | public string[]? Property { get; set; } 52 | 53 | /// 54 | /// Retrieves attachments for the specified mail message via Microsoft Graph API. 55 | /// 56 | protected override void ProcessRecord() { 57 | var cred = new GraphCredential { ClientId = ClientId, ClientSecret = ClientSecret, DirectoryId = DirectoryId }; 58 | var task = MicrosoftGraphUtils.GetMailMessageAttachmentsAsync(cred, UserPrincipalName, MessageId, Property); 59 | task.Wait(); 60 | foreach (var att in task.Result) { 61 | WriteObject(att); 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr.PowerShell/CmdletGetPOPMessage.cs: -------------------------------------------------------------------------------- 1 | using System.Management.Automation; 2 | using System.Threading.Tasks; 3 | using Mailozaurr.PowerShell; 4 | 5 | namespace Mailozaurr.PowerShell; 6 | 7 | /// 8 | /// Retrieves messages from a POP3 mailbox using an active POP3 connection. 9 | /// The Get-POPMessage cmdlet retrieves one or more messages from a POP3 mailbox using the provided object (from Connect-POP). You can specify the message index, count, or use -All to retrieve all messages. Returns message objects for further automation or archiving. 10 | /// 11 | /// Get the first message from a POP3 mailbox 12 | /// $client = Connect-POP ...; Get-POPMessage -Client $client -Index 0 13 | /// 14 | /// 15 | /// Get all messages from a POP3 mailbox 16 | /// $client = Connect-POP ...; Get-POPMessage -Client $client -All 17 | /// 18 | /// 19 | /// Use this cmdlet to enumerate or download messages from a POP3 mailbox for backup, migration, or processing. 20 | /// 21 | /// 22 | /// Mailozaurr Documentation 23 | /// 24 | [Cmdlet(VerbsCommon.Get, "POPMessage")] 25 | [Alias("Get-POP3Message")] 26 | public sealed class CmdletGetPOPMessage : AsyncPSCmdlet { 27 | /// 28 | /// The object representing the active POP3 connection. This is the object returned by Connect-POP. 29 | /// 30 | [Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true)] 31 | public PopConnectionInfo? Client { get; set; } 32 | 33 | /// 34 | /// Specifies the index of the first message to retrieve. Default is 0 (the first message). 35 | /// 36 | [Parameter(Position = 1)] 37 | public int Index { get; set; } 38 | 39 | /// 40 | /// Specifies the number of messages to retrieve starting from Index. Default is 1. 41 | /// 42 | [Parameter(Position = 2)] 43 | public int Count { get; set; } = 1; 44 | 45 | /// 46 | /// If set, retrieves all messages from the POP3 mailbox. 47 | /// 48 | [Parameter()] 49 | public SwitchParameter All { get; set; } 50 | 51 | /// 52 | /// Retrieves one or more messages from the POP3 mailbox. 53 | /// 54 | protected override Task ProcessRecordAsync() { 55 | if (Client != null && Client.Data != null) { 56 | if (All.IsPresent) { 57 | var messages = Client.Data.GetMessages(Index, Count); 58 | WriteObject(messages, true); 59 | } else { 60 | if (Index < Client.Data.Count) { 61 | var messages = Client.Data.GetMessages(Index, Count); 62 | WriteObject(messages, true); 63 | } else { 64 | WriteWarning($"Get-POP3Message - Index is out of range. Use index less than {Client.Data.Count}."); 65 | } 66 | } 67 | } else { 68 | WriteWarning("Get-POP3Message - Is POP3 connected?"); 69 | } 70 | return Task.CompletedTask; 71 | } 72 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr.PowerShell/CmdletImportMailFile.cs: -------------------------------------------------------------------------------- 1 | using System.Management.Automation; 2 | using System.IO; 3 | using System.Threading.Tasks; 4 | using MsgReader; 5 | using MsgReader.Mime; 6 | 7 | namespace Mailozaurr.PowerShell; 8 | 9 | /// 10 | /// Imports a .msg or .eml mail file and returns its contents as a message object. 11 | /// The Import-MailFile cmdlet loads a .msg (Outlook) or .eml (RFC822) file from disk and returns a message object for further processing, inspection, or conversion. Supports both file types and provides warnings for unsupported files or errors. 12 | /// 13 | /// Import a .msg file 14 | /// Import-MailFile -InputPath "C:\Mail\message.msg" 15 | /// 16 | /// 17 | /// Import a .eml file 18 | /// Import-MailFile -InputPath "C:\Mail\message.eml" 19 | /// 20 | /// 21 | /// Use this cmdlet to inspect, convert, or process mail files in automation or migration scenarios. 22 | /// 23 | /// Mailozaurr Documentation 24 | /// 25 | [Cmdlet(VerbsData.Import, "MailFile")] 26 | public sealed class CmdletImportMailFile : AsyncPSCmdlet { 27 | /// 28 | /// Specifies the path to the .msg or .eml file to import. Accepts aliases FilePath and Path. 29 | /// 30 | [Parameter(Mandatory = true, Position = 0)] 31 | [Alias("FilePath", "Path")] 32 | public string? InputPath { get; set; } 33 | 34 | /// 35 | /// Imports the specified mail file and returns its contents as a message object. 36 | /// 37 | protected override Task ProcessRecordAsync() { 38 | if (!string.IsNullOrEmpty(InputPath) && File.Exists(InputPath)) { 39 | FileInfo item; 40 | try { 41 | item = new FileInfo(InputPath); 42 | } catch (System.Exception ex) { 43 | WriteWarning($"Import-MailFile - File {InputPath} doesn't exist. Error: {ex.Message}"); 44 | return Task.CompletedTask; 45 | } 46 | try { 47 | if (item.Extension.Equals(".msg", System.StringComparison.OrdinalIgnoreCase)) { 48 | var message = new MsgReader.Outlook.Storage.Message(InputPath); 49 | WriteObject(message); 50 | } else if (item.Extension.Equals(".eml", System.StringComparison.OrdinalIgnoreCase)) { 51 | var message = MsgReader.Mime.Message.Load(new FileInfo(InputPath)); 52 | WriteObject(message); 53 | } else { 54 | WriteWarning($"Import-MailFile - File {InputPath} is not a .msg or .eml file."); 55 | } 56 | } catch (System.Exception ex) { 57 | WriteWarning($"Import-MailFile - File {InputPath} is not a .msg or .eml file or another error occured. Error: {ex.Message}"); 58 | } 59 | } else { 60 | WriteWarning($"Import-MailFile - File {InputPath} doesn't exist."); 61 | } 62 | return Task.CompletedTask; 63 | } 64 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr.PowerShell/CmdletSaveMailMessage.cs: -------------------------------------------------------------------------------- 1 | using System.Management.Automation; 2 | using Mailozaurr; 3 | 4 | namespace Mailozaurr.PowerShell; 5 | 6 | /// 7 | /// Saves Microsoft Graph email messages to disk in a specified format. 8 | /// The Save-MailMessage cmdlet saves one or more objects to disk at the specified path. Use this to archive, export, or process messages retrieved from Microsoft Graph. 9 | /// 10 | /// Save mail messages to a folder 11 | /// Get-MailMessage ... | Save-MailMessage -Path "C:\Archive" 12 | /// 13 | /// 14 | /// Use this cmdlet to export or archive messages for backup, migration, or compliance scenarios. 15 | /// 16 | /// Mailozaurr Documentation 17 | /// 18 | [Cmdlet(VerbsData.Save, "MailMessage")] 19 | public class CmdletSaveMailMessage : PSCmdlet { 20 | /// 21 | /// Specifies the objects to save. Accepts pipeline input. 22 | /// 23 | [Parameter(Mandatory = true, ValueFromPipeline = true)] 24 | public GraphEmailMessage[]? Message { get; set; } 25 | /// 26 | /// Specifies the path where the messages will be saved. 27 | /// 28 | [Parameter(Mandatory = true)] 29 | public string? Path { get; set; } 30 | 31 | /// 32 | /// Saves the specified mail messages to disk at the given path. 33 | /// 34 | protected override void ProcessRecord() { 35 | MicrosoftGraphUtils.SaveMailMessages(Message, Path); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Sources/Mailozaurr.PowerShell/CmdletSavePOPMessage.cs: -------------------------------------------------------------------------------- 1 | using System.Management.Automation; 2 | using System.Threading.Tasks; 3 | using Mailozaurr.PowerShell; 4 | 5 | namespace Mailozaurr.PowerShell; 6 | 7 | /// 8 | /// Saves a POP3 message to disk at the specified path. 9 | /// The Save-POPMessage cmdlet saves a message from a POP3 mailbox (using a object from Connect-POP) to disk at the specified path. Use this to archive, export, or process messages retrieved from a POP3 server. 10 | /// 11 | /// Save a POP3 message to a file 12 | /// $client = Connect-POP ...; Save-POPMessage -Client $client -Index 0 -Path "C:\Mail\message.eml" 13 | /// 14 | /// 15 | /// Use this cmdlet to export or archive messages for backup, migration, or compliance scenarios. 16 | /// 17 | /// 18 | /// Mailozaurr Documentation 19 | /// 20 | [Cmdlet(VerbsData.Save, "POPMessage")] 21 | [Alias("Save-POP3Message")] 22 | public sealed class CmdletSavePOPMessage : AsyncPSCmdlet { 23 | /// 24 | /// The object representing the active POP3 connection. This is the object returned by Connect-POP. 25 | /// 26 | [Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true)] 27 | public PopConnectionInfo? Client { get; set; } 28 | 29 | /// 30 | /// Specifies the index of the message to save. 31 | /// 32 | [Parameter(Mandatory = true, Position = 1)] 33 | public int Index { get; set; } 34 | 35 | /// 36 | /// Specifies the path where the message will be saved. 37 | /// 38 | [Parameter(Mandatory = true, Position = 2)] 39 | public string? Path { get; set; } 40 | 41 | /// 42 | /// Saves the specified POP3 message to disk at the given path. 43 | /// 44 | protected override Task ProcessRecordAsync() { 45 | if (Client != null && Client.Data != null) { 46 | if (Index < Client.Data.Count) { 47 | var message = Client.Data.GetMessage(Index); 48 | message.WriteTo(Path); 49 | } else { 50 | WriteWarning($"Save-POP3Message - Index is out of range. Use index less than {Client.Data.Count}."); 51 | } 52 | } else { 53 | WriteWarning("Save-POP3Message - Is POP3 connected?"); 54 | } 55 | return Task.CompletedTask; 56 | } 57 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr.PowerShell/CmdletTestEmailAddress.cs: -------------------------------------------------------------------------------- 1 | namespace Mailozaurr.PowerShell; 2 | 3 | /// 4 | /// Validates one or more email addresses for format and standards compliance. 5 | /// The Test-EmailAddress cmdlet checks if one or more email addresses are valid according to standard email address rules. Supports validation for international addresses and top-level domains. Returns validation results for each address. 6 | /// 7 | /// Check if an email address is valid 8 | /// Test-EmailAddress -EmailAddress "test@example.com" 9 | /// 10 | /// 11 | /// Check if an email address is valid using pipeline input 12 | /// "test@example.com" | Test-EmailAddress 13 | /// 14 | /// 15 | /// Check if an email address is a valid international email address 16 | /// Test-EmailAddress -EmailAddress "test@exámple.com" -AllowInternational 17 | /// 18 | /// 19 | /// Check if an email address is valid with a top level domain 20 | /// Test-EmailAddress -EmailAddress "test@email" -AllowTopLevelDomains 21 | /// 22 | /// 23 | /// Use this cmdlet to validate email addresses before sending, importing, or processing them in automation scenarios. 24 | /// 25 | /// Mailozaurr Documentation 26 | /// 27 | [Cmdlet(VerbsDiagnostic.Test, "EmailAddress")] 28 | public sealed class CmdletTestEmailAddress : AsyncPSCmdlet { 29 | 30 | /// 31 | /// Specifies the email addresses to check. Accepts an array of strings. This parameter is mandatory. 32 | /// 33 | [Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)] 34 | public string[]? EmailAddress; 35 | 36 | /// 37 | /// If set, the cmdlet will use the newer international email standards to validate the email addresses. 38 | /// 39 | [Parameter(Mandatory = false, Position = 1)] 40 | public SwitchParameter AllowInternational { get; set; } 41 | 42 | /// 43 | /// If set, the cmdlet will allow top level domains in the email addresses (such as test@email). 44 | /// 45 | [Parameter(Mandatory = false, Position = 2)] 46 | public SwitchParameter AllowTopLevelDomains { get; set; } 47 | 48 | private InternalLogger _logger; 49 | 50 | /// 51 | /// Initializes the logger for verbose, warning, debug, error, progress, and information messages. 52 | /// 53 | protected override Task BeginProcessingAsync() { 54 | // Initialize the logger to be able to see verbose, warning, debug, error, progress, and information messages. 55 | _logger = new InternalLogger(false); 56 | var internalLoggerPowerShell = new InternalLoggerPowerShell(_logger, this.WriteVerbose, this.WriteWarning, this.WriteDebug, this.WriteError, this.WriteProgress, this.WriteInformation); 57 | return Task.CompletedTask; 58 | } 59 | 60 | /// 61 | /// Processes each email address and checks if it is valid. Writes results to the output pipeline. 62 | /// 63 | protected override async Task ProcessRecordAsync() { 64 | foreach (var email in EmailAddress) { 65 | _logger.WriteVerbose("Processing email: {0}", email); 66 | WriteObject(Validator.ValidateEmail(email, AllowInternational, AllowTopLevelDomains)); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Sources/Mailozaurr.PowerShell/Communication/LogEmitter.cs: -------------------------------------------------------------------------------- 1 | namespace Mailozaurr.PowerShell; 2 | 3 | /// 4 | /// LogEmitter is a static class that emits logs to the PowerShell cmdlet. 5 | /// It's used as a way to decouple the logging from the cmdlet. 6 | /// - `LoggingMessages.Logger.WriteXXX` static method should be used for AsyncPSCmdlet. 7 | /// - `LogCollector.LogWarning($"Send-EmailMessage - Error during sending using SendGrid: {ex.Message}")` should be used for native PSCmdlet. 8 | /// 9 | public static class LogEmitter { 10 | /// 11 | /// Emits logs to the PowerShell cmdlet. 12 | /// 13 | /// The log collector. 14 | /// The PowerShell cmdlet. 15 | public static void EmitLogs(LogCollector collector, PSCmdlet cmdlet) { 16 | while (collector.Logs.TryDequeue(out var log)) { 17 | switch (log.Type) { 18 | case LogType.Warning: 19 | cmdlet.WriteWarning(log.Message); 20 | break; 21 | case LogType.Error: 22 | cmdlet.WriteError(new ErrorRecord(new Exception(log.Message), "SendGridError", ErrorCategory.NotSpecified, null)); 23 | break; 24 | case LogType.Verbose: 25 | cmdlet.WriteVerbose(log.Message); 26 | break; 27 | case LogType.Information: 28 | cmdlet.WriteInformation(log.Message, new string[0]); 29 | break; 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr.PowerShell/CredentialHelpers.cs: -------------------------------------------------------------------------------- 1 | namespace Mailozaurr.PowerShell; 2 | 3 | using System.Security; 4 | using System.Net; 5 | 6 | /// 7 | /// Helper class for converting strings to SecureString. 8 | /// 9 | public static class CredentialHelpers { 10 | /// 11 | /// Converts a string to a SecureString. 12 | /// 13 | /// 14 | /// 15 | public static SecureString ToSecureString(string s) { 16 | if (string.IsNullOrEmpty(s)) 17 | return new SecureString(); 18 | // Try to convert from encrypted string, fallback to plain text 19 | try { 20 | return new NetworkCredential("", s).SecurePassword; 21 | } catch { 22 | var ss = new SecureString(); 23 | foreach (char c in s) ss.AppendChar(c); 24 | ss.MakeReadOnly(); 25 | return ss; 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr.PowerShell/Definitions/EmlConversionResult.cs: -------------------------------------------------------------------------------- 1 | namespace Mailozaurr.PowerShell; 2 | 3 | /// 4 | /// Eml conversion result 5 | /// 6 | public class EmlConversionResult { 7 | /// 8 | /// Eml file path to file that was converted 9 | /// 10 | public string EmlFile { get; set; } 11 | /// 12 | /// Msg file path to file that was created 13 | /// 14 | public string MsgFile { get; set; } 15 | /// 16 | /// Status of the conversion 17 | /// 18 | public bool Status { get; set; } 19 | /// 20 | /// Error message if conversion failed 21 | /// 22 | public string Error { get; set; } 23 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr.PowerShell/Definitions/ImapConnectionInfo.cs: -------------------------------------------------------------------------------- 1 | using MailKit.Net.Imap; 2 | 3 | namespace Mailozaurr.PowerShell; 4 | 5 | /// 6 | /// Represents the result of a successful IMAP connection, including the client and connection details. 7 | /// 8 | public class ImapConnectionInfo { 9 | /// IMAP server URI. 10 | public string Uri { get; set; } 11 | /// Authentication mechanisms supported by the server. 12 | public object AuthenticationMechanisms { get; set; } 13 | /// Server capabilities. 14 | public object Capabilities { get; set; } 15 | /// The underlying stream. 16 | public object Stream { get; set; } 17 | /// Current state of the connection. 18 | public object State { get; set; } 19 | /// Whether the client is connected. 20 | public bool IsConnected { get; set; } 21 | /// APOP token, if any. 22 | public object ApopToken { get; set; } 23 | /// Expire policy. 24 | public object ExpirePolicy { get; set; } 25 | /// Server implementation info. 26 | public object Implementation { get; set; } 27 | /// Login delay, if any. 28 | public object LoginDelay { get; set; } 29 | /// Whether the client is authenticated. 30 | public bool IsAuthenticated { get; set; } 31 | /// Whether the connection is secure. 32 | public bool IsSecure { get; set; } 33 | /// The actual MailKit ImapClient instance. 34 | public ImapClient Data { get; set; } 35 | /// Message count. 36 | public int Count { get; set; } 37 | /// Messages collection (if available). 38 | public object Messages { get; set; } 39 | /// Recent message count. 40 | public int Recent { get; set; } 41 | /// 42 | /// IMAP folder. 43 | /// 44 | public ImapFolder Folder { get; set; } 45 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr.PowerShell/Definitions/PopConnectionInfo.cs: -------------------------------------------------------------------------------- 1 | using MailKit.Net.Pop3; 2 | 3 | namespace Mailozaurr.PowerShell; 4 | 5 | /// 6 | /// Represents the result of a successful POP3 connection, including the client and connection details. 7 | /// 8 | public class PopConnectionInfo 9 | { 10 | /// POP3 server URI. 11 | public string Uri { get; set; } 12 | /// Authentication mechanisms supported by the server. 13 | public object AuthenticationMechanisms { get; set; } 14 | /// Server capabilities. 15 | public object Capabilities { get; set; } 16 | /// The underlying stream. 17 | public object Stream { get; set; } 18 | /// Current state of the connection. 19 | public object State { get; set; } 20 | /// Whether the client is connected. 21 | public bool IsConnected { get; set; } 22 | /// APOP token, if any. 23 | public object ApopToken { get; set; } 24 | /// Expire policy. 25 | public object ExpirePolicy { get; set; } 26 | /// Server implementation info. 27 | public object Implementation { get; set; } 28 | /// Login delay, if any. 29 | public object LoginDelay { get; set; } 30 | /// Whether the client is authenticated. 31 | public bool IsAuthenticated { get; set; } 32 | /// Whether the connection is secure. 33 | public bool IsSecure { get; set; } 34 | /// The actual MailKit Pop3Client instance. 35 | public Pop3Client Data { get; set; } 36 | /// Message count. 37 | public int Count { get; set; } 38 | /// Messages collection (if available). 39 | public object Messages { get; set; } 40 | /// Recent message count. 41 | public int Recent { get; set; } 42 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr.PowerShell/Mailozaurr.PowerShell.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Evotec 5 | Przemyslaw Klys 6 | 2.0.0 7 | net472;netstandard2.0;net8.0 8 | Mailozaurr.PowerShell 9 | enable 10 | (c) 2011 - 2024 Przemyslaw Klys @ Evotec. All rights reserved. 11 | latest 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | true 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | true 52 | 53 | 54 | 55 | 56 | 57 | all 58 | runtime; build; native; contentfiles; analyzers; buildtransitive 59 | 60 | 61 | -------------------------------------------------------------------------------- /Sources/Mailozaurr.PowerShell/Mailozaurr.PowerShell.csproj.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | True 3 | True -------------------------------------------------------------------------------- /Sources/Mailozaurr.PowerShell/OnImportAndRemove.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Reflection; 3 | 4 | /// 5 | /// OnModuleImportAndRemove is a class that implements the IModuleAssemblyInitializer and IModuleAssemblyCleanup interfaces. 6 | /// This class is used to handle the assembly resolve event when the module is imported and removed. 7 | /// 8 | public class OnModuleImportAndRemove : IModuleAssemblyInitializer, IModuleAssemblyCleanup { 9 | /// 10 | /// OnImport is called when the module is imported. 11 | /// 12 | public void OnImport() { 13 | if (IsNetFramework()) { 14 | AppDomain.CurrentDomain.AssemblyResolve += MyResolveEventHandler; 15 | } 16 | } 17 | 18 | /// 19 | /// OnRemove is called when the module is removed. 20 | /// 21 | /// 22 | public void OnRemove(PSModuleInfo module) { 23 | if (IsNetFramework()) { 24 | AppDomain.CurrentDomain.AssemblyResolve -= MyResolveEventHandler; 25 | } 26 | } 27 | 28 | /// 29 | /// MyResolveEventHandler is a method that handles the AssemblyResolve event. 30 | /// 31 | /// 32 | /// 33 | /// 34 | private static Assembly MyResolveEventHandler(object sender, ResolveEventArgs args) { 35 | var libDirectory = Path.GetDirectoryName(typeof(OnModuleImportAndRemove).Assembly.Location); 36 | var directoriesToSearch = new List { libDirectory }; 37 | 38 | if (Directory.Exists(libDirectory)) { 39 | directoriesToSearch.AddRange(Directory.GetDirectories(libDirectory, "*", SearchOption.AllDirectories)); 40 | } 41 | 42 | var requestedAssemblyName = new AssemblyName(args.Name).Name + ".dll"; 43 | 44 | foreach (var directory in directoriesToSearch) { 45 | var assemblyPath = Path.Combine(directory, requestedAssemblyName); 46 | 47 | if (File.Exists(assemblyPath)) { 48 | try { 49 | return Assembly.LoadFrom(assemblyPath); 50 | } catch (Exception ex) { 51 | Console.WriteLine($"Failed to load assembly from {assemblyPath}: {ex.Message}"); 52 | } 53 | } 54 | } 55 | 56 | return null; 57 | } 58 | 59 | /// 60 | /// Determine if the current runtime is .NET Framework 61 | /// 62 | /// 63 | private bool IsNetFramework() { 64 | return System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework", StringComparison.OrdinalIgnoreCase); 65 | } 66 | 67 | // Determine if the current runtime is .NET Core 68 | private bool IsNetCore() { 69 | return System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription.StartsWith(".NET Core", StringComparison.OrdinalIgnoreCase); 70 | } 71 | 72 | /// 73 | /// Determine if the current runtime is .NET 5 or higher 74 | /// 75 | /// 76 | private bool IsNet5OrHigher() { 77 | return System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription.StartsWith(".NET 5", StringComparison.OrdinalIgnoreCase) || 78 | System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription.StartsWith(".NET 6", StringComparison.OrdinalIgnoreCase) || 79 | System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription.StartsWith(".NET 7", StringComparison.OrdinalIgnoreCase) || 80 | System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription.StartsWith(".NET 8", StringComparison.OrdinalIgnoreCase) || 81 | System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription.StartsWith(".NET 9", StringComparison.OrdinalIgnoreCase); 82 | } 83 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.3.32804.467 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mailozaurr.PowerShell", "Mailozaurr.PowerShell\Mailozaurr.PowerShell.csproj", "{EEF3BFAD-C8A5-474C-BA52-5C20E66EF0F9}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {74FF5540-DB31-4031-BBE1-1A471A17CCFC} = {74FF5540-DB31-4031-BBE1-1A471A17CCFC} 9 | EndProjectSection 10 | EndProject 11 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mailozaurr.Examples", "Mailozaurr.Examples\Mailozaurr.Examples.csproj", "{FC455BBE-52F1-4FD3-AC16-F76172C9AAD2}" 12 | ProjectSection(ProjectDependencies) = postProject 13 | {74FF5540-DB31-4031-BBE1-1A471A17CCFC} = {74FF5540-DB31-4031-BBE1-1A471A17CCFC} 14 | EndProjectSection 15 | EndProject 16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mailozaurr", "Mailozaurr\Mailozaurr.csproj", "{74FF5540-DB31-4031-BBE1-1A471A17CCFC}" 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 20 | Debug|Any CPU = Debug|Any CPU 21 | Release|Any CPU = Release|Any CPU 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {EEF3BFAD-C8A5-474C-BA52-5C20E66EF0F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {EEF3BFAD-C8A5-474C-BA52-5C20E66EF0F9}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {EEF3BFAD-C8A5-474C-BA52-5C20E66EF0F9}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {EEF3BFAD-C8A5-474C-BA52-5C20E66EF0F9}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {FC455BBE-52F1-4FD3-AC16-F76172C9AAD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {FC455BBE-52F1-4FD3-AC16-F76172C9AAD2}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {FC455BBE-52F1-4FD3-AC16-F76172C9AAD2}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {FC455BBE-52F1-4FD3-AC16-F76172C9AAD2}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {74FF5540-DB31-4031-BBE1-1A471A17CCFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {74FF5540-DB31-4031-BBE1-1A471A17CCFC}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {74FF5540-DB31-4031-BBE1-1A471A17CCFC}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {74FF5540-DB31-4031-BBE1-1A471A17CCFC}.Release|Any CPU.Build.0 = Release|Any CPU 36 | EndGlobalSection 37 | GlobalSection(SolutionProperties) = preSolution 38 | HideSolutionNode = FALSE 39 | EndGlobalSection 40 | GlobalSection(ExtensibilityGlobals) = postSolution 41 | SolutionGuid = {F37BB785-3AB1-4498-8102-689C0E4C3924} 42 | EndGlobalSection 43 | EndGlobal 44 | -------------------------------------------------------------------------------- /Sources/Mailozaurr.sln.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | True 3 | True -------------------------------------------------------------------------------- /Sources/Mailozaurr/Authentication/OAuthHelpers.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Identity.Client; 2 | using Google.Apis.Auth.OAuth2; 3 | using Google.Apis.Auth.OAuth2.Flows; 4 | using Google.Apis.Util.Store; 5 | 6 | namespace Mailozaurr; 7 | 8 | public static class OAuthHelpers { 9 | public static async Task AcquireO365TokenInteractiveAsync( 10 | string login, 11 | string clientId, 12 | string tenantId, 13 | string redirectUri, 14 | IEnumerable scopes) { 15 | var options = new PublicClientApplicationOptions { 16 | ClientId = clientId, 17 | TenantId = tenantId, 18 | RedirectUri = redirectUri 19 | }; 20 | var app = PublicClientApplicationBuilder.CreateWithApplicationOptions(options).Build(); 21 | AuthenticationResult result; 22 | if (!string.IsNullOrEmpty(login)) { 23 | result = await app.AcquireTokenInteractive(scopes) 24 | .WithLoginHint(login) 25 | .ExecuteAsync(); 26 | } else { 27 | result = await app.AcquireTokenInteractive(scopes) 28 | .ExecuteAsync(); 29 | } 30 | return new OAuthCredential { 31 | UserName = result.Account.Username, 32 | AccessToken = result.AccessToken 33 | }; 34 | } 35 | 36 | public static async Task AcquireGoogleTokenInteractiveAsync( 37 | string gmailAccount, 38 | string clientId, 39 | string clientSecret, 40 | IEnumerable scopes) { 41 | var clientSecrets = new ClientSecrets { 42 | ClientId = clientId, 43 | ClientSecret = clientSecret 44 | }; 45 | var initializer = new GoogleAuthorizationCodeFlow.Initializer { 46 | ClientSecrets = clientSecrets, 47 | Scopes = scopes, 48 | DataStore = new FileDataStore("CredentialCacheFolder", false) 49 | }; 50 | var codeFlow = new GoogleAuthorizationCodeFlow(initializer); 51 | var codeReceiver = new LocalServerCodeReceiver(); 52 | var authCode = new AuthorizationCodeInstalledApp(codeFlow, codeReceiver); 53 | var credential = await authCode.AuthorizeAsync(gmailAccount, System.Threading.CancellationToken.None); 54 | if (credential.Token.IsExpired(Google.Apis.Util.SystemClock.Default)) { 55 | await credential.RefreshTokenAsync(System.Threading.CancellationToken.None); 56 | } 57 | return new OAuthCredential { 58 | UserName = credential.UserId, 59 | AccessToken = credential.Token.AccessToken 60 | }; 61 | } 62 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr/Authentication/SaslMechanismNtlmIntegrated.cs: -------------------------------------------------------------------------------- 1 | using NSspi; 2 | using NSspi.Contexts; 3 | using NSspi.Credentials; 4 | 5 | namespace Mailozaurr { 6 | /// 7 | /// The NTLM Integrated Auth SASL mechanism. 8 | /// 9 | /// 10 | /// A SASL mechanism based on NTLM using the credentials of the current user 11 | /// via Windows Integrated Authentication (SSPI). 12 | /// 13 | /// 14 | public class SaslMechanismNtlmIntegrated : SaslMechanism { 15 | enum LoginState { 16 | Initial, 17 | Challenge 18 | } 19 | 20 | LoginState state; 21 | ClientContext sspiContext; 22 | 23 | /// 24 | /// Initializes a new instance of the class. 25 | /// 26 | /// 27 | /// Creates a new NTLM Integrated Auth SASL context. 28 | /// 29 | public SaslMechanismNtlmIntegrated() : base(string.Empty, string.Empty) { 30 | } 31 | 32 | /// 33 | public override string MechanismName => "NTLM"; 34 | 35 | /// 36 | public override bool SupportsInitialResponse => true; 37 | 38 | /// 39 | /// The authenticated user name. 40 | /// 41 | public virtual string AuthenticatedUserName => sspiContext.ContextUserName; 42 | 43 | /// 44 | /// 45 | /// The SASL mechanism is already authenticated. 46 | /// 47 | protected override byte[] Challenge(byte[] token, int startIndex, int length, CancellationToken cancellationToken) { 48 | cancellationToken.ThrowIfCancellationRequested(); 49 | 50 | if (IsAuthenticated) { 51 | throw new InvalidOperationException(); 52 | } 53 | 54 | InitializeSSPIContext(); 55 | 56 | byte[] serverResponse; 57 | 58 | if (state == LoginState.Initial) { 59 | sspiContext.Init(null, out serverResponse); 60 | state = LoginState.Challenge; 61 | } else { 62 | sspiContext.Init(token, out serverResponse); 63 | IsAuthenticated = true; 64 | } 65 | 66 | return serverResponse; 67 | } 68 | 69 | private void InitializeSSPIContext() { 70 | if (sspiContext != null) { 71 | return; 72 | } 73 | 74 | var credential = new ClientCurrentCredential(PackageNames.Ntlm); 75 | 76 | sspiContext = new ClientContext( 77 | credential, 78 | string.Empty, 79 | ContextAttrib.InitIntegrity 80 | | ContextAttrib.ReplayDetect 81 | | ContextAttrib.SequenceDetect 82 | | ContextAttrib.Confidentiality); 83 | } 84 | 85 | 86 | public override void Reset() { 87 | state = LoginState.Initial; 88 | base.Reset(); 89 | } 90 | } 91 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr/Definitions/EmlConversionResult.cs: -------------------------------------------------------------------------------- 1 | namespace Mailozaurr; 2 | 3 | /// 4 | /// Eml conversion result 5 | /// 6 | public class EmlConversionResult { 7 | /// 8 | /// Eml file path to file that was converted 9 | /// 10 | public string EmlFile { get; set; } 11 | /// 12 | /// Msg file path to file that was created 13 | /// 14 | public string MsgFile { get; set; } 15 | /// 16 | /// Status of the conversion 17 | /// 18 | public bool Status { get; set; } 19 | /// 20 | /// Error message if conversion failed 21 | /// 22 | public string Error { get; set; } 23 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr/Definitions/OAuthCredential.cs: -------------------------------------------------------------------------------- 1 | namespace Mailozaurr; 2 | 3 | /// 4 | /// Represents OAuth credentials. 5 | /// 6 | public class OAuthCredential { 7 | /// 8 | /// The username associated with the OAuth credential. 9 | /// 10 | public string UserName { get; set; } 11 | /// 12 | /// The access token for the OAuth credential. 13 | /// 14 | public string AccessToken { get; set; } 15 | } 16 | -------------------------------------------------------------------------------- /Sources/Mailozaurr/Definitions/ValidatedEmail.cs: -------------------------------------------------------------------------------- 1 | using EmailValidation; 2 | 3 | namespace Mailozaurr; 4 | 5 | /// 6 | /// Validated email class 7 | /// 8 | public class ValidatedEmail { 9 | /// 10 | /// Email address 11 | /// 12 | /// 13 | /// The email address. 14 | /// 15 | public string EmailAddress { get; set; } = string.Empty; 16 | 17 | /// 18 | /// Returns true if email address is valid. 19 | /// 20 | /// 21 | /// true if this instance is valid; otherwise, false. 22 | /// 23 | public bool IsValid { get; set; } 24 | 25 | /// 26 | /// Indicates if the email address is disposable 27 | /// 28 | /// 29 | /// true if email address is disposable; otherwise, false. 30 | /// 31 | public bool IsDisposable { get; set; } 32 | 33 | /// 34 | /// Indicates why email address is invalid (if it is) 35 | /// 36 | public EmailValidationErrorCode Reason { get; set; } 37 | 38 | /// 39 | /// Indicates the index of the token that caused the email address to be invalid 40 | /// 41 | public int? ReasonTokenIndex { get; set; } 42 | 43 | /// 44 | /// Indicates the index of the error that caused the email address to be invalid 45 | /// 46 | public int? ReasonErrorIndex { get; set; } 47 | 48 | /// 49 | /// If error during validation happens, this will contain the error message 50 | /// 51 | /// 52 | /// The error. 53 | /// 54 | public string Error { get; set; } = string.Empty; 55 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr/EmailMessage.cs: -------------------------------------------------------------------------------- 1 | using MsgKit; 2 | 3 | namespace Mailozaurr; 4 | 5 | public static class EmailMessage { 6 | public static IEnumerable ConvertEmlToMsg(string[] emlFile, string outputFolder, bool force) { 7 | LoggingMessages.Logger.WriteVerbose($"Converting {emlFile.Length} EML file(s) to MSG file(s)..."); 8 | foreach (var eml in emlFile) { 9 | var fileName = Path.GetFileNameWithoutExtension(eml); 10 | var targetFile = Path.Combine(outputFolder, $"{fileName}.msg"); 11 | var msg = ConvertEmlToMsg(new FileInfo(eml), new FileInfo(targetFile), force); 12 | yield return msg; 13 | } 14 | } 15 | 16 | public static EmlConversionResult ConvertEmlToMsg(FileInfo emlFile, FileInfo msgFile, bool force) { 17 | if (File.Exists(emlFile.FullName)) { 18 | LoggingMessages.Logger.WriteVerbose("Processing EML file: {0}", emlFile); 19 | try { 20 | if (File.Exists(msgFile.FullName) && !force) { 21 | LoggingMessages.Logger.WriteWarning("MSG file already exists: {0}", msgFile); 22 | return new EmlConversionResult() { EmlFile = emlFile.FullName, MsgFile = msgFile.FullName, Status = false, Error = "MSG file already exists" }; 23 | } else { 24 | if (File.Exists(msgFile.FullName)) { 25 | LoggingMessages.Logger.WriteVerbose("Removing existing MSG file: {0}", msgFile); 26 | File.Delete(msgFile.FullName); 27 | } 28 | Converter.ConvertEmlToMsg(emlFile.FullName, msgFile.FullName); 29 | return new EmlConversionResult() { EmlFile = emlFile.FullName, MsgFile = msgFile.FullName, Status = true }; 30 | } 31 | } catch (Exception ex) { 32 | LoggingMessages.Logger.WriteWarning("Error converting EML to MSG: {0}", ex.Message); 33 | return new EmlConversionResult() { EmlFile = emlFile.FullName, MsgFile = msgFile.FullName, Status = false, Error = ex.Message }; 34 | } 35 | } 36 | return new EmlConversionResult() { EmlFile = emlFile.FullName, MsgFile = msgFile.FullName, Status = false, Error = "EML file does not exist" }; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Sources/Mailozaurr/Enums/ActionPreference.cs: -------------------------------------------------------------------------------- 1 | namespace Mailozaurr; 2 | 3 | public enum ActionPreference { 4 | Stop, 5 | Continue, 6 | Inquire, 7 | SilentlyContinue, 8 | Suspend 9 | } 10 | -------------------------------------------------------------------------------- /Sources/Mailozaurr/Enums/DeliveryNotification.cs: -------------------------------------------------------------------------------- 1 | namespace Mailozaurr; 2 | 3 | public enum DeliveryNotification { 4 | None, 5 | Delay, 6 | Never, 7 | OnFailure, 8 | OnSuccess, 9 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr/Enums/EmailAction.cs: -------------------------------------------------------------------------------- 1 | namespace Mailozaurr; 2 | 3 | public enum EmailAction { 4 | Authenticate, 5 | Connect, 6 | SMimeSignature, 7 | SMimeSignaturePKCS7, 8 | SMimeEncrypt, 9 | SMimeSignAndEncrypt, 10 | PgpSign, 11 | PgpEncrypt, 12 | Send, 13 | SendDraftMessage, 14 | SendAttachment 15 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr/Enums/EmailActionEncryption.cs: -------------------------------------------------------------------------------- 1 | namespace Mailozaurr; 2 | 3 | public enum EmailActionEncryption { 4 | None, 5 | SMIMESign, 6 | SMIMESignPkcs7, 7 | SMIMEEncrypt, 8 | SMIMESignAndEncrypt, 9 | } 10 | -------------------------------------------------------------------------------- /Sources/Mailozaurr/Enums/EmailProvider.cs: -------------------------------------------------------------------------------- 1 | namespace Mailozaurr; 2 | public enum EmailProvider { 3 | None, 4 | SendGrid, 5 | Mailgun, 6 | //MailChimp, 7 | //AmazonSES, 8 | //Moosend, 9 | //Postmark, 10 | //Brevo (Sendinblue), 11 | //MessageBird (SparkPost), 12 | //MailerSend 13 | } 14 | -------------------------------------------------------------------------------- /Sources/Mailozaurr/Enums/MessagePriority.cs: -------------------------------------------------------------------------------- 1 | namespace Mailozaurr; 2 | 3 | public enum MessagePriority { 4 | High, 5 | Low, 6 | Normal 7 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr/Helpers/Helpers.cs: -------------------------------------------------------------------------------- 1 | using System.Net; 2 | using System.Security; 3 | 4 | namespace Mailozaurr; 5 | 6 | public static class Helpers { 7 | public static (string UserName, string Token) ConvertFromOAuth2Credential(NetworkCredential credential) { 8 | return (credential.UserName, credential.Password); 9 | } 10 | 11 | public static NetworkCredential ConvertFromPlainText(string userName, string password) { 12 | var secStringPassword = new SecureString(); 13 | foreach (char c in password) { 14 | secStringPassword.AppendChar(c); 15 | } 16 | return new NetworkCredential(userName, secStringPassword); 17 | } 18 | 19 | public static string CredentialToApiKey(ICredentials credentials) { 20 | string apiKey; 21 | try { 22 | var networkCredential = credentials as NetworkCredential; 23 | apiKey = networkCredential.Password; 24 | } catch (Exception ex) { 25 | apiKey = ""; 26 | } 27 | return apiKey; 28 | } 29 | 30 | public static string GetEmailAddress(object from) { 31 | if (from is string s) { 32 | return s; 33 | } 34 | if (from is IDictionary dict && dict.ContainsKey("Email")) { 35 | return dict["Email"]?.ToString(); 36 | } 37 | return from?.ToString() ?? string.Empty; 38 | } 39 | 40 | public static object GetFromObject(string email, string name) { 41 | if (!string.IsNullOrEmpty(name)) { 42 | return new Dictionary { { "Name", name }, { "Email", email } }; 43 | } 44 | return email; 45 | } 46 | 47 | public static (string Email, string? Name) GetEmailAndName(object from) { 48 | if (from is string s) { 49 | return (s, null); 50 | } 51 | if (from is IDictionary dict) { 52 | var email = dict.Contains("Email") ? dict["Email"]?.ToString() : null; 53 | var name = dict.Contains("Name") ? dict["Name"]?.ToString() : null; 54 | return (email, name); 55 | } 56 | return (from?.ToString(), null); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Sources/Mailozaurr/Imap.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Mailozaurr; 8 | internal class Imap { 9 | } 10 | -------------------------------------------------------------------------------- /Sources/Mailozaurr/Logging/LogCollector.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Concurrent; 2 | 3 | namespace Mailozaurr; 4 | 5 | /// 6 | /// Collects log entries in a thread-safe queue for later emission by PowerShell cmdlets. 7 | /// Intended for use in client classes (e.g., SendGridClient) to decouple logging from cmdlet pipeline output. 8 | /// 9 | public class LogCollector { 10 | /// 11 | /// The thread-safe queue of log entries. 12 | /// 13 | public ConcurrentQueue Logs { get; } = new(); 14 | 15 | /// Adds a warning log entry. 16 | public void LogWarning(string message) => Logs.Enqueue(new LogEntry { Message = message, Type = LogType.Warning }); 17 | /// Adds an error log entry. 18 | public void LogError(string message) => Logs.Enqueue(new LogEntry { Message = message, Type = LogType.Error }); 19 | /// Adds a verbose log entry. 20 | public void LogVerbose(string message) => Logs.Enqueue(new LogEntry { Message = message, Type = LogType.Verbose }); 21 | /// Adds an informational log entry. 22 | public void LogInformation(string message) => Logs.Enqueue(new LogEntry { Message = message, Type = LogType.Information }); 23 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr/Logging/LogEntry.cs: -------------------------------------------------------------------------------- 1 | namespace Mailozaurr; 2 | 3 | /// 4 | /// Represents the type of a log entry for use in cmdlet and client logging. 5 | /// 6 | public enum LogType { 7 | /// A warning message. 8 | Warning, 9 | /// An error message. 10 | Error, 11 | /// A verbose message. 12 | Verbose, 13 | /// An informational message. 14 | Information 15 | } 16 | 17 | /// 18 | /// Represents a single log entry, including its message and type. 19 | /// Used to collect logs in client classes and emit them in cmdlets. 20 | /// 21 | public class LogEntry { 22 | /// The log message. 23 | public string Message { get; set; } 24 | /// The type of log (warning, error, etc.). 25 | public LogType Type { get; set; } 26 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr/Logging/LoggingConfigurator.cs: -------------------------------------------------------------------------------- 1 | namespace Mailozaurr; 2 | 3 | public class LoggingConfigurator { 4 | public MemoryStream? LogStream { get; private set; } 5 | public bool LogConsole { get; private set; } 6 | public bool LogObject { get; private set; } 7 | public bool LogTimestamps { get; private set; } 8 | public bool LogSecrets { get; private set; } 9 | public string? LogTimestampsFormat { get; private set; } 10 | public string? LogServerPrefix { get; private set; } 11 | public string? LogClientPrefix { get; private set; } 12 | public bool LogOverwrite { get; private set; } 13 | public string? LogPath { get; private set; } 14 | internal ProtocolLogger? ProtocolLogger { get; set; } 15 | 16 | public void ConfigureLogging(string logPath, bool logConsole, bool logObject, bool logTimestamps, bool logSecrets, string? logTimestampsFormat = null, string? logServerPrefix = null, string? logClientPrefix = null, bool logOverwrite = false) { 17 | LogTimestamps = logTimestamps; 18 | LogSecrets = logSecrets; 19 | LogTimestampsFormat = logTimestampsFormat; 20 | LogServerPrefix = logServerPrefix; 21 | LogClientPrefix = logClientPrefix; 22 | LogOverwrite = logOverwrite; 23 | LogObject = logObject; 24 | LogConsole = logConsole; 25 | LogPath = logPath; 26 | 27 | ProtocolLogger? protocolLogger = null; 28 | if (!string.IsNullOrEmpty(logPath) || logConsole || logObject) { 29 | if (!string.IsNullOrEmpty(logPath)) { 30 | try { 31 | protocolLogger = new ProtocolLogger(logPath, logOverwrite); 32 | } catch { 33 | //Console.WriteLine($"Couldn't create protocol logger with {logPath}. Using console output instead."); 34 | // TODO: add logging 35 | protocolLogger = new ProtocolLogger(Console.OpenStandardOutput()); 36 | } 37 | } else if (logConsole) { 38 | protocolLogger = new ProtocolLogger(Console.OpenStandardOutput()); 39 | } else { 40 | LogStream = new MemoryStream(); 41 | protocolLogger = new ProtocolLogger(LogStream); 42 | } 43 | 44 | protocolLogger.LogTimestamps = logTimestamps; 45 | protocolLogger.RedactSecrets = !logSecrets; 46 | 47 | if (!string.IsNullOrEmpty(logTimestampsFormat)) { 48 | protocolLogger.TimestampFormat = logTimestampsFormat; 49 | } 50 | 51 | if (!string.IsNullOrEmpty(logServerPrefix)) { 52 | protocolLogger.ServerPrefix = logServerPrefix; 53 | } 54 | 55 | if (!string.IsNullOrEmpty(logClientPrefix)) { 56 | protocolLogger.ClientPrefix = logClientPrefix; 57 | } 58 | } 59 | ProtocolLogger = protocolLogger; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Sources/Mailozaurr/Logging/LoggingMessages.cs: -------------------------------------------------------------------------------- 1 | namespace Mailozaurr; 2 | 3 | public class LoggingMessages { 4 | public static InternalLogger Logger = new InternalLogger(); 5 | 6 | public static bool Error { 7 | get => Logger.IsError; 8 | set => Logger.IsError = value; 9 | } 10 | 11 | public static bool Verbose { 12 | get => Logger.IsVerbose; 13 | set => Logger.IsVerbose = value; 14 | } 15 | 16 | public static bool Warning { 17 | get => Logger.IsWarning; 18 | set => Logger.IsWarning = value; 19 | } 20 | 21 | public static bool Progress { 22 | get => Logger.IsProgress; 23 | set => Logger.IsProgress = value; 24 | } 25 | 26 | public static bool Debug { 27 | get => Logger.IsDebug; 28 | set => Logger.IsDebug = value; 29 | } 30 | 31 | internal static object _LockObject = new object(); 32 | } 33 | -------------------------------------------------------------------------------- /Sources/Mailozaurr/Mailgun/Mailgun.cs: -------------------------------------------------------------------------------- 1 | namespace Mailozaurr; 2 | 3 | public class MailgunClient : IDisposable { 4 | private readonly HttpClient _client; 5 | 6 | /// 7 | /// Gets the API key used for authentication with the Mailgun API. 8 | /// 9 | private string _apiKey => Helpers.CredentialToApiKey(Credentials); 10 | 11 | /// 12 | /// Gets or sets the domain of the email address. 13 | /// 14 | private string EmailDomain { 15 | get { 16 | //var emailInformation = From.Split("@"); 17 | //return emailInformation[1]; 18 | // TODO - Implement this 19 | return ""; 20 | } 21 | } 22 | 23 | /// 24 | /// Gets or sets the credentials used for authentication with the Mailgun API. 25 | /// 26 | public ICredentials Credentials { get; set; } 27 | 28 | /// 29 | /// Gets or sets the action to take when an error occurs. 30 | /// 31 | public ActionPreference? ErrorAction { get; set; } 32 | 33 | public object[]? Bcc { get; set; } 34 | public object[]? Cc { get; set; } 35 | public object From { get; set; } 36 | public object[]? To { get; set; } 37 | public string Subject { get; set; } 38 | public string BodyText { get; set; } 39 | public string BodyHtml { get; set; } 40 | 41 | 42 | public MailgunClient(ICredentials credentials, object from, object[] to, object[] cc, object[] bcc, string subject, string bodyText, string bodyHtml) { 43 | _client = new HttpClient(); 44 | Credentials = credentials; 45 | From = from; 46 | To = to; 47 | Subject = subject; 48 | BodyText = bodyText; 49 | BodyHtml = bodyHtml; 50 | } 51 | 52 | public async Task SendEmailAsync() { 53 | var url = $"https://api.mailgun.net/v3/{EmailDomain}/messages"; 54 | var idpass = $"api:{_apiKey}"; 55 | var basicauth = Convert.ToBase64String(Encoding.ASCII.GetBytes(idpass)); 56 | _client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", basicauth); 57 | 58 | var formData = new Dictionary { 59 | // TODO - Implement the rest of the form data 60 | //{ "from", From }, 61 | { "to", string.Join(",", To) }, 62 | { "subject", Subject }, 63 | { "text", BodyText }, 64 | { "html", BodyHtml } 65 | }; 66 | 67 | var content = new FormUrlEncodedContent(formData); 68 | var response = await _client.PostAsync(url, content); 69 | 70 | return response.IsSuccessStatusCode; 71 | } 72 | 73 | public void Dispose() { 74 | _client?.Dispose(); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Sources/Mailozaurr/Mailozaurr.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Evotec 5 | Przemyslaw Klys 6 | 2.0.0 7 | net472;netstandard2.0;net8.0;net9.0 8 | Mailozaurr 9 | (c) 2011 - 2024 Przemyslaw Klys @ Evotec. All rights reserved. 10 | latest 11 | enable 12 | enable 13 | true 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /Sources/Mailozaurr/Mailozaurr.csproj.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | True 3 | True 4 | True 5 | True 6 | True 7 | True 8 | True 9 | True 10 | True -------------------------------------------------------------------------------- /Sources/Mailozaurr/MicrosoftGraph/GraphAttachment.cs: -------------------------------------------------------------------------------- 1 | namespace Mailozaurr; 2 | 3 | public class GraphAttachmentPlaceHolder { 4 | public string Json { get; set; } 5 | public List Content { get; set; } 6 | public long FileSize { get; set; } 7 | public string FileName { get; set; } 8 | } 9 | 10 | public class GraphAttachmentItemWrapper { 11 | [JsonPropertyName("AttachmentItem")] 12 | public GraphAttachmentItem AttachmentItem { get; set; } 13 | 14 | public GraphAttachmentItemWrapper(GraphAttachmentItem attachmentItem) { 15 | AttachmentItem = attachmentItem; 16 | } 17 | } 18 | 19 | public class GraphAttachmentItem { 20 | [JsonPropertyName("attachmentType")] 21 | public string AttachmentType { get; set; } 22 | 23 | [JsonPropertyName("name")] 24 | public string Name { get; set; } 25 | 26 | [JsonPropertyName("size")] 27 | public long Size { get; set; } 28 | 29 | public GraphAttachmentItem(string attachmentType, string name, long size) { 30 | AttachmentType = attachmentType; 31 | Name = name; 32 | Size = size; 33 | } 34 | } 35 | 36 | public class GraphAttachment { 37 | [JsonPropertyName("@odata.type")] 38 | public string ODataType { get; set; } = "#microsoft.graph.fileAttachment"; 39 | 40 | [JsonPropertyName("name")] 41 | public string Name { get; set; } 42 | 43 | [JsonPropertyName("contentBytes")] 44 | public string ContentBytes { get; set; } 45 | 46 | public static GraphAttachment FromFile(string filePath) { 47 | var fileInfo = new FileInfo(filePath); 48 | var fileBytes = File.ReadAllBytes(filePath); 49 | var fileContentBase64 = Convert.ToBase64String(fileBytes); 50 | 51 | return new GraphAttachment { 52 | Name = fileInfo.Name, 53 | ContentBytes = fileContentBase64 54 | }; 55 | } 56 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr/MicrosoftGraph/GraphAuthorization.cs: -------------------------------------------------------------------------------- 1 | namespace Mailozaurr; 2 | 3 | public class GraphUploadSessionResult { 4 | [JsonPropertyName("uploadUrl")] 5 | public string UploadUrl { get; set; } 6 | } 7 | 8 | public class GraphAuthorization { 9 | [JsonPropertyName("token_type")] 10 | public string TokenType { get; set; } 11 | 12 | [JsonPropertyName("access_token")] 13 | public string AccessToken { get; set; } 14 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr/MicrosoftGraph/GraphErrors.cs: -------------------------------------------------------------------------------- 1 | namespace Mailozaurr; 2 | 3 | public class GraphApiError { 4 | [JsonPropertyName("error")] 5 | public GraphApiErrorDetail Error { get; set; } 6 | } 7 | 8 | public class GraphApiErrorDetail { 9 | [JsonPropertyName("code")] 10 | public string Code { get; set; } 11 | 12 | [JsonPropertyName("message")] 13 | public string Message { get; set; } 14 | 15 | [JsonPropertyName("innerError")] 16 | public GraphApiInnerError InnerError { get; set; } 17 | } 18 | 19 | public class GraphApiInnerError { 20 | [JsonPropertyName("request-id")] 21 | public string RequestId { get; set; } 22 | 23 | [JsonPropertyName("client-request-id")] 24 | public string ClientRequestId { get; set; } 25 | 26 | [JsonPropertyName("date")] 27 | public DateTime Date { get; set; } 28 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr/MicrosoftGraph/GraphMessage.cs: -------------------------------------------------------------------------------- 1 | namespace Mailozaurr; 2 | 3 | public class GraphMessageContainer { 4 | [JsonPropertyName("message")] 5 | public GraphMessage Message { get; set; } 6 | [JsonPropertyName("saveToSentItems")] 7 | public bool SaveToSentItems { get; set; } 8 | } 9 | 10 | public class GraphMessage { 11 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 12 | [JsonPropertyName("id")] 13 | public string Id { get; set; } 14 | [JsonPropertyName("from")] 15 | public GraphEmailAddress From { get; set; } 16 | 17 | [JsonPropertyName("toRecipients")] 18 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 19 | public List? To { get; set; } 20 | 21 | [JsonPropertyName("ccRecipients")] 22 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 23 | public List? Cc { get; set; } 24 | 25 | [JsonPropertyName("bccRecipients")] 26 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 27 | public List? Bcc { get; set; } 28 | 29 | [JsonPropertyName("replyTo")] 30 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 31 | public List? ReplyTo { get; set; } 32 | 33 | [JsonPropertyName("subject")] 34 | public string Subject { get; set; } 35 | 36 | [JsonPropertyName("body")] 37 | public GraphContent Body { get; set; } 38 | 39 | [JsonPropertyName("importance")] 40 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 41 | public string? Importance { get; set; } 42 | 43 | [JsonPropertyName("isReadReceiptRequested")] 44 | public bool IsReadReceiptRequested { get; set; } 45 | 46 | [JsonPropertyName("isDeliveryReceiptRequested")] 47 | public bool IsDeliveryReceiptRequested { get; set; } 48 | 49 | [JsonPropertyName("attachments")] 50 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 51 | public List? Attachments { get; set; } 52 | } 53 | 54 | public class GraphEmailAddress { 55 | [JsonPropertyName("emailAddress")] 56 | public GraphEmail Email { get; set; } 57 | } 58 | 59 | public class GraphEmail { 60 | [JsonPropertyName("address")] 61 | public string Address { get; set; } 62 | } 63 | 64 | public class GraphContent { 65 | [JsonPropertyName("contentType")] 66 | public string Type { get; set; } = "Text"; 67 | 68 | [JsonPropertyName("content")] 69 | public string Content { get; set; } = ""; 70 | } -------------------------------------------------------------------------------- /Sources/Mailozaurr/Pop.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Mailozaurr; 8 | internal class Pop { 9 | } 10 | -------------------------------------------------------------------------------- /Sources/Mailozaurr/README.md: -------------------------------------------------------------------------------- 1 | # Mailozaurr 2 | 3 | Mailozaurr is a powerful .NET library for sending emails using various providers (SMTP, SendGrid, Mailgun, Microsoft Graph, etc.), supporting advanced features like attachments, HTML bodies, and authentication. 4 | 5 | ## Features 6 | - Send emails via SMTP, SendGrid, Mailgun, Microsoft Graph, and more 7 | - Support for attachments, HTML, and plain text 8 | - OAuth2 and basic authentication 9 | - Delivery notifications and advanced options 10 | - Designed for integration in C# and PowerShell projects 11 | 12 | ## Installation 13 | 14 | Add a reference to the `Mailozaurr` project or its compiled DLL in your C# project: 15 | 16 | ``` 17 | // If using .csproj 18 | 19 | ``` 20 | Or, if you have the DLL: 21 | ``` 22 | // In your .csproj 23 | 24 | 25 | path/to/Mailozaurr.dll 26 | 27 | 28 | ``` 29 | 30 | ## Usage in C# 31 | 32 | ### Basic Example: Sending an Email via SMTP 33 | 34 | ```csharp 35 | using Mailozaurr; 36 | using MailKit.Security; 37 | 38 | var smtp = new Smtp(); 39 | smtp.From = "sender@example.com"; 40 | smtp.To = new[] { "recipient@example.com" }; 41 | smtp.Subject = "Test Email"; 42 | smtp.HtmlBody = "Hello from Mailozaurr!"; 43 | smtp.Server = "smtp.example.com"; 44 | smtp.Port = 587; 45 | smtp.SecureSocketOptions = SecureSocketOptions.StartTls; 46 | 47 | // Optional: authentication 48 | smtp.Authenticate("username", "password"); 49 | 50 | // Send the email 51 | var result = smtp.Send(); 52 | if (result.Status) 53 | { 54 | Console.WriteLine("Email sent successfully!"); 55 | } 56 | else 57 | { 58 | Console.WriteLine($"Failed: {result.ErrorMessage}"); 59 | } 60 | ``` 61 | 62 | ### Using Microsoft Graph 63 | 64 | ```csharp 65 | using Mailozaurr; 66 | 67 | var graph = new Graph(); 68 | graph.From = "sender@example.com"; 69 | graph.To = new[] { "recipient@example.com" }; 70 | graph.Subject = "Graph API Email"; 71 | graph.HTML = "

Sent via Microsoft Graph!

"; 72 | // ... set up authentication ... 73 | // graph.Authenticate(...); 74 | // graph.SendMessageAsync(); 75 | ``` 76 | 77 | ## Key Classes 78 | - `Smtp` - for SMTP email sending 79 | - `Graph` - for Microsoft Graph API 80 | - `SendGridClient` - for SendGrid 81 | - `MailgunClient` - for Mailgun 82 | - `SmtpResult` - result object for send operations 83 | 84 | ## Building from Source 85 | 86 | 1. Clone the repository 87 | 2. Open the solution in Visual Studio or run `dotnet build` in the root directory 88 | 3. Reference the built DLL in your project 89 | 90 | ## License 91 | 92 | (c) 2011 - 2024 Przemyslaw Klys @ Evotec. All rights reserved. 93 | 94 | --- 95 | 96 | *For more advanced usage, see the source code and examples in the repository.* -------------------------------------------------------------------------------- /Sources/Mailozaurr/SendGrid/SendGridMessage.cs: -------------------------------------------------------------------------------- 1 | namespace Mailozaurr; 2 | 3 | /// 4 | /// Represents a message to be sent using SendGrid. 5 | /// 6 | public class SendGridMessage { 7 | /// 8 | /// Gets or sets the list of personalizations for the message. 9 | /// 10 | public List Personalizations { get; set; } 11 | 12 | /// 13 | /// Gets or sets the sender of the message. 14 | /// 15 | public SendGridEmailAddress From { get; set; } 16 | 17 | /// 18 | /// Gets or sets the subject of the message. 19 | /// 20 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 21 | public string? Subject { get; set; } 22 | 23 | /// 24 | /// Gets or sets the content of the message. 25 | /// 26 | public List Content { get; set; } 27 | 28 | /// 29 | /// Gets or sets the reply-to address for the message. 30 | /// 31 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 32 | public SendGridEmailAddress? ReplyTo { get; set; } 33 | 34 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 35 | public List? Attachments { get; set; } 36 | } 37 | 38 | /// 39 | /// Represents an email address in a SendGrid message. 40 | /// 41 | public class SendGridEmailAddress { 42 | /// 43 | /// Gets or sets the email address. 44 | /// 45 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 46 | public string Email { get; set; } 47 | 48 | /// 49 | /// Gets or sets the name associated with the email address. 50 | /// 51 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 52 | public string? Name { get; set; } 53 | } 54 | 55 | /// 56 | /// Represents a personalization in a SendGrid message. 57 | /// 58 | public class SendGridPersonalization { 59 | /// 60 | /// Gets or sets the list of recipients for the message. 61 | /// 62 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 63 | public List? To { get; set; } 64 | 65 | /// 66 | /// Gets or sets the list of CC recipients for the message. 67 | /// 68 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 69 | public List? Cc { get; set; } 70 | 71 | /// 72 | /// Gets or sets the list of BCC recipients for the message. 73 | /// 74 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 75 | public List? Bcc { get; set; } 76 | } 77 | 78 | /// 79 | /// Represents the content of a SendGrid message. 80 | /// 81 | public class SendGridContent { 82 | /// 83 | /// Gets or sets the type of the content. 84 | /// 85 | public string? Type { get; set; } 86 | 87 | /// 88 | /// Gets or sets the value of the content. 89 | /// 90 | public string? Value { get; set; } 91 | } 92 | 93 | /// 94 | /// Represents an attachment in a SendGrid message. 95 | /// 96 | public class SendGridAttachment { 97 | /// 98 | /// Gets or sets the filename of the attachment. 99 | /// 100 | public string Filename { get; set; } 101 | 102 | /// 103 | /// Gets or sets the content of the attachment, encoded in Base64. 104 | /// 105 | public string Content { get; set; } 106 | 107 | /// 108 | /// Gets or sets the MIME type of the attachment. 109 | /// 110 | public string Type { get; set; } 111 | 112 | /// 113 | /// Gets or sets the disposition of the attachment. 114 | /// 115 | public string Disposition { get; set; } 116 | 117 | /// 118 | /// Initializes a new instance of the SendGridAttachment class with the specified file path. 119 | /// The file is read from the file system, and its content is converted to Base64. 120 | /// 121 | /// The path of the file to attach. 122 | public SendGridAttachment(string filePath) { 123 | Filename = Path.GetFileName(filePath); 124 | var bytes = File.ReadAllBytes(filePath); 125 | Content = Convert.ToBase64String(bytes); 126 | Type = "application/octet-stream"; // Update this if you have the MIME type 127 | Disposition = "attachment"; 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /Sources/Mailozaurr/Smtp/SmtpResult.cs: -------------------------------------------------------------------------------- 1 | namespace Mailozaurr; 2 | 3 | /// 4 | /// Class that holds the result of the SMTP operation 5 | /// 6 | public class SmtpResult { 7 | public bool Status { get; set; } 8 | public EmailAction EmailAction { get; set; } 9 | public string SentTo { get; set; } 10 | public string SentFrom { get; set; } 11 | public string? Message { get; set; } 12 | public TimeSpan TimeToExecute { get; set; } 13 | public string Server { get; set; } 14 | public int Port { get; set; } 15 | public string? Error { get; set; } 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// if set to true [status]. 20 | /// The email action. 21 | /// The sent to. 22 | /// The sent from. 23 | /// The server. 24 | /// The port. 25 | /// The time to execute. 26 | /// The output message. 27 | public SmtpResult(bool status, EmailAction emailAction, string sentTo, string sentFrom, string server, int port, TimeSpan timeToExecute, string? outputMessage = null, string? error = null) { 28 | Status = status; 29 | SentTo = sentTo; 30 | SentFrom = sentFrom; 31 | Server = server; 32 | Port = port; 33 | TimeToExecute = timeToExecute; 34 | Message = outputMessage; 35 | EmailAction = emailAction; 36 | Error = error; 37 | } 38 | 39 | /// 40 | /// Initializes a new instance of the class. 41 | /// 42 | /// if set to true [status]. 43 | /// The email action. 44 | /// The sent to. 45 | /// The sent from. 46 | /// The server. 47 | /// The port. 48 | /// The time to execute. 49 | /// The logging configurator. 50 | public SmtpResult(bool status, EmailAction emailAction, string sentTo, string sentFrom, string server, int port, TimeSpan timeToExecute, LoggingConfigurator? loggingConfigurator) { 51 | Status = status; 52 | SentTo = sentTo; 53 | SentFrom = sentFrom; 54 | Server = server; 55 | Port = port; 56 | TimeToExecute = timeToExecute; 57 | EmailAction = emailAction; 58 | 59 | if (loggingConfigurator?.ProtocolLogger != null && loggingConfigurator.LogObject) { 60 | Message = Encoding.ASCII.GetString(loggingConfigurator.LogStream?.ToArray() ?? Array.Empty()); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Sources/Mailozaurr/Smtp/SmtpSecureMime.cs: -------------------------------------------------------------------------------- 1 | //using System.Data.SQLite; 2 | 3 | //using MimeKit.Cryptography; 4 | 5 | //namespace Mailozaurr; 6 | //public class MySecureMimeContext : DefaultSecureMimeContext { 7 | // public static string DatabasePath { get; set; } = "C:\\Temp\\certdb.sqlite"; 8 | 9 | // public MySecureMimeContext() : base(OpenDatabase(DatabasePath)) { } 10 | 11 | // static IX509CertificateDatabase OpenDatabase(string fileName) { 12 | // var builder = new SQLiteConnectionStringBuilder(); 13 | // builder.DateTimeFormat = SQLiteDateFormats.Ticks; 14 | // builder.DataSource = fileName; 15 | 16 | // if (!File.Exists(fileName)) { 17 | // SQLiteConnection.CreateFile(fileName); 18 | // } 19 | 20 | // var sqlite = new SQLiteConnection(builder.ConnectionString); 21 | // sqlite.Open(); 22 | 23 | // return new SqliteCertificateDatabase(sqlite, "password"); 24 | // } 25 | //} 26 | -------------------------------------------------------------------------------- /Tests/Send-EmailMessage.Tests.ps1: -------------------------------------------------------------------------------- 1 | Describe 'Send-EmailMessage' { 2 | It 'Send email using given parameters (SMTP)' { 3 | $sendEmailMessageSplat = @{ 4 | From = @{ Name = 'Przemysław Kłys'; Email = 'test@evotec.pl' } 5 | To = 'testing@test.pl', 'test@gmail.com' 6 | Server = 'smtp.office365.com' 7 | HTML = $Body 8 | Text = $Text 9 | DeliveryNotificationOption = 'OnSuccess' 10 | Priority = 'High' 11 | Subject = 'This is another test email 🤣😍😒💖✨🎁 我' 12 | SecureSocketOptions = 'Auto' 13 | Password = 'TempPassword' 14 | WhatIf = $True 15 | } 16 | 17 | $Output = Send-EmailMessage @sendEmailMessageSplat -ErrorAction Stop 18 | $Output.Error | Should -Be 'Email not sent (WhatIf)' 19 | $Output.SentTo | Should -Be 'testing@test.pl, test@gmail.com' 20 | $Output.SentFrom.Email | Should -Be 'test@evotec.pl' 21 | $Output.SentFrom.Name | Should -Be 'Przemysław Kłys' 22 | $Output.Message | Should -Be $null 23 | $Output.Server | Should -Be 'smtp.office365.com' 24 | $Output.Port | Should -Be '587' 25 | $Output.Status | Should -Be $false 26 | } 27 | It 'Send email using given parameters (Graph)' { 28 | # Credentials for Graph 29 | $ClientID = '0fb383f1-8bfe' 30 | $DirectoryID = 'ceb371f6-8745' 31 | 32 | $EncryptedClientSecret = ConvertTo-SecureString -String 'VKDM_2.eC2US7pFW1' -AsPlainText -Force | ConvertFrom-SecureString 33 | 34 | $Credential = ConvertTo-GraphCredential -ClientID $ClientID -ClientSecretEncrypted $EncryptedClientSecret -DirectoryID $DirectoryID 35 | 36 | # sending email 37 | $sendEmailMessageSplat = @{ 38 | From = 'random@domain.pl' 39 | To = 'newemail@domain.pl' 40 | Credential = $Credential 41 | HTML = $Body 42 | Subject = 'This is another test email 2' 43 | Graph = $true 44 | Verbose = $true 45 | Priority = 'Low' 46 | DoNotSaveToSentItems = $true 47 | WhatIf = $true 48 | } 49 | $GraphOutput = Send-EmailMessage @sendEmailMessageSplat 50 | $GraphOutput.Error | Should -Be 'Email not sent (WhatIf)' 51 | $GraphOutput.SentTo | Should -Be 'newemail@domain.pl' 52 | $GraphOutput.SentFrom | Should -Be 'random@domain.pl' 53 | $GraphOutput.Message | Should -Be '' 54 | $GraphOutput.Status | Should -Be $False 55 | } 56 | It 'Send email using given parameters (SMTP no TLS, no login/password)' { 57 | $Output = Send-EmailMessage -From 'test@evotec.pl' -To 'mailozaurr@evotec.pl' -Server 'smtp.freesmtpservers.com' -Port 25 -Body 'test me 🤣😍😒💖✨🎁 Przemysław Kłys' -Subject '😒💖 This is another test email 我' -Verbose 58 | $Output.Error | Should -Be '' 59 | $Output.SentTo | Should -Be 'mailozaurr@evotec.pl' 60 | $Output.SentFrom | Should -Be 'test@evotec.pl' 61 | $Output.Message | Should -Be 'OK' 62 | $Output.Server | Should -Be 'smtp.freesmtpservers.com' 63 | $Output.Port | Should -Be 25 64 | $Output.Status | Should -Be $true 65 | } 66 | } --------------------------------------------------------------------------------