Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have contact form on my website. I have written following code


HTML
<form method="post"  action="mailto:sonalipatil311@rediffmail.com" enctype="text/plain">

</form>

inside that code I have 3 text boxes (name,email, comment)
one button for submit the mail. Its working fine in IE but not working in google crome. why?
Posted
Updated 15-Apr-12 21:09pm
v3

1 solution

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:
HTML
<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
 
Share this answer
 
Comments
Nelek 16-Apr-12 17:30pm    
Nice explanation. +5
Just an addition... posting an email address into a forum when searching for help is quite a bad idea as well ;P
Sergey Alexandrovich Kryukov 16-Apr-12 17:37pm    
Thank you, Nelek.
I agree with your warning about posting of the e-mail address. I assumed that it was a fake one as OP should understand the flaw ;-)
--SA
Nelek 16-Apr-12 18:48pm    
That could be assuming to much.
Sergey Alexandrovich Kryukov 20-Apr-12 17:11pm    
:-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900