Sending an email using php

The php files are mail1.php, mail3.php and so on

For safety sake I have created a dummy email address just incase it gets spammed -

In keeping with many programing efforts the process is an iterative one, making small changes and then testing. It is easy to break the php handler causing it to crash and error out. If this happens then this needs to be fixed before changing the html and the form itself.

The form is the easy bit - the layout of the elements

Data from form

Sending mail with extra headers as array and data from form elements


Number of Children under 5:

------ THIS DOES SEND AN EMAIL! - I have to delete this from my inbox

The form above and the associated php work as well as I want them at the present time. The form is not as elegant as it could be and the php leaves the user on a non-responsive page which requires a previous page click. I do have an alert box (which is responsive) but I have not worked out how to return to page with the form on it - yet.

Actually this form seems to have broken - Example 1 below still works - and "data from form" is being debugged - AGAIN! I thought that I had the headers in an array working - I didn't - but I do now.

I need to do more on this, but in the meantime I may want to disable any access to the Apache mail() function (actually it is SendMail - the mail() is a php function).

Example 1

The form above works and sends an email from my HostingUK username.

Example 3

Sending mail with extra headers as array - 3 lines of hard-coded text as a message. I think that this now works! mail3.php has now been debugged I think.

Disabled Forms

Having seen some activity, emails received that were not sent by me, I can only conclude that the forms had been found by either a robot looking for forms to exploit or a random visitor with Javascript turned off. This was due to the fact that there was no entry in my Google Analytics reports. In any case there is no reason for the forms to be active on this website if they are not used.

The forms will be disabled until they are both "hardened" or actually required for testing or use on my site.

Hardening Forms

This may be overkill, but in the past I have seen php mailing scripts being "bombarded" with POST requests with data in fields with names that are commnly used as parameters passed to the php mail() function. These include $to:, $from:, $subject and $message - for this reason I intend to change these to $Huw, $Clunes, $Bindo and $keKe - $KeKe is an array containing reply-to, cc and bcc etc.


External Sources

Sending an email using php