Sendmail?

  • 19 years ago

    I'm making a website, and under contact us, I want a form that sends an email. Now i know how to make it send through there default email account, but can i make a sendmail.asp type file in php?
    If so, how?

  • 19 years ago

    anyone anyone?

  • 19 years ago

    Use the mail() command. Below is an example

    Code:
    mail("james@vbweb.co.uk",$Subject,$Message,"From: $Email\n");

  • 19 years ago

    the php mail function is as follows:


    Quote:
    mail (string to, string subject, string message [, string additionalheaders [, string additionalparameters]])


    If you print view the full headers of a email you have received you will see all the options that can go in the "additional_headers" section, for example: From, X-Sender, X-Priority, Return-Path, cc, bcc, etc.


    for example:


    Quote:

    /* recipients */
    $recipient .= "santa@north-pole.com";


    /* subject */
    $subject = "Xmas List";


    /* message */
    $message .= "This is a simple mail example\n";


    /* additional header pieces for errors, From cc’s, bcc’s, etc */
    $headers .= "From: Birthday Reminder <birthday@php.net>\n";
    $headers .= "X-Sender: <birthday@php.net>\n";
    $headers .= "X-Mailer: PHP\n"; // mailer
    $headers .= "X-Priority: 1\n"; // Urgent message!
    $headers .= "Return-Path: <birthday@php.net>\n"; // Return path for errors


    /* If you want to send html mail, uncomment the following line */
    // $headers .= "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type
    $headers .= "cc: birthdayarchive@php.net\n"; // CC to
    $headers .= "bcc: birthdaycheck@php.net, birthdaygifts@php.net"; // BCCs to


    /* and now mail it */
    mail($recipient, $subject, $message, $headers);



    Hope this is useful

  • 18 years ago

    does the $ sign in front of reciepent and message etc does that mean, that thats the form name. Or what.
    If not how would a form look like

  • 18 years ago

    if something has a $ in front of it, and you're using php, then its a variable., ie


    Code:

    $myvariable = "hello"


    myfunction ($myvariable)



    is the same as

    Code:

    myfunction ("hello")

  • 18 years ago

    err... yes.  They could be the names of the input boxes in a form e.g.


    Code:

    <form action="mailscript.php" method="post">
     <input type="text" name="recipient" />
     <input type="text" name="subject" />
     <textarea name="message"></textarea>
    </form>


    on the mail script you will probably (if you have a fairly recent version of php [4.1.x +]) need to refer to the variables as $_POST['recipient'].... etc.

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The generation of random numbers is too important to be left to chance.” - Robert R. Coveyou