Killersites.com - EMAILING FROM A WEB PAGE

Emailing from a Web Page

There are 2 basic ways you can send an email from a web page: with the built in HTTP method using the ‘mailto’ attribute of a hyperlink or by using a server side script.

Option 1: Browser's built in support for sending email.

The easiest way to send an email is by using the browser's built in support for mailto:

<a href=’mailto:someAddress@killersites.com’>Email Me!</a> 

When the user clicks on a link with the ‘mailto’ attribute written in, the browser is smart enough to know that is should open up the default email program and set the ‘to’ address to the one specified in the link.

So in this case the address would be:

someAddress@killersites.com 

You can get a little fancy by setting the ‘Subject’ field by adding this to the address:

 someAddress@killersites.com?subject=I have to break up with you because you are a nerd … 

Now that subject will be automatically inserted as well.

Advantages: Easy to do and widely supported.

Disadvantages: Spam bots can pick up the email address listed on the page (but there are ways to protect against that.) – Not all people’s machines will be able to support it. - People can see where you are sending the email.

NOTE: Whenever you create a URL there should never be any spaces in it. In this case this would include the subject we just appended to the URL:

subject=I have to break up with you because you are a nerd …

So to make this proper you would add the space character (%20) like so:

subject=I%20have%20to%20break%20up%20with%20you ... 

This is the strict way of doing it and is best practice, but many browsers are forgiving ...

Option 2: Use a server side script.

Today there are many options for sending mail via server side scripting engines like PHP and PERL CGI. PHP has a built in mail function and there are many CGI scripts that will do it for you too.

HOW IT WORKS:

You would build an HTML form according to the scripts instructions where the form would post to the script, be it in a page (like in PHP) or to a CGI bin script like with PERL CGI.

The problem is that you have to have the server set up to run the scripts and you have to know just a little programming. In addition to that, unless the person enters his email address in a form field, you can’t know who emailed you.

On the positive side, if the user does not have an email program on his/her computer (say he/she found your site while at an internet coffee shop) he/she will still be able to send you an email. Another positive is that spam bots have no way of snooping for your email address on that page. And yet another advantage is that people will not be able to send you an email virus this way, even by accident.

So where do you go to find such a script? If you have the ability to use PHP you can do it in a PHP page. Learn how with my beginners PHP video tutorials:

Beginners PHP

Top
© 1996 - Killersites.com – All rights reserved