views:

39

answers:

3

How do you send the content of a website form to an email address without disclosing the email address to the user.

Thanks!

PS: If at all possible, I would like this to be in HTML JavaScript Ok, anything I guess.

A: 

If you mean doing so on a client side, using mailto: link - you can not.

If you mean any way, yes - you submit the form contents back to your server, and have your back end script send the email.

DVK
A: 

You can do the form in HTML, but the posting will need to be done in a script. Even if you don't expose the email address, the script can be used to spam that email address. This is why you see captcha being used in such cases. There are scripts available for most languages. Check to make sure their are no known security problems for the scripts. The original Matt's script in perl had problems, and the Perl community created a more secure version.

BillThor
+2  A: 

Not possible. You can however put a "fake" from header in the mail. You'll only risk it to end up in the junk folder.

HTML doesn't provide any functionality to send mails. You'll really need to do this in the server side. How exactly to do this depends on the server side programming language in question. In PHP for example, you have the mail() function. In Java you have the JavaMail API. And so on.

Regardless of the language used, you'll need a SMTP server as well. It's the one responsible for actually sending the mail. You can use the one from your ISP or a public email provider (Gmail, Yahoo, etc), but you'll be forced to use your account name in the from header. You can also register a domain with a mailbox and just register something like [email protected] and use this to send mails from.

Update: JavaScript can't send mails as well. Like HTML it's a client side language. You'll need to do it with a server side language. All JavaScript can do is to dump the entire page content back to the server side. jQuery may be useful in this:

$.post('/your-server-side-script-url', { body: $('body').html(); });

with (PHP targeted example)

$to = '[email protected]';
$subject = 'Page contents';
$body = $_POST['body']
$headers = prepare_mail_headers();
mail($to, $subject, $body, $headers);

Update 2: if you actually want to hide the to header in the mail, then you'll need to use the bcc (Blind Carbon Copy) instead. This way the recipient addres(ses) will be undisclosed. Only the from, to, cc stays visible.

BalusC