Using a PHP Email Script

KB Tags associated with this article:
Use all tags
KB Tags
Body

If you’re facing an issue with the contact form (email script) on your website, it is possible that your emails are getting blocked by our servers.

Why does this happen?

Traditionally, most email scripts you find online for contact forms are built with either a customizable or dynamic sender email address (email address filled in while filling the contact form) or do not carry an email address at all. On our shared servers, such email scripts do not work.

Why this restriction?

We’ve enabled this restriction so that our servers authenticate the sender (from) email address and prevent users from misusing it to send spam emails from our servers.

What’s Email Spoofing?

In simple terms, its an email sent to anyone with a forged sender address. These emails are generated using email scripts.

How does it affect a server?

Sending spoof emails from a server results in the blacklisting of that server globally.

To prevent this, we do not allow the sending of such spoof emails from our servers.

What can I do about this?

If you have an email script which is not working i.e. the email is not going through, its probably because our server has blocked that email. We’d suggest you to amend your email script in such a way that it incorporates a static sender (from) email address of your domain name, for example - [email protected]

Here’s an awesome test PHP script we’ve just made for you so that we can get you right:


<?
  $mailto="[email protected]"; //Enter recipient email address here
  $subject = "Test Email";
  $from="[email protected]"; //Your valid email address here
  $message_body = "This is a test email from Webmaster.";
  mail($mailto,$subject,$message_body,"From:".$from);
  echo "Your email has been sent successfully";
?>

Save this file with a .php extension and run it; for example, save the file with file name email.php in your web root directory and run this script by visiting the URL - yourdomain.com/email.php

The email address that you’ve specified as the recipient of the email will receive an email.

You can make use of this email script for your website and customize the changes according to your needs.