Using a CGI to submit a form via email

Posted on 1998-12-22
Last Modified: 2012-05-04
Does anyone have a script that will take an email address and subject entered from a form (post method) and mail the text from that form to the email address.  Preferably using elm, but will settle for anything.  Also, if possible, attach a .gif to the message or embed it.

This would be extremely helpful!


Question by:rellik
  • 2
  • 2
  • 2
  • +1

Expert Comment

ID: 1207085

I am not sure if it lets you attach files though...

Expert Comment

ID: 1207086
I want to weather you would like to install blat on your server  or and if you can then I have a solution do replay..

Expert Comment

ID: 1207087
Formmail does not let you attach files.  The best way to do what you want is to send a MIME complient message and encode the file in Base-64 within your Perl CGI.  I have a script which does this based on  the MIME routine you can find in the Perl Library.
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.


Author Comment

ID: 1207088
He didn't answer the question, he just refered me to web page that talks about submitting form mail.

Accepted Solution

sdjjm earned 200 total points
ID: 1207089
I posted a Perl script last week that will take input  from an HTML form, parse the data,  and generate email using sendmail.   It works well, and  you can add the MIME routines to it if you want to attach a file..   If you want to use Perl, you can find the script at:


Author Comment

ID: 1207090

Expert Comment

ID: 1207091
Since you can install blat on server then it is simple.
Just store the data of form in a temporary txt file and use the commannd
open(MAIL,"|$mailprog temp.txt -s \"subject\" -f \"$in{'email'}\" -t \"$recipient\"");
         print MAIL "\n\n";

I hope the few lines of code may solve your problem

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
perl script to count sepecial characters in a file 7 147
work on ods spreadsheet with perl in ubuntu 4 80
Perl script to process a .csv file 18 44
Perl Versus AWK? 7 51
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question