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

Requirements

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

Example PHP contact form code

  1. Copy and paste the code from our link below into a new contact.php file in your DomainsFoundry web space, under your public_html folder.
  2. Edit and change the $to = “you@example.com”; line to the email address you want to receive your contact form messages at.
  3. Change the $from = “postmaster@example.com”; line to an email address on your DomainsFoundry 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 https://www.example.com/contact.php, replacing example.com with your own domain.