Validate list of email addresses in a text file and check which
email is a valid email and which one has the incorrect format.
PowerShell code below can easily check or validate incorrect
email, output will show true if valid email and false if the email is not
valid.
To check list of valid emails PowerShell utilizes regex. This is useful to check typo errors when sending out mass email or a list of emails which has not yet been verified.
But of course, the code will not be able to check whether the emails are active or not.
#===============================
$reader =
[System.IO.File]::OpenText("c:\all_emails.txt") #get-content can also be used
#read the file line by line and validate the data
while($null -ne ($line = $reader.ReadLine())) {
while($null -ne ($line = $reader.ReadLine())) {
#$line
$regx="[a-z0-9!#\$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#\$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?"
[regex]::Match($line, $regx,
"IgnoreCase ") | format-Table success, value -AutoSize
}
#===============================
format-Table success, value -AutoSize -- this will trim empty white spaces
I found the regex validation in stackoverflow, and formatting the output can be found using the Technet link below.
references:
#format table output https://blogs.technet.microsoft.com/csps/2011/03/21/powershell-overview-format-table-vs-select-object/
#validate email https://stackoverflow.com/questions/11564679/using-regex-in-powershell-to-grab-email
Cheers! Till next time.
================================
Free Android Apps:
Click on links below to find out more:
Linux Android App cheat sheet:
Multiplication Table for early learners
Catholic Rosary Guide for Android:
Divine Mercy Chaplet Guide (A Powerful prayer):
"Wow, I can't believe I stumbled upon this amazing bulk email checker
ReplyDeletethat's completely free! As someone who frequently deals with email marketing and outreach, this tool is an absolute lifesaver. It saves me so much time and effort by verifying the validity of email addresses in bulk.