Import email addresses to SpamTitan (API) whitelist filter from text file with PowerShell
I've created this PowerShell script to import email addresses into SpamTitan (API) global whitelist filter from a text file. Feel free to use it as long as you link to this article on your site or in your script:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Created by Allan Brochorst Kjær. Script must not be changed and/or copied without written permission from the author. | |
Source file must contain an e-mail address on each line, e.g.: | |
user1@test.com | |
user2@test.com | |
user3@test.com | |
#> | |
Remove-Item c:\SpamTitan_ImportAddress_log.txt | |
date >>c:\SpamTitan_ImportAddress_log.txt | |
$data1 = Get-Content "\\fileshare\source1.txt" | Select-String "@" | |
$data2 = Get-Content "\\fileshare\source2.txt" | Select-String "@" | |
$data3 = Get-Content "\\fileshare\source3.txt" | Select-String "@" | |
Foreach ($i in $data1) | |
{ | |
$i >>c:\SpamTitan_ImportAddress_log.txt | |
#The wget alias does not work in PowerShell 3, using Invoke-WebRequest instead | |
#wget https://yourSpamTitanURLhere.site.com/whitelist/add?sender=$i | |
Invoke-WebRequest https://yourSpamTitanURLhere.site.com/whitelist/add?sender=$i >>c:\SpamTitan_ImportAddress_log.txt | |
} | |
Foreach ($i in $data2) | |
{ | |
$i >>c:\SpamTitan_ImportAddress_log.txt | |
#wget https://yourSpamTitanURLhere.site.com/whitelist/add?sender=$i | |
Invoke-WebRequest https://yourSpamTitanURLhere.site.com/whitelist/add?sender=$i >>c:\SpamTitan_ImportAddress_log.txt | |
} | |
Foreach ($i in $data3) | |
{ | |
$i >>c:\SpamTitan_ImportAddress_log.txt | |
#wget https://yourSpamTitanURLhere.site.com/whitelist/add?sender=$i | |
Invoke-WebRequest https://yourSpamTitanURLhere.site.com/whitelist/add?sender=$i >>c:\SpamTitan_ImportAddress_log.txt | |
} | |
date >>c:\SpamTitan_ImportAddress_log.txt |
Kommentarer
Send en kommentar