Tuesday, October 23, 2007

How to send email from a form ?

How to send email from a form ?

I had asked this question a few days ago myself. And have been scouting
google for the answer. To be honest, I did get quite a few answers.

But, the problem lay in finding the compatible tool for my installation.

My limitations were:
- I do not own the server
- I cannot install or uninstall any tool on to the server
- The server help was not very familiar with the installation either
- I had to scout the server details (info like the MTA used by the server)

So, was born a script that does not rely on the server configuration, for sending mail.

This script is in php (I tried to use the formmail script, but found that
this is easier) and relies on direct communication with the SMTP server to send mail.

The script uses SMTP AUTHentication for sending mail. This script assumes that you are using the Exim MTA for your email transport.

As you see in the script, though the SMT Protocol (SMTP) is standard, the request and response for different servers are slightly different and the script may have to be modified to suit your server. As mentioned, this

script is for the Exim MTA with SMTP AUTH.

SMTP AUTH means that you can post a message ONLYy after you have identified yourself to the server, meaning that you have to be an authenticated user on your server.

Hopefully, this helps!

If the php server is not configured correctly, variables defined in the html form may not pass properly into the php document, which is why the "track_vars" is used.

In addition, the phrase $HTTP_POST_VARS["b_first"] creates the appropriate variable in the document that was passed through the form, but was not visible due to some misconfiguration at the server.

Download the "form to email" script below:
form2mail script in a zipped file
Post a Comment

Why should I not take revenge?

This is what we do and have been doing since we have known man. Revenge seems to be a natural response to injustice that seems to target us...

Copyrighted.com Registered & Protected DWYE-NHTO-NBNH-7FFM