From a15cd9f64e8ffccb46682016e7c49066be04f35f Mon Sep 17 00:00:00 2001 From: Christian Pohle Date: Mon, 18 May 2020 09:55:09 +0200 Subject: [PATCH] Collect and send E-Mail Addresses to our SPAMProxy Host Collect E-Mail Addresses from your Domain with Powershell and send the file to our SPAMProxy Host --- Microsoft/Exchange/Mail-Gateways/README.MD | 2 ++ .../Mail-Gateways/eMailAddressDump.ps1 | 4 +++ .../Mail-Gateways/sendMailAddresses.cmd | 28 +++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 Microsoft/Exchange/Mail-Gateways/README.MD create mode 100644 Microsoft/Exchange/Mail-Gateways/eMailAddressDump.ps1 create mode 100644 Microsoft/Exchange/Mail-Gateways/sendMailAddresses.cmd diff --git a/Microsoft/Exchange/Mail-Gateways/README.MD b/Microsoft/Exchange/Mail-Gateways/README.MD new file mode 100644 index 0000000..6762435 --- /dev/null +++ b/Microsoft/Exchange/Mail-Gateways/README.MD @@ -0,0 +1,2 @@ +Script to collect E-Mail Addresses from your Domain with Powershell and send the file to our SPAMProxy Host +You have to create a contact in Exchange for spamproxy@DOMAIN.com that redirects the Mails to our SPAMProxy Address. \ No newline at end of file diff --git a/Microsoft/Exchange/Mail-Gateways/eMailAddressDump.ps1 b/Microsoft/Exchange/Mail-Gateways/eMailAddressDump.ps1 new file mode 100644 index 0000000..056c811 --- /dev/null +++ b/Microsoft/Exchange/Mail-Gateways/eMailAddressDump.ps1 @@ -0,0 +1,4 @@ +# Collect and Display all SMTP E-Mail Addresses in Domain + +Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn +Get-Mailbox | Select Name -ExpandProperty EmailAddresses | Select SmtpAddress | ft -HideTableHeaders diff --git a/Microsoft/Exchange/Mail-Gateways/sendMailAddresses.cmd b/Microsoft/Exchange/Mail-Gateways/sendMailAddresses.cmd new file mode 100644 index 0000000..7e787f5 --- /dev/null +++ b/Microsoft/Exchange/Mail-Gateways/sendMailAddresses.cmd @@ -0,0 +1,28 @@ +echo off +rem : sendMailAddresses.cmd - Send valid Mail Addresses from Domain to SPAM Proxy + +rem : Change Style + cd /d %0\.. + title Send valid Mail Addresses + color 17 + +rem : Dump Mail Addresses into C:\Service\eMailAddressDump\DOMAIN.com + Powershell.exe -executionpolicy remotesigned -File C:\Service\eMailAddressDump\eMailAddressDump.ps1 > C:\Service\eMailAddressDump\DOMAIN.txt + +rem : Generate the Body + echo Actual SMTP Addresses of DOMAIN.com > C:\Service\eMailAddressDump\body.txt + date /t >> C:\Service\eMailAddressDump\body.txt + time /t >> C:\Service\eMailAddressDump\body.txt + +rem : Generate a Message File and MIME encode the File with the Users Addresses + mpack -s "Actual SMTP Addresses of DOMAIN.com" -d C:\Service\eMailAddressDump\body.txt -o C:\Service\eMailAddressDump\body.msg C:\Service\eMailAddressDump\DOMAIN.txt + +rem : Send the encoded File by e-Mail + bmail -s 127.0.0.1 -t spamproxy@DOMAIN.com -f exchangeadmin@DOMAIN.com -h -m C:\Service\eMailAddressDump\body.msg + +rem : Delete temporary Files + del C:\Service\eMailAddressDump\body.txt + del C:\Service\eMailAddressDump\body.msg + del C:\Service\eMailAddressDump\DOMAIN.txt + +rem : Remember to include this Servers IP Address as a Relay Host at your Mail Server!