cgi-bin/mail

topic posted Wed, November 7, 2007 - 2:01 PM by  jazzlamb
Hi there,

I kneel to the gods of social networking for help in this matter

I seem to have forgotten how to use cgi-bin/mail sever side forms

can someone please help me in this case : I want a secure form that will send an email via the server for the purpose of a mailing list. Banging my head against the wall so to speak - and know this is so simple. Thanks.

jazzlamb
posted by:
jazzlamb
Canada
  • Re: cgi-bin/mail

    Wed, November 7, 2007 - 3:30 PM
    form collects information int he form of fields.

    form submits to he value of its attribute "action" via the value of its "method". action is the url to the script that will process the data, method is a valid http/https server method, normally POST or GET for most operations.

    script then validates the the submitted data (or not)

    if valid it then processes the data.

    the form submitted as the body of the request so most scripting languages make these immediately available as local variables in the processing script. look at this simple example in php:

    form:

    <form name="myForm" action="myProcessor.php" method="POST">
    <input type="text" name="sender"></input>
    <input type="text" name="sender_email"></input>
    <textarea name="message"></textarea>
    <input type="submit"></input>
    </form>

    php:
    <?php
    extract($_POST); // extract the variables of the form form the post array to local variables of the same name
    $mailer = new phpmailer();
    $mailer->AddAddress('recipient@mydomain.com');
    $mailer->SetSubject('A scripting example');
    $mailer->SetFrom($username, $sender_email);
    $mailer->SetHost('localhost');
    $mailer->SetBody($message);
    $mailer->Prepare();

    if($mailer->Send())
    {
    header('Location: www.mydomain.com/success.html');
    } else
    {
    header('Location: www.mydomain.com/error.html');
    }
    ?>

    it goes something like that.. there are literally tons of scripts out there for php and perl. Some more secure than others. But id start searching for those.

Recent topics in "- webdesign -"