The whole idea is wrong. There is nothing to work in this code sample. Perhaps you did not show relevant part of the code.
If you are using a form to post a mail message, you never need to expose the "To" e-mail address. Actually, hiding that e-mail address and even the whole mechanism of sending a message is one of the important purposes of sending a message on the server side. Main considerations of dealing with the server side are safety consideration. Otherwise, you could simply create an anchor like this:
<a href="mailto:mailto:sonalipatil311@rediffmail.com">Send me a message</a>
Note that in this case you always expose your e-mail address to everyone, as with any URI on the HTML page.
I hope you understand that the
<form>
tag is only needed if you something on the server side. If you don't use any server-side technology, your activity makes no sense. You can only use an anchor shown above which might run some default mail program on the user's machine. Nothing guarantees that the user has anything like that installed and that the user is able to use the e-mail address which can be copied from the Web pages using any Web browser. If I assume you use some server-side technology, I cannot do give a detailed advice as you did not share with us what exactly are you using.
Using server side is the way to organize safe message sending by the site users. The value of the attribute
action
should be an URL of some Web page, usually the same page as the one with the form. The data required for the message (such as message, subject, "attachment" data, user information, etc) should be placed in the form and identified with unique
name
attribute. The server-side code should identify each piece of data by its
name
attribute, compose a message and send it.
Here is a
serious safety warning for you: it is critically important that you filter all the user-supplied data to make sure it is safe. If you fail to do it,
your host can be turned zombie sending spam or something like that in no time. In my past answer, I explain this issue in detail. Please see:
unable to send mail , it showing the error in below code .[
^].
Please be very careful.
Good luck,
—SA