Search code examples
c#asp.netcontact-form

Why does creating contact forms require a password?


So Im looking at having a contact form on my website where a person can type a message and send it, with the mesage going to my inbox.

But every time I see them online Ill see this:

 System.Net.NetworkCredential("[email protected]", "YourPassword");

Why do I need to provide my password? When you send someone a regular email, you dont need THEIR password.

I also have security concerns. Ok, it's in a .cs file, but still, I dont like seeing my password in plain text there.

Also, what about if its for a big company? Does ebay have their password in plain text? It's something I doubt. How do other people do it?


Solution

  • You absolutely don't want the users password.

    But for your contact form to be able to send a mail it needs to be send by a valid email client. Say for example you want to use the gmail server for your mail, you need to provide your credentials for it.

    As for the second part of your question, please don't store these plain text in code. You can easily acces those from app.config / web.config

    (for example see: Embed credentials for webclient in C# Console Application app.config?)