Hi people

I need your recommendations on what (free) CGI Mail Form script to download and use.

All I want to be able to do is have a form on my HTML page that allows people to input some personal info and then the info is posted to my email address.

I've tried a few scripts but I've had problems configureing it. I'm not very familiar with CGI/Perl at all.

Your thoughts are very welcome.

Many thanks.

Leroy

Dani AI

Generated

Options for : three practical routes depending on hosting and comfort with server code.

  1. If the web host supports PHP, a tiny PHP handler is the quickest way to accept a POSTed form and forward it by email.
  2. If editing server scripts is not wanted, a hosted form-to-email service removes all server-side work.
  3. If Perl/CGI is required, a Perl CGI script will work but needs correct shebang, execute permission, and the right mail modules. @chrisbliss18's pointer to Perl support is on target, and @sarahk's mention of a PHP-based mail approach is what most people use when PHP is available.

Example form (place on the public page):

<form method="post" action="/send.php">
<input type="text" name="name" placeholder="Name" />
<input type="email" name="email" placeholder="Email" />
<textarea name="message" placeholder="Message"></textarea>
<input type="submit" value="Send" />
</form>

Minimal PHP handler notes: remove CR/LF from header fields, validate the sender email, and use a server-domain From with the visitor as Reply-To to avoid SPF/DKIM/spam problems.

<?php
ini_set('display_errors',1); error_reporting(E_ALL);
function safe($s){ return trim(str_replace(array("\r","\n"),' ',$s)); }
$name = safe($_POST['name'] ?? '');
$email = filter_var($_POST['email'] ?? '', FILTER_VALIDATE_EMAIL);
$msg  = trim($_POST['message'] ?? '');
$to = 'me@mydomain.com';
$from = 'webform@mydomain.com';
$subject = "Contact from {$name}";
$headers = "From: {$from}\r\nReply-To: {$email}\r\nContent-Type: text/plain; charset=UTF-8\r\n";
if ($email && mail($to,$subject,$msg,$headers)) { echo "OK"; } else { echo "Send failed — check server logs"; }
?>

Troubleshooting & security checklist:

  • Confirm host supports PHP/CGI and where scripts must live (cgi-bin vs document root).
  • For Perl CGI: set executable bit (chmod 755), correct shebang (#!/usr/bin/perl or host path), and Unix line endings.
  • Check webserver error logs and mail logs for clues.
  • Prevent header injection by stripping CR/LF from inputs.
  • Use SMTP with authentication or a mail library for reliable deliverability; use Reply-To for the visitor and a valid server-domain From.
  • Add spam controls (honeypot, simple question, or captcha).

If Perl help is wanted later, include the exact script text and server error output when moving the question to the Perl forum.

Recommended Answers

All 2 Replies

Are you wanting a Perl script or a PHP script? This is the PHP forum. If you want Perl assistance, go here.

I use a free script from sourceforge called phpMailer, it's awesome.

One of the big issues I've had has been to have an email work in Outlook, and webmail, and thunderbird etc. phpMailer seems to have sussed out all the answers to these problems.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.