This PowerShell module is intended to provide a simple way for expiring email addresses. Ultimately this should reduce spam as mail addresses are only available for a certain amount of time.
- PowerShell 6.0 and later
- A mailbox with sieve support
- Support for the sieve extensions
envelope
andreject
-
Start a new PowerShell session
-
Install the module from the PSGallery using
Install-Module
orInstall-PSResource
PS> Install-PSResource DatedMail
- Initialize the module by providing a configuration. The default configuration is persisted at
$env::HOME/.config/DatedMail/DatedMailConfig.json
and must provide the email address where valid messages should be forwarded to, as well as the path to the sieve filter file.
PS> Initialize-DatedMailConfiguration -SieveFilterPath /home/marvin/users/temp/sieve/datedmail.filter -ForwardingEmailAddress marvin@example.org -MailAddressDomin "example.org" -MailAddressPrefix "temp+"
- Create a new expiring mail address. This will update the sieve filter and forward all mails received for the new address to the defined forwarding address. The created mail address will be available at the
ExportFilePath
to be used by other scripts. Alternatively it can also be returned to STDOUT.
PS> New-DatedMailAddress -ValidDays 7 -ExportFilePath $env:Home/DatedMail
- Create a timer to periodically call
Update-DatedMailAddress
(e.g. hourly). This will remove expired email addreses from the configuration and update the sieve filter accordingly. Thus mails for expired mail addresses will be rejected and bounced back to the sender with the error message550 Invalid or expired recipient address
. Make sure that the sieve filter specified by the script is the one active on the mailbox.