PHP

 
 
PHP (= Hypertext Preprocessor) is an HTML-embedded server-side scripting language.

PHP is distributed at no charge for commercial or non-commercial use. For more information read the LICENSE information.

More information about PHP can be found at: http://www.php.net

PHP manuals can be found at:
http://www.php.net/manual/en/
http://devzone.zend.com/manual/

The latest PHP version can be downloaded from: http://www.php.net/downloads.php

rss feed






Sending mail



Information
none

Operating system used
Windows XP Home Edition Version 5.1 SP 2

Software prerequisites
PHP 4


Procedure
  1. Sending mail without SMTP authentication

    • If you are hosting your website on your workstation and you are connected to the internet by an ADSL/Cable connection and NO SMTP authentication is required to send email then you need to modify your php.ini file.

      Sending mail with no authentication

      Modify file c:\WINDOWS\php.ini. Change the following lines:

      [mail function]
      ; For Win32 only.
      SMTP = smtp.myisp.com
      smtp_port = 25

      ; For Win32 only.
      sendmail_from = [email protected]


      Variable Value
      SMTP Enter the SMTP server address of your ISP
      (=Internet Service Provider)
      sendmail_from Enter your email address issued by the ISP

      If your website is hosted by a hosting provider then you do not need to edit the php.ini file.

    • To send an email, create the following sendmail.php script:

      <?php

      /*
      $user_email = $_REQUEST['Email'] ;
      $message = $_REQUEST['Message'] ;
      */

      $user_email = "[email protected]";
      $message = "Hello World!";

      $to_email = "[email protected]";
      $subject = "Mobilefish.com Email";

      mail( $to_email, $subject, $message, "From: $user_email" );
      header( "Location: http://www.mobilefish.com/popupwindow/contact_thanks.html" );

      ?>




  2. Sending mail with SMTP authentication

    • If you are hosting your website on your workstation and you are connected to the internet by an ADSL/Cable connection and SMTP authentication is required then you need to install the PEAR packages first. In particular the PEAR Mail package.
      See quick guide: Install PEAR.

      Sending mail with authentication

    • After PEAR is installed, you can now send an email. Create the following sendmail.php script:

      <?php require_once "Mail.php";

      /*
      $user_email = $_REQUEST['Email'] ;
      $message = $_REQUEST['Message'] ;
      */

      $user_email = "[email protected]";
      $from_email = "[email protected]";
      $to_email = "[email protected]";
      $subject = "Mobilefish.com Email";
      $message = "Hello World!" . "\n\n Message send from: " . $user_email;

      $host = "smtp.myisp.com";
      $username = "myaccount";
      $password = "mypassword";

      $headers = array ('From' => $from_email,'To' => $to_email,'Subject' => $subject);
      $smtp = Mail::factory('smtp',array ('host' => $host,'auth' => true,'username' => $username,'password' => $password));

      $mail = $smtp->send($to_email, $headers, $message);

      if (PEAR::isError($mail)) {
      echo("<p>" . $mail->getMessage() . "</p>");
      } else {
      echo("<p>Message successfully sent!</p>"); }

      ?>