55 users online (1 members and 54 guests)  


  Results 1 to 3 of 3

Related

  1. Need help with form going to email.    Forum: HTML Forum
    Replies: 1
  2. email form script, need advice    Forum: PHP Forum
    Replies: 1
  3. Please help with email form script    Forum: PHP Forum
    Replies: 1
  4. PHP email form.    Forum: PHP Forum
    Replies: 2
  1. #1
    khnumtemu's Avatar
    New User

    Status
    Offline
    Join Date
    Aug 2007
    Posts
    1

    Extend my email form script

    Peace everyone. I just finished a class on CGI/Perl Basics. The course helped us to build an email processing form script. Which I have included below.
    I would like to take it to the next level and learn how to include a file upload feild. So a user can attach a Word Document to the email.
    Any help would be greatly appreciated.

    Email Script:
    Code:
    #!/usr/local/bin/perl
    #run subroutine to turn stdin into an array named %in
    require "cgi-lib.pl";
    &ReadParse;
    #store location of mail program in variable
    #your mail program's locale may differ 
    $mailprog = '/usr/sbin/sendmail';
    #use cgi-lib.pl subroutine to set content type
    print &PrintHeader;
    unless (-e $mailprog){
    print <<"PrintTag";
    <HTML>
    <BODY>
    <H3>Cannot find $mailprog.</H3>
    <P>There is a typo in the mail program path.</P>
    </BODY>
    </HTML>
    PrintTag
    exit(0);}
    #create confirmation web page
    print <<"PrintTag";
    <HTML>
    <HEAD>
    <TITLE>Thanks for your comment(s) and suggestion(s)!</TITLE>
    </HEAD>
    <BODY BGCOLOR="white" TEXT="black">
    <H2>Thank You! $in{'Name'}</H2>
    <P>Your comment(s) and suggestion(s) has/have been received.</P>
    <P>We will be reviewing your comment(s) and suggestion(s) immediately.</P>
    <!-- change the URL below to YOUR home page -->
    <a href="<A href="http://www.somesite.com/index.html">Home">http://www.somesite.com/index.html">Home Page</a>
    </body>
    </html>
    PrintTag
    #open mail program
    open (MAIL, "|$mailprog -t") || 
    die "Can't open mail program\n";
    #print message headers (to, from, subject, etc)
    print MAIL "To: $in{'Email'}\n";
    print MAIL "Reply-To: $in{'empmail'}\n";
    print MAIL "From: $in{'empmail'}\n";
    print MAIL "Subject: Your Comment(s) and Suggestion(s).\n\n";
    #print body of message
    print MAIL <<"PrintTag";
    Dear $in{'Name'}:
    Thank you for your comment(s) and suggestion(s).
    This e-mail confirms that we have received your comment(s) and suggestion(s). 
    We will be reviewing your comment(s) and suggestion(s).
    PrintTag
    #close mail program, releasing message to be sent
    close(MAIL);
    #open mail program for a second message to employee
    open (MAIL, "|$mailprog -t") || die "Can't open mail program\n";
    #print message headers
    print MAIL "To: $in{'empmail'}\n";
    print MAIL "Reply-To: $in{'Email'}\n";
    print MAIL "From: $in{'Email'}\n";
    print MAIL "Subject: comment(s) and suggestion(s).\n\n";
    #create body of message
    print MAIL <<"PrintTag";
    Please review the following comment(s) and suggestion(s):
    $in{'Name'}
    $in{'address'}
    $in{'cityStateZip'}
    $in{'phone'}
    $in{'Email'}
    $in{'TextArea'}
    PrintTag
    #close mail program and send message
    close(MAIL);
    #end of program
    Peace and Blessing to all
    Last edited by vinyl-junkie; 08-03-2007 at 08:49 PM. Reason: Added code tags

  2. #2
    vinyl-junkie's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    721

    Re: Extend my email form script

    Welcome to AHFB! We're glad to have you here.

    Did you try Google? There are plenty of scripts that you can use as examples when modifying your own.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more

  3. #3
    pageBuzz.com's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2006
    Posts
    21

    Re: Extend my email form script

    Sendmail does not support attachments. However there is a perl module that can.

    MIME::Lite

    You can lookup the useage and sample on CPAN. It should be relatively easy to add to your script.



Tags for this Thread