views:

58

answers:

4

I am not a web developer but I do have a lot of programming experience in C# and Windows forms programming. On our company webpage my boss wants me to put in a textbox where visitors can submit a comment and press a submit button and that comment will be sent to an email address. Right now, our website uses just plain old html, no php or javascript or anything like that. I am wondering what is the simplest way to accomplish what I need? Can someone point me in the right direction? The website is hosted on an Apache server so I won't be able to use aspx.

+2  A: 

The simplest solution would be have the form action as "mailto:[email protected]"

However, this has the downside of the email address being sent to being exposed to spam bots, along with the clients mail application having to load to send the email which can be confusing and slow.

Sending emails in PHP is common, and there are thousands of articles out there on how to do it, here's one

Tom Gullen
Confusing? Yes. Slow? Yes. Not working most of the time? Yes. Never go near mailto: as a form action.
David Dorward
I agree with David. You never know how the user has their email set up. mailto might just not work and will certainly confuse, even annoy some people.
Oli
He did ask for the simplest way though.
Moox
+1 for right answer and specifying a better alternative.
Moox
Of course, but it can be OK in some instances, for example company Intranets etc. It would appear that the question asker is quite new to web tech, so if he's looking for a quick solution it might be acceptable.
Tom Gullen
@Moox simplicity is more than a basic implementation. It's not simple if you get a load of complaints from users who are fed up of your website spawning email windows. Or phone calls from people who would have preferred to use the email box but didn't have a mail client installed (increasingly the case).
Oli
I understand simple to mean the most basic and easy solution.
Tom Gullen
@Oli I'm quite aware that it would be an awful method. But it IS the simplest way. The answer provided a better alternative and explained why the simplest way was not a good idea. By definition, it was the most simple answer.
Moox
A: 

In this case the most simple way is to install PHP to your apache to use the mail()-function. Of couse you could use tomcat additional to apache, but the configuaration is much more time-eating.

poeschlorn
+2  A: 

The simplest method depends heavily on what is available. If PHP is supported, use it.

Here's a simple example (I wouldn't focus too much on their HTML -- which is a bit shoddy) but the PHP at the bottom to give you an idea on how to pull the <form> in and send the email.

If you don't have PHP and don't want to install it, you can do this without any server-side code and outsource the problem. Bravenet (a name that will be familiar with any old-school webdeveloper) have a free hosted form solution that lets you post your forms to their server and they email you the result.

Not amazingly professional, but takes about 10 seconds to implement.

Oli
The hosting company supports PHP. I tried out the mail() method and it works perfectly! Thanks!
Jordan S
A: 

If you don't want to use any sort of scripting technology, then the form mailto might be your only option. You can just make the action of your HTML form mailto:youraddress and the form post will be mailed directly.

I would highly recommend looking into some sort of scripting technology though to do this in a more reliable way....PHP looks like a good fit in your environment.

jaltiere