BlogEngine.Net's contact form fixed for Hotmail users (well, hacked)

by Patrice 11/11/2008 11:10:06 AM

The other day, my wife decided to make a joke on me and used the contact page on this blog to ask funny questions. Yesterday, she was asking about my blog, how it was going, are people interested, do I receive... emails? hmmm, why is she asking all these questions suddenly? Finally the cat went out the bag... She told me about her joke... but I never received any email. Alright, this could be due to a SMTP configuration problem. But BlogEngine.Net "test" email function worked (this is part of the admin page to test SMTP values)... I then tried the contact form myself and I never received any feedback... I tried again by filling the "from" field using a different email and this time it worked... hmm, okay, the difference between my wife (as with my first test) and my second test is hotmail.com. I can even use the contact form using a fake "from" as bla@blablabla.bla and it will work.

This site is hosted on GoDaddy, my lfdx.com emails are hosted on GMail. It's known that to use GMail POP3 you need to use the port 465. But this port is blocked on GoDaddy servers. The solution is to set the SMTP server to relay-hosting.secureserver.net (GoDaddy server, considering that you already have set your MX records to point to googlemail.com). So, where is hotmail.com blocked? Somewhere within GoDaddy infrastructure I suppose. This is not crucial and I don't have time to investigate with GoDaddy.... Let hack the code then. Quicker and funnier!

Since I have compiled BlogEngine myself, it was easy to "debug" and "patch" the code... I opened contact.aspx.cs page and went to SenEmail() method. That's where I decided to hack the "from" field. Here is how... nothing complex.

I replaced this:

mail.From = new MailAddress(txtEmail.Text, txtName.Text);

to:

string email = txtEmail.Text.ToUpperInvariant();//for the String.Replace method
//Hotmail patch for GoDaddy-Hotmail-GMail issue
if (email.EndsWith("HOTMAIL.COM" ))
    email = email.Replace("HOTMAIL.COM", "_REMOVE_hotmail.com");

mail.From = new MailAddress(email, txtName.Text);

This way, I receive hotmail emails and if I need to do a reply, I just have to delete the _REMOVE_ part.

Unfortunately, I don't like the way I hacked BlogEngine.Net code since the next time I will upgrade BlogEngine.Net, this part will be overwritten. But I don't have time to figure a best way for now.... If anyone has one, you are welcome to share your solution!

Powered by BlogEngine.NET 1.3.1.0

LFDX Software Inc.

About the author

P. Lafond Patrice Lafond
(and yes, it's Mr!)
Software Engineer
French Canadian expat in Bermuda for over 7 years.
flag QC  flag BDA

E-mail me Send mail

Calendar

<<  November 2008  >>
MoTuWeThFrSaSu
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

View posts in large calendar

Pages

    Recent comments

    Authors

    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2009

    Sign in