Sending emails with Php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xiaofan
    New Member
    • Aug 2007
    • 3

    Sending emails with Php

    this is a simple email form of html

    Code:
    <form method="post" action="example.php">
    Recepient's Email:<input name="to" type ="text"><br>
    Your Email: <input name="from" type="text"><br>
    Message:<br> 
    <textarea name="message" rows="15" cols="40"></textarea><br> 
    <input type="submit" value="send"> 
    </form>

    but i dont know how to generate example.php
    cos i'm totally all new to php
    Can you help?
    Thx
  • Jeigh
    New Member
    • Jul 2007
    • 73

    #2
    [code=php]
    <?php

    $to = $_POST['to'];
    $subject = "Subject Here";
    $from = $_POST['from'];
    $message = $_POST['message'];

    $headers = "From: $from \r\n";
    $headers.= "Content-Type: text/html; charset=ISO-8859-1 ";
    $headers .= "MIME-Version: 1.0 ";

    mail($to, $subject, $message, $headers);

    ?>
    [/code]

    This should work, and it is a HTML email. If you don't want it to be you can just change the headers.

    Comment

    • ak1dnar
      Recognized Expert Top Contributor
      • Jan 2007
      • 1584

      #3
      And you have to Configure a SMTP server (For Local Server).

      Comment

      • xiaofan
        New Member
        • Aug 2007
        • 3

        #4
        Originally posted by ajaxrand
        And you have to Configure a SMTP server (For Local Server).

        May i know how to configure SMTP server?
        And what is POP 3?

        Comment

        • xiaofan
          New Member
          • Aug 2007
          • 3

          #5
          Originally posted by Jeigh
          [code=php]
          <?php

          $to = $_POST['to'];
          $subject = "Subject Here";
          $from = $_POST['from'];
          $message = $_POST['message'];

          $headers = "From: $from \r\n";
          $headers.= "Content-Type: text/html; charset=ISO-8859-1 ";
          $headers .= "MIME-Version: 1.0 ";

          mail($to, $subject, $message, $headers);

          ?>
          [/code]

          This should work, and it is a HTML email. If you don't want it to be you can just change the headers.

          Thank you jeigh
          thanks for generate an answer for me

          Comment

          • ak1dnar
            Recognized Expert Top Contributor
            • Jan 2007
            • 1584

            #6
            Originally posted by xiaofan
            May i know how to configure SMTP server?
            Locate your php.ini file and do the changes.


            Code:
            ; Setup for Windows systems 
            SMTP = smtp.your.isp.net 
            sendmail_from = me@domain.com
            Code:
            ; Setup for Linux systems 
            sendmail_path = /usr/sbin/sendmail -t 
            sendmail_from = me@domain.com
            Originally posted by xiaofan
            And what is POP 3?
            POP3 is the abbreviation for Post Office Protocol (version 3)
            It is an e-mail protocol used to retrieve e-mail from a remote server over an Internet connection.

            Comment

            • ak1dnar
              Recognized Expert Top Contributor
              • Jan 2007
              • 1584

              #7
              Thread Title : Generate example.php for me? Changed.

              Please Find Why? and how to Create Good Thread Title

              Thanks

              Comment

              Working...