There are several different tools available that you can use to send emails from a web page. The following scripts are the most commonly used on our servers:
FormMail
Using a simple script (see below), you can quickly set up FormMail to send emails from a Contact Us page, for example.
<form method="post" action="https://www.example.com/cgi-bin/FormMail.pl" accept-charset="ISO-8859-1" onsubmit="var originalCharset = document.charset; document.charset = 'ISO-8859-1';
window.onbeforeunload = function (){document.charset=originalCharset;};">:
Your Name <input name="realname" />
Your Email <input name="email" />
Your Message
<textarea cols="40" rows="10" name="Message">
</textarea>
<input type="submit" value="Send" />
<input type="hidden" name="recipient" value="[email protected]" />
<input type="hidden" name="subject" value="Subject" />
<input type="hidden" name="redirect" value="https://www.example.com/thanks.html" />
<input type="hidden" name="missing_fields_redirect" value="https://www.example.com/error.html" />
<input type="hidden" name="required" value="realname,email,Message" />
</form>
phpMailer
How to use phpMailer to send emails from a webpage
PHP mail() function:
Using the PHP Mail() Function to send emails from a webpage
What script should I choose?
If you are creating a, “Contact Us” type of page, you may want to look into using FormMail. FormMail is configured to send to the same email address every time, and is a simple script to setup.
If the email address you need to send to is a different email address every time, for example a user has signed up for something on your website and needs a confirmation email, you should look into using either phpMailer or the php mail() function. Both of these scripts can be used within php, and this is very useful if the email address you need to email is gathered from a variable in your php script.
The phpMailer script can work on any of our servers, however due to current SPAM standards involved with the PHP ‘nobody’ user, the php mail() function is not enabled on all of our servers. All of our newer shared servers have the php mail() function enabled, however it is not enabled on some of our previous servers. Please contact the support department if you are unsure whether your server has the php mail() function enabled.