Knowledge Base

Browse through our expansive online help documentation.

Configuring the Contact Form in Hydro

This template provides you with a front-end contact form that collects the sender’s name, email address, phone number, and message. In order for this form to work, you need a handler to manage the data collected in the form, which is included in two third-party PHP files – contact.php and class.phpmailer.php.

Setting Up the Form

You will have to configure the contact form before you are ready to receive messages from your visitors. To configure the form, follow these instructions:

  1. Open the contact.php file in your code editor.
  2. Search for the following variables:
    • $mail->AddAddress(‘you@yourdomain.com’, ‘Your Name’)
    • $mail->Subject = ‘Contact Form Submission’;
  3. Change the you@yourdomain.com string to your desired email address.
  4. Change the Your Name string to your name.
  5. Change the Contact Form Submission string to a different subject. The PHP script will automatically include this subject line whenever someone emails you from the contact form. You may want to change this to something more recognizable, but it is not required that you do so.
  6. Save the contact.php file.
  7. Upload the contact.php file to your server and test the changes by sending an email through the contact form to make sure you can receive emails submitted through the form.
    • Note: If the contact form is not sending an email to your email address, check the file permissions for both the contact.php and class.phpmailer.php files within your server’s file manager. Both files should have permissions set to 0644. Check with your hosting company’s help documentation if you need instructions on how to do this.

The phone number is not a required field in the contact form section; however, all other fields are required before the email can be sent.

Here is the code which you need to modify to configure the contact form:

$mail->AddAddress('me@mydomain.com', 'My Name'); // Your email address and name
$mail->Subject = 'My Domain: Contact Form Emails'; // Your subject

When changing your email address, name, and subject, do not delete the single quotes or the comma. If you do, the contact form will not send emails.

Customizing the Success Message

Once a visitor sends an email, a notification displays under the submit button, informing them that you have received their message. Currently, there is a generic message that we pre-configured in Hydro. This message can be customized by following these instructions:

  1. Open the contact.php file in your code editor.
  2. Search for the following variable: ‘message’ => “Thanks for sending us a note. We will contact you shortly.”
  3. Change the generic message in double quotations to a custom message of your choice. If this message is too long, it will not display in its entirety to the end user without you having to adjust the height/width of the popup.
  4. Save the contact.php file.
  5. Upload the contact.php file to your server and test the changes by sending an email through the contact form to make sure the custom success message displays appropriately.

Here is the code which you need to modify to customize the success message:

'message' -> "Thanks for emailing us. We will contact you shortly." // Your message

There is also a success message in the #modalOverlay section of the HTML files. Change this message to the same message in the contact.php file.