Grep emailaddress from IMAP dir with UNDELIVERABLE messages


You send newsletter and get a hole buns of UNDELIVERABLE email back in your INbox. You find this irritating and want to cleanup your newsletter database.

To do so you probably need a list with all email addresses you want to un-subscribe.


  • First create a new IMAP directory.

Check for valid of invalid emailaddresses with egrep


If you want to check if a file, like a csv-file with e-mail-addresses for a newsletter, contains invalid formatted email-addresses then you can use this egrep command.

egrep "\w+([._-]\w)*@\w+([._-]\w)*\.\w{2,4}" emial.csv -vn

Input file email.csv is a file containing all the email-addresses.