Link to home
Start Free TrialLog in
Avatar of Daniel Van Der Werken
Daniel Van Der WerkenFlag for United States of America

asked on

How To -- Create a bad, corrupted, or broken email for testing -- C#

We're using Rackspace as our mail server. We have people from all over the USA sending us emails with PDF attachments for a specific reason. Anyway, sometimes, the emails themselves (forget about the PDF's for now), cause the home-grown application that we wrote to retrieve and process these emails blow up.

We wrote a command-line application in C# that downloads and "processes" the messages using the Mailkit library.

The messages arrive at Rackspace, and our application checks for unread messages and grabs the information we need and saves it to the database and file system. The original message stays at Rackspace.

On rare occasions, we get a bizarre-o email that causes our C# application to go belly-up. Note that the Rackspace web email client seems to handle these messages just fine, but my application breaks.

As you can imagine, my application, breaking, isn't a good thing. We have to manually log into the Rackspace web client, remove the offending email from the inbox, and let it continue to process the "good" messages.

 I'm trying to bullet-proof the application, so I need to be able to create these crazy emails that cause my application to go bad.

I have a few applications I've written that allow me to send messages to my inbox, but they "check" the messages for proper formatting and will fail to send a "bad" message.

For example, one of the bad messages we actually received in production had a "from" email address something like "user@user@gmail.com" (GMail seems to be a really good source of bad emails, btw).

I tried to do this with my tools, and the email software I use says "bad from address. Fail."

I think we had one email once that didn't have a header. At all. It was just blank.

Of course, when I try to forward this to my local inbox to test, it gets reprocessed and looks good. I need a way to populate the Rackspace inbox with "broken" emails that I can use to test with via my application.

No, I don't want to cause Rackspace any problems, of course. I like Rackspace. Good people there. I just need the occasional broken message that I can use to test with.

Any recommendations?
ASKER CERTIFIED SOLUTION
Avatar of Mark Bullock
Mark Bullock
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial