The following is an example of a basic form-to-email script using PHP.


  • Web space with PHP support.
  • A valid email address to send the emails from. This must an active account hosted with Ecenica Hosting.

Example PHP contact form code

  1. Copy and paste the code from our link below into a new contact.php file in your Ecenica web space, under the public_html folder.
  2. Edit and change the $to = “”; line to the email address you want to receive your contact form messages at.
  3. Change the $from = “”; line to an email address on your Ecenica hosting account.
  4. Change the subject line ‘$subject = “An example of a simple Contact Form using PHP mail() function”;’ to your preferred subject.
  5. Save your contact.php file
  6. Open your web browser and visit at, replacing with your own domain.