SMTP mail form with PEAR and WAMPServer?

  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

honestly, I've been working on this for days and have gotten nowhere. No idea what to write for code, no idea how to get it to send, no idea where I left my brain when it leaked out of my head.

I'd post some code for you guys to look at, but I don't have any, like I said, none of it is working, nor is it even close.

I need the form on this site: http://173.11.86.101/voltec/ to post to a php file that works with PEARs mail addon.

I've looked at about 20 different sites, read through the tutorials bogey posted here, as well as 10 - 15 tuts elsewhere. Any help guys?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

Show me the PEAR mail addon... can you also explain the problem a little more? What exactly are you trying to do... you want those things in the form sent to you VIA email?

I can send you the SMTP Class that I got and modified a little bit... it works perfectly. (I use it to send account verification, contact me, or user to user email sending and my other emailing needs).


It looks like the PEAR's mail addon is missing at least one dependency. (Mail.php asked for in sendemail.php).
  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

I believe this is the pear package that's installed

php 5, the newest stable release.

yes, I want the form data to be sent to an email through an SMTP server when the user hits submit.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

The SMTP class that I use is...

Code: [ Select ]
<?php
// Mail.php
class mail
{
    private $smtpServer = 'smtp.site.com';
    private $port = '25';
    private $timeout = 30;
    private $username = 'smtp_user';
    private $password = 'smtp_pass';
    private $username_email = 'admin@site.com';
    private $newline = "\r\n";
    private $localdomain = 'site.com';
    private $charset = 'windows-1251';
    private $contentTransferEncoding = false;
 
    // Do not change anything below
    private $smtpConnect = false;
    private $to = false;
    private $subject = false;
    private $message = false;
    private $headers = false;
    private $logArray = array(); // Array response message for debug
    private $Error = '';
 
    public function __construct($to, $subject, $message, $to2 = false) {
        $this->to = (($to2 !== false)? $this->username_email : $to);
        $this->subject = &$subject;
        $this->message = &$message;
       
        // Connect to server
        if(!$this->Connect2Server()) {
            // Display error message
            echo '<pre>'.trim($this->Error).'</pre>'.$this->newline.'<!-- '.$this->newline;
            print_r($this->logArray);
            echo $this->newline.'-->'.$this->newline;
            return false;
        }
        return true;
    }
 
    private function Connect2Server() {
        $from = (($to2 == false)? $this->username_email : $to);
       
        // Connect to server
        $this->smtpConnect = fsockopen($this->smtpServer,$this->port,$errno,$error,$this->timeout);
        $this->logArray['CONNECT_RESPONSE'] = $this->readResponse();
 
        if (!is_resource($this->smtpConnect)) {
            return false;
        }
        $this->logArray['connection'] = "Connection accepted: {$smtpResponse}";
        // Hi, server!
        $this->sendCommand("HELO {$this->localdomain}");
        $this->logArray['HELO'] = $this->readResponse();
        // Let's know each other
        $this->sendCommand('AUTH LOGIN');
        $this->logArray['AUTH_REQUEST'] = $this->readResponse();
        // My name...
        $this->sendCommand(base64_encode($this->username));
        $this->logArray['REQUEST_USER'] = $this->readResponse();
        // My password..
        $this->sendCommand(base64_encode($this->password));
        $this->logArray['REQUEST_PASSWD'] = $this->readResponse();
        // If error in response auth...
        if (substr($this->logArray['REQUEST_PASSWD'],0,3)!='235') {
            $this->Error .= 'Authorization error! '.$this->logArray['REQUEST_PASSWD'].$this->newline;
            return false;
        }
        // "From" mail...
        $this->sendCommand("MAIL FROM: {$from}");
        $this->logArray['MAIL_FROM_RESPONSE'] = $this->readResponse();
        if (substr($this->logArray['MAIL_FROM_RESPONSE'],0,3)!='250') {
            $this->Error .= 'Mistake in sender\'s address! '.$this->logArray['MAIL_FROM_RESPONSE'].$this->newline;
            return false;
        }
        // "To" address
        $this->sendCommand("RCPT TO: {$this->to}");
        $this->logArray['RCPT_TO_RESPONCE'] = $this->readResponse();
        if(substr($this->logArray['RCPT_TO_RESPONCE'],0,3) != '250')
        {
            $this->Error .= 'Mistake in reciepent address! '.$this->logArray['RCPT_TO_RESPONCE'].$this->newline;
        }
        // Send data to server
        $this->sendCommand('DATA');
        $this->logArray['DATA_RESPONSE'] = $this->readResponse();
        // Send mail message
        if (!$this->sendMail()) return false;
        // Good bye server! =)
        $this->sendCommand('QUIT');
        $this->logArray['QUIT_RESPONSE'] = $this->readResponse();
        // Close smtp connect
        fclose($this->smtpConnect);
        return true;
    }
    // Function send mail
    private function sendMail() {
        $this->sendHeaders();
        $this->sendCommand($this->message);
        $this->sendCommand('.');
        $this->logArray['SEND_DATA_RESPONSE'] = $this->readResponse();
        if(substr($this->logArray['SEND_DATA_RESPONSE'],0,3)!='250') {
            $this->Error .= 'Mistake in sending data! '.$this->logArray['SEND_DATA_RESPONSE'].$this->newline;
            return false;
        }
        return true;
    }
    // Function read response
    private function readResponse() {
        $data="";
        while($str = fgets($this->smtpConnect,4096))
        {
            $data .= $str;
            if(substr($str,3,1) == " ") { break; }
        }
        return $data;
    }
    // function send command to server
    private function sendCommand($string) {
        fputs($this->smtpConnect,$string.$this->newline);
        return ;
    }
    // function send headers
    private function sendHeaders() {
        $from = (($to2 == false)? $this->username_email : $to);
        $this->sendCommand("Date: ".date("D, j M Y G:i:s")." +0700");
        $this->sendCommand("From: <{$from}>");
        $this->sendCommand("Reply-To: <{$from}>");
        $this->sendCommand("To: <{$this->to}>");
        $this->sendCommand("Subject: {$this->subject}");
        $this->sendCommand("MIME-Version: 1.0");
        $this->sendCommand("Content-Type: text/html; charset={$this->charset}");
        if ($this->contentTransferEncoding) $this->sendCommand("Content-Transfer-Encoding: {$this->contentTransferEncoding}");
        return ;
    }
 
    public function __destruct() {
        if (is_resource($this->smtpConnect)) fclose($this->smtpConnect);
    }
}
?>
  1. <?php
  2. // Mail.php
  3. class mail
  4. {
  5.     private $smtpServer = 'smtp.site.com';
  6.     private $port = '25';
  7.     private $timeout = 30;
  8.     private $username = 'smtp_user';
  9.     private $password = 'smtp_pass';
  10.     private $username_email = 'admin@site.com';
  11.     private $newline = "\r\n";
  12.     private $localdomain = 'site.com';
  13.     private $charset = 'windows-1251';
  14.     private $contentTransferEncoding = false;
  15.  
  16.     // Do not change anything below
  17.     private $smtpConnect = false;
  18.     private $to = false;
  19.     private $subject = false;
  20.     private $message = false;
  21.     private $headers = false;
  22.     private $logArray = array(); // Array response message for debug
  23.     private $Error = '';
  24.  
  25.     public function __construct($to, $subject, $message, $to2 = false) {
  26.         $this->to = (($to2 !== false)? $this->username_email : $to);
  27.         $this->subject = &$subject;
  28.         $this->message = &$message;
  29.        
  30.         // Connect to server
  31.         if(!$this->Connect2Server()) {
  32.             // Display error message
  33.             echo '<pre>'.trim($this->Error).'</pre>'.$this->newline.'<!-- '.$this->newline;
  34.             print_r($this->logArray);
  35.             echo $this->newline.'-->'.$this->newline;
  36.             return false;
  37.         }
  38.         return true;
  39.     }
  40.  
  41.     private function Connect2Server() {
  42.         $from = (($to2 == false)? $this->username_email : $to);
  43.        
  44.         // Connect to server
  45.         $this->smtpConnect = fsockopen($this->smtpServer,$this->port,$errno,$error,$this->timeout);
  46.         $this->logArray['CONNECT_RESPONSE'] = $this->readResponse();
  47.  
  48.         if (!is_resource($this->smtpConnect)) {
  49.             return false;
  50.         }
  51.         $this->logArray['connection'] = "Connection accepted: {$smtpResponse}";
  52.         // Hi, server!
  53.         $this->sendCommand("HELO {$this->localdomain}");
  54.         $this->logArray['HELO'] = $this->readResponse();
  55.         // Let's know each other
  56.         $this->sendCommand('AUTH LOGIN');
  57.         $this->logArray['AUTH_REQUEST'] = $this->readResponse();
  58.         // My name...
  59.         $this->sendCommand(base64_encode($this->username));
  60.         $this->logArray['REQUEST_USER'] = $this->readResponse();
  61.         // My password..
  62.         $this->sendCommand(base64_encode($this->password));
  63.         $this->logArray['REQUEST_PASSWD'] = $this->readResponse();
  64.         // If error in response auth...
  65.         if (substr($this->logArray['REQUEST_PASSWD'],0,3)!='235') {
  66.             $this->Error .= 'Authorization error! '.$this->logArray['REQUEST_PASSWD'].$this->newline;
  67.             return false;
  68.         }
  69.         // "From" mail...
  70.         $this->sendCommand("MAIL FROM: {$from}");
  71.         $this->logArray['MAIL_FROM_RESPONSE'] = $this->readResponse();
  72.         if (substr($this->logArray['MAIL_FROM_RESPONSE'],0,3)!='250') {
  73.             $this->Error .= 'Mistake in sender\'s address! '.$this->logArray['MAIL_FROM_RESPONSE'].$this->newline;
  74.             return false;
  75.         }
  76.         // "To" address
  77.         $this->sendCommand("RCPT TO: {$this->to}");
  78.         $this->logArray['RCPT_TO_RESPONCE'] = $this->readResponse();
  79.         if(substr($this->logArray['RCPT_TO_RESPONCE'],0,3) != '250')
  80.         {
  81.             $this->Error .= 'Mistake in reciepent address! '.$this->logArray['RCPT_TO_RESPONCE'].$this->newline;
  82.         }
  83.         // Send data to server
  84.         $this->sendCommand('DATA');
  85.         $this->logArray['DATA_RESPONSE'] = $this->readResponse();
  86.         // Send mail message
  87.         if (!$this->sendMail()) return false;
  88.         // Good bye server! =)
  89.         $this->sendCommand('QUIT');
  90.         $this->logArray['QUIT_RESPONSE'] = $this->readResponse();
  91.         // Close smtp connect
  92.         fclose($this->smtpConnect);
  93.         return true;
  94.     }
  95.     // Function send mail
  96.     private function sendMail() {
  97.         $this->sendHeaders();
  98.         $this->sendCommand($this->message);
  99.         $this->sendCommand('.');
  100.         $this->logArray['SEND_DATA_RESPONSE'] = $this->readResponse();
  101.         if(substr($this->logArray['SEND_DATA_RESPONSE'],0,3)!='250') {
  102.             $this->Error .= 'Mistake in sending data! '.$this->logArray['SEND_DATA_RESPONSE'].$this->newline;
  103.             return false;
  104.         }
  105.         return true;
  106.     }
  107.     // Function read response
  108.     private function readResponse() {
  109.         $data="";
  110.         while($str = fgets($this->smtpConnect,4096))
  111.         {
  112.             $data .= $str;
  113.             if(substr($str,3,1) == " ") { break; }
  114.         }
  115.         return $data;
  116.     }
  117.     // function send command to server
  118.     private function sendCommand($string) {
  119.         fputs($this->smtpConnect,$string.$this->newline);
  120.         return ;
  121.     }
  122.     // function send headers
  123.     private function sendHeaders() {
  124.         $from = (($to2 == false)? $this->username_email : $to);
  125.         $this->sendCommand("Date: ".date("D, j M Y G:i:s")." +0700");
  126.         $this->sendCommand("From: <{$from}>");
  127.         $this->sendCommand("Reply-To: <{$from}>");
  128.         $this->sendCommand("To: <{$this->to}>");
  129.         $this->sendCommand("Subject: {$this->subject}");
  130.         $this->sendCommand("MIME-Version: 1.0");
  131.         $this->sendCommand("Content-Type: text/html; charset={$this->charset}");
  132.         if ($this->contentTransferEncoding) $this->sendCommand("Content-Transfer-Encoding: {$this->contentTransferEncoding}");
  133.         return ;
  134.     }
  135.  
  136.     public function __destruct() {
  137.         if (is_resource($this->smtpConnect)) fclose($this->smtpConnect);
  138.     }
  139. }
  140. ?>

The $smtpServer is the SMTP server that you are using. GMAIL does this, or you can use yours if you have one.

The $port is the port number for the SMTP server.

The $username is the username used to log-in to SMTP server.

The $password is the password used with the username to log-in to SMTP server.

The $username_email is your main email where the mails would be sent to.

The $localdomain is your domain.

And to use it with your information...
Code: [ Select ]
<?php
/* Some required variables to configure this page */
 
// Variables not to be sent to you
$blocked = array('submit1');
 
// The email address the result of the form would be sent to.
$adm_email = 'your_email@your_host.com'
 
// The prefix to the mail
$mail_prefix = 'A ' . $_POST['service'] . ' request was sent to you from ' . $_POST['firstname'] . ' ' . $_POST['lastname'] . '\r\n <hr />';
 
// The post (signature) to the mail
$mail_post = null;
 
// The title for the message
$title = 'A ' . $_POST['service'] . ' request was sent to you from ' . $_POST['firstname'] . ' ' . $_POST['lastname'];
 
/* The actual code body for sending */
 
// Initiating the body var
$body = $mail_prefix;
 
// Initiating some numeric values that would be incremented in the following loop
$blocked_num = 0;
 
// Building the body for the mail
foreach($_POST as $field_name => $field_value)
{
    // Building the body for the mail with the correct fields
    if($field_name != $blocked[$blocked_num])
        $body .= "<strong>{$field_name}</strong>: {$_POST[$field_name]}<br />\r\n";
 
    // Initiating the blocked num counter if needed
    if(count($blocked) < $blocked_num)
        ++$blocked_num;
}
 
// Ending the body var
$body .= $mail_post;
 
// Trimming the ends of body from any unneeded white spaces
$body = trim($body);
 
// Requiring the SMTP class
require_once 'mail.php';
 
// Initiating the mail object
$mail = new mail();
 
// Sending the message
if(new mail($_POST['email'], $title, $body, true))
    echo 'The mail was successfully sent. Thank you for your time!';
else
    echo 'There was an error in the mailling service.';
?>
  1. <?php
  2. /* Some required variables to configure this page */
  3.  
  4. // Variables not to be sent to you
  5. $blocked = array('submit1');
  6.  
  7. // The email address the result of the form would be sent to.
  8. $adm_email = 'your_email@your_host.com'
  9.  
  10. // The prefix to the mail
  11. $mail_prefix = 'A ' . $_POST['service'] . ' request was sent to you from ' . $_POST['firstname'] . ' ' . $_POST['lastname'] . '\r\n <hr />';
  12.  
  13. // The post (signature) to the mail
  14. $mail_post = null;
  15.  
  16. // The title for the message
  17. $title = 'A ' . $_POST['service'] . ' request was sent to you from ' . $_POST['firstname'] . ' ' . $_POST['lastname'];
  18.  
  19. /* The actual code body for sending */
  20.  
  21. // Initiating the body var
  22. $body = $mail_prefix;
  23.  
  24. // Initiating some numeric values that would be incremented in the following loop
  25. $blocked_num = 0;
  26.  
  27. // Building the body for the mail
  28. foreach($_POST as $field_name => $field_value)
  29. {
  30.     // Building the body for the mail with the correct fields
  31.     if($field_name != $blocked[$blocked_num])
  32.         $body .= "<strong>{$field_name}</strong>: {$_POST[$field_name]}<br />\r\n";
  33.  
  34.     // Initiating the blocked num counter if needed
  35.     if(count($blocked) < $blocked_num)
  36.         ++$blocked_num;
  37. }
  38.  
  39. // Ending the body var
  40. $body .= $mail_post;
  41.  
  42. // Trimming the ends of body from any unneeded white spaces
  43. $body = trim($body);
  44.  
  45. // Requiring the SMTP class
  46. require_once 'mail.php';
  47.  
  48. // Initiating the mail object
  49. $mail = new mail();
  50.  
  51. // Sending the message
  52. if(new mail($_POST['email'], $title, $body, true))
  53.     echo 'The mail was successfully sent. Thank you for your time!';
  54. else
  55.     echo 'There was an error in the mailling service.';
  56. ?>

I hope that made sense. And I hope that helps :D


About the PEAR thing. Make sure that Mail.php is in the correct directory and that the include code has the correct address to Mail.php
  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

how do I set an include? Sorry bogey, I'm definitely a noob when it comes to php
  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

how would I go about setting the "services" field and the email field as the subject of the email, and set the rest of the fields as the body of the email?
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

Can you post the code you got in 'sendemail.php'?

Although that isn't important. Let me try to explain this without seeing the code, but if you are still having some problems, could you please post the code here, unless you are afraid of people stealing your work.

include('Mail.php');
Whatever is in between the single-quotes " ' ", is the address to the file you want to include into the current file (sendemail.php). Is that address correct?

I may have worded something wrong, and if I did, I'm sorry :)
  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

this is what is in the sendemail.php

PHP Code: [ Select ]
 
<?php
include("Mail.php");
 
$name = $_REQUEST['firsstname'] ;
$email = $_REQUEST['email'] ;
$message = $_REQUEST['textarea'] ;
$subject = $_REQUEST['service'] ;
 
/* mail setup recipients, subject etc */
$recipients = "feedback@yourdot.com";
$headers["From"] = "$email";
$headers["To"] = "email@example.com";
$headers["Subject"] = "$subject";
$mailmsg = "$subject";
/* SMTP server name, port, user/passwd */
$smtpinfo["host"] = "host.domain.com";
$smtpinfo["port"] = "25";
$smtpinfo["auth"] = true;
$smtpinfo["username"] = "username";
$smtpinfo["password"] = "password";
/* Create the mail object using the Mail::factory method */
$mail_object =& Mail::factory("smtp", $smtpinfo);
/* Ok send mail */
$mail_object->send($recipients, $headers, $mailmsg);
?>
 
  1.  
  2. <?php
  3. include("Mail.php");
  4.  
  5. $name = $_REQUEST['firsstname'] ;
  6. $email = $_REQUEST['email'] ;
  7. $message = $_REQUEST['textarea'] ;
  8. $subject = $_REQUEST['service'] ;
  9.  
  10. /* mail setup recipients, subject etc */
  11. $recipients = "feedback@yourdot.com";
  12. $headers["From"] = "$email";
  13. $headers["To"] = "email@example.com";
  14. $headers["Subject"] = "$subject";
  15. $mailmsg = "$subject";
  16. /* SMTP server name, port, user/passwd */
  17. $smtpinfo["host"] = "host.domain.com";
  18. $smtpinfo["port"] = "25";
  19. $smtpinfo["auth"] = true;
  20. $smtpinfo["username"] = "username";
  21. $smtpinfo["password"] = "password";
  22. /* Create the mail object using the Mail::factory method */
  23. $mail_object =& Mail::factory("smtp", $smtpinfo);
  24. /* Ok send mail */
  25. $mail_object->send($recipients, $headers, $mailmsg);
  26. ?>
  27.  
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

Where is your Mail.php located?

Also, that's firstname, NOT firsstname.
  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

bin/wamp/bin/php/php5.2.9-2/PEAR/Structures/Mail.php.

This file (mail.php) has these contents:

Code: [ Select ]
 
<?php
//
// +----------------------------------------------------------------------+
// | PHP Version 4                                                        |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group                                |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license,      |
// | that is bundled with this package in the file LICENSE, and is        |
// | available at through the world-wide-web at                           |
// | http://www.php.net/license/2_02.txt.                                 |
// | If you did not receive a copy of the PHP license and are unable to   |
// | obtain it through the world-wide-web, please send a note to          |
// | license@php.net so we can mail you a copy immediately.               |
// +----------------------------------------------------------------------+
// | Author: Chuck Hagenbuch <chuck@horde.org>                            |
// +----------------------------------------------------------------------+
//
// $Id: Mail.php,v 1.17 2006/09/15 03:41:18 jon Exp $
 
require_once 'PEAR.php';
 
/**
 * PEAR's Mail:: interface. Defines the interface for implementing
 * mailers under the PEAR hierarchy, and provides supporting functions
 * useful in multiple mailer backends.
 *
 * @access public
 * @version $Revision: 1.17 $
 * @package Mail
 */
class Mail
{
    /**
     * Line terminator used for separating header lines.
     * @var string
     */
    var $sep = "\r\n";
 
    /**
     * Provides an interface for generating Mail:: objects of various
     * types
     *
     * @param string $driver The kind of Mail:: object to instantiate.
     * @param array  $params The parameters to pass to the Mail:: object.
     * @return object Mail a instance of the driver class or if fails a PEAR Error
     * @access public
     */
    function &factory($driver, $params = array())
    {
        $driver = strtolower($driver);
        @include_once 'Mail/' . $driver . '.php';
        $class = 'Mail_' . $driver;
        if (class_exists($class)) {
            $mailer = new $class($params);
            return $mailer;
        } else {
            return PEAR::raiseError('Unable to find class for driver ' . $driver);
        }
    }
 
    /**
     * Implements Mail::send() function using php's built-in mail()
     * command.
     *
     * @param mixed $recipients Either a comma-seperated list of recipients
     *              (RFC822 compliant), or an array of recipients,
     *              each RFC822 valid. This may contain recipients not
     *              specified in the headers, for Bcc:, resending
     *              messages, etc.
     *
     * @param array $headers The array of headers to send with the mail, in an
     *              associative array, where the array key is the
     *              header name (ie, 'Subject'), and the array value
     *              is the header value (ie, 'test'). The header
     *              produced from those values would be 'Subject:
     *              test'.
     *
     * @param string $body The full text of the message body, including any
     *               Mime parts, etc.
     *
     * @return mixed Returns true on success, or a PEAR_Error
     *               containing a descriptive error message on
     *               failure.
     * @access public
     * @deprecated use Mail_mail::send instead
     */
    function send($recipients, $headers, $body)
    {
        $this->_sanitizeHeaders($headers);
 
        // if we're passed an array of recipients, implode it.
        if (is_array($recipients)) {
            $recipients = implode(', ', $recipients);
        }
 
        // get the Subject out of the headers array so that we can
        // pass it as a seperate argument to mail().
        $subject = '';
        if (isset($headers['Subject'])) {
            $subject = $headers['Subject'];
            unset($headers['Subject']);
        }
 
        // flatten the headers out.
        list(,$text_headers) = Mail::prepareHeaders($headers);
 
        return mail($recipients, $subject, $body, $text_headers);
 
    }
 
    /**
     * Sanitize an array of mail headers by removing any additional header
     * strings present in a legitimate header's value.  The goal of this
     * filter is to prevent mail injection attacks.
     *
     * @param array $headers The associative array of headers to sanitize.
     *
     * @access private
     */
    function _sanitizeHeaders(&$headers)
    {
        foreach ($headers as $key => $value) {
            $headers[$key] =
                preg_replace('=((<CR>|<LF>|0x0A/%0A|0x0D/%0D|\n|\r)\S).*=i',
                             null, $value);
        }
    }
 
    /**
     * Take an array of mail headers and return a string containing
     * text usable in sending a message.
     *
     * @param array $headers The array of headers to prepare, in an associative
     *              array, where the array key is the header name (ie,
     *              'Subject'), and the array value is the header
     *              value (ie, 'test'). The header produced from those
     *              values would be 'Subject: test'.
     *
     * @return mixed Returns false if it encounters a bad address,
     *               otherwise returns an array containing two
     *               elements: Any From: address found in the headers,
     *               and the plain text version of the headers.
     * @access private
     */
    function prepareHeaders($headers)
    {
        $lines = array();
        $from = null;
 
        foreach ($headers as $key => $value) {
            if (strcasecmp($key, 'From') === 0) {
                include_once 'Mail/RFC822.php';
                $parser = &new Mail_RFC822();
                $addresses = $parser->parseAddressList($value, 'localhost', false);
                if (PEAR::isError($addresses)) {
                    return $addresses;
                }
 
                $from = $addresses[0]->mailbox . '@' . $addresses[0]->host;
 
                // Reject envelope From: addresses with spaces.
                if (strstr($from, ' ')) {
                    return false;
                }
 
                $lines[] = $key . ': ' . $value;
            } elseif (strcasecmp($key, 'Received') === 0) {
                $received = array();
                if (is_array($value)) {
                    foreach ($value as $line) {
                        $received[] = $key . ': ' . $line;
                    }
                }
                else {
                    $received[] = $key . ': ' . $value;
                }
                // Put Received: headers at the top.  Spam detectors often
                // flag messages with Received: headers after the Subject:
                // as spam.
                $lines = array_merge($received, $lines);
            } else {
                // If $value is an array (i.e., a list of addresses), convert
                // it to a comma-delimited string of its elements (addresses).
                if (is_array($value)) {
                    $value = implode(', ', $value);
                }
                $lines[] = $key . ': ' . $value;
            }
        }
 
        return array($from, join($this->sep, $lines));
    }
 
    /**
     * Take a set of recipients and parse them, returning an array of
     * bare addresses (forward paths) that can be passed to sendmail
     * or an smtp server with the rcpt to: command.
     *
     * @param mixed Either a comma-seperated list of recipients
     *              (RFC822 compliant), or an array of recipients,
     *              each RFC822 valid.
     *
     * @return mixed An array of forward paths (bare addresses) or a PEAR_Error
     *               object if the address list could not be parsed.
     * @access private
     */
    function parseRecipients($recipients)
    {
        include_once 'Mail/RFC822.php';
 
        // if we're passed an array, assume addresses are valid and
        // implode them before parsing.
        if (is_array($recipients)) {
            $recipients = implode(', ', $recipients);
        }
 
        // Parse recipients, leaving out all personal info. This is
        // for smtp recipients, etc. All relevant personal information
        // should already be in the headers.
        $addresses = Mail_RFC822::parseAddressList($recipients, 'localhost', false);
 
        // If parseAddressList() returned a PEAR_Error object, just return it.
        if (PEAR::isError($addresses)) {
            return $addresses;
        }
 
        $recipients = array();
        if (is_array($addresses)) {
            foreach ($addresses as $ob) {
                $recipients[] = $ob->mailbox . '@' . $ob->host;
            }
        }
 
        return $recipients;
    }
 
}
 
  1.  
  2. <?php
  3. //
  4. // +----------------------------------------------------------------------+
  5. // | PHP Version 4                                                        |
  6. // +----------------------------------------------------------------------+
  7. // | Copyright (c) 1997-2003 The PHP Group                                |
  8. // +----------------------------------------------------------------------+
  9. // | This source file is subject to version 2.02 of the PHP license,      |
  10. // | that is bundled with this package in the file LICENSE, and is        |
  11. // | available at through the world-wide-web at                           |
  12. // | http://www.php.net/license/2_02.txt.                                 |
  13. // | If you did not receive a copy of the PHP license and are unable to   |
  14. // | obtain it through the world-wide-web, please send a note to          |
  15. // | license@php.net so we can mail you a copy immediately.               |
  16. // +----------------------------------------------------------------------+
  17. // | Author: Chuck Hagenbuch <chuck@horde.org>                            |
  18. // +----------------------------------------------------------------------+
  19. //
  20. // $Id: Mail.php,v 1.17 2006/09/15 03:41:18 jon Exp $
  21.  
  22. require_once 'PEAR.php';
  23.  
  24. /**
  25.  * PEAR's Mail:: interface. Defines the interface for implementing
  26.  * mailers under the PEAR hierarchy, and provides supporting functions
  27.  * useful in multiple mailer backends.
  28.  *
  29.  * @access public
  30.  * @version $Revision: 1.17 $
  31.  * @package Mail
  32.  */
  33. class Mail
  34. {
  35.     /**
  36.      * Line terminator used for separating header lines.
  37.      * @var string
  38.      */
  39.     var $sep = "\r\n";
  40.  
  41.     /**
  42.      * Provides an interface for generating Mail:: objects of various
  43.      * types
  44.      *
  45.      * @param string $driver The kind of Mail:: object to instantiate.
  46.      * @param array  $params The parameters to pass to the Mail:: object.
  47.      * @return object Mail a instance of the driver class or if fails a PEAR Error
  48.      * @access public
  49.      */
  50.     function &factory($driver, $params = array())
  51.     {
  52.         $driver = strtolower($driver);
  53.         @include_once 'Mail/' . $driver . '.php';
  54.         $class = 'Mail_' . $driver;
  55.         if (class_exists($class)) {
  56.             $mailer = new $class($params);
  57.             return $mailer;
  58.         } else {
  59.             return PEAR::raiseError('Unable to find class for driver ' . $driver);
  60.         }
  61.     }
  62.  
  63.     /**
  64.      * Implements Mail::send() function using php's built-in mail()
  65.      * command.
  66.      *
  67.      * @param mixed $recipients Either a comma-seperated list of recipients
  68.      *              (RFC822 compliant), or an array of recipients,
  69.      *              each RFC822 valid. This may contain recipients not
  70.      *              specified in the headers, for Bcc:, resending
  71.      *              messages, etc.
  72.      *
  73.      * @param array $headers The array of headers to send with the mail, in an
  74.      *              associative array, where the array key is the
  75.      *              header name (ie, 'Subject'), and the array value
  76.      *              is the header value (ie, 'test'). The header
  77.      *              produced from those values would be 'Subject:
  78.      *              test'.
  79.      *
  80.      * @param string $body The full text of the message body, including any
  81.      *               Mime parts, etc.
  82.      *
  83.      * @return mixed Returns true on success, or a PEAR_Error
  84.      *               containing a descriptive error message on
  85.      *               failure.
  86.      * @access public
  87.      * @deprecated use Mail_mail::send instead
  88.      */
  89.     function send($recipients, $headers, $body)
  90.     {
  91.         $this->_sanitizeHeaders($headers);
  92.  
  93.         // if we're passed an array of recipients, implode it.
  94.         if (is_array($recipients)) {
  95.             $recipients = implode(', ', $recipients);
  96.         }
  97.  
  98.         // get the Subject out of the headers array so that we can
  99.         // pass it as a seperate argument to mail().
  100.         $subject = '';
  101.         if (isset($headers['Subject'])) {
  102.             $subject = $headers['Subject'];
  103.             unset($headers['Subject']);
  104.         }
  105.  
  106.         // flatten the headers out.
  107.         list(,$text_headers) = Mail::prepareHeaders($headers);
  108.  
  109.         return mail($recipients, $subject, $body, $text_headers);
  110.  
  111.     }
  112.  
  113.     /**
  114.      * Sanitize an array of mail headers by removing any additional header
  115.      * strings present in a legitimate header's value.  The goal of this
  116.      * filter is to prevent mail injection attacks.
  117.      *
  118.      * @param array $headers The associative array of headers to sanitize.
  119.      *
  120.      * @access private
  121.      */
  122.     function _sanitizeHeaders(&$headers)
  123.     {
  124.         foreach ($headers as $key => $value) {
  125.             $headers[$key] =
  126.                 preg_replace('=((<CR>|<LF>|0x0A/%0A|0x0D/%0D|\n|\r)\S).*=i',
  127.                              null, $value);
  128.         }
  129.     }
  130.  
  131.     /**
  132.      * Take an array of mail headers and return a string containing
  133.      * text usable in sending a message.
  134.      *
  135.      * @param array $headers The array of headers to prepare, in an associative
  136.      *              array, where the array key is the header name (ie,
  137.      *              'Subject'), and the array value is the header
  138.      *              value (ie, 'test'). The header produced from those
  139.      *              values would be 'Subject: test'.
  140.      *
  141.      * @return mixed Returns false if it encounters a bad address,
  142.      *               otherwise returns an array containing two
  143.      *               elements: Any From: address found in the headers,
  144.      *               and the plain text version of the headers.
  145.      * @access private
  146.      */
  147.     function prepareHeaders($headers)
  148.     {
  149.         $lines = array();
  150.         $from = null;
  151.  
  152.         foreach ($headers as $key => $value) {
  153.             if (strcasecmp($key, 'From') === 0) {
  154.                 include_once 'Mail/RFC822.php';
  155.                 $parser = &new Mail_RFC822();
  156.                 $addresses = $parser->parseAddressList($value, 'localhost', false);
  157.                 if (PEAR::isError($addresses)) {
  158.                     return $addresses;
  159.                 }
  160.  
  161.                 $from = $addresses[0]->mailbox . '@' . $addresses[0]->host;
  162.  
  163.                 // Reject envelope From: addresses with spaces.
  164.                 if (strstr($from, ' ')) {
  165.                     return false;
  166.                 }
  167.  
  168.                 $lines[] = $key . ': ' . $value;
  169.             } elseif (strcasecmp($key, 'Received') === 0) {
  170.                 $received = array();
  171.                 if (is_array($value)) {
  172.                     foreach ($value as $line) {
  173.                         $received[] = $key . ': ' . $line;
  174.                     }
  175.                 }
  176.                 else {
  177.                     $received[] = $key . ': ' . $value;
  178.                 }
  179.                 // Put Received: headers at the top.  Spam detectors often
  180.                 // flag messages with Received: headers after the Subject:
  181.                 // as spam.
  182.                 $lines = array_merge($received, $lines);
  183.             } else {
  184.                 // If $value is an array (i.e., a list of addresses), convert
  185.                 // it to a comma-delimited string of its elements (addresses).
  186.                 if (is_array($value)) {
  187.                     $value = implode(', ', $value);
  188.                 }
  189.                 $lines[] = $key . ': ' . $value;
  190.             }
  191.         }
  192.  
  193.         return array($from, join($this->sep, $lines));
  194.     }
  195.  
  196.     /**
  197.      * Take a set of recipients and parse them, returning an array of
  198.      * bare addresses (forward paths) that can be passed to sendmail
  199.      * or an smtp server with the rcpt to: command.
  200.      *
  201.      * @param mixed Either a comma-seperated list of recipients
  202.      *              (RFC822 compliant), or an array of recipients,
  203.      *              each RFC822 valid.
  204.      *
  205.      * @return mixed An array of forward paths (bare addresses) or a PEAR_Error
  206.      *               object if the address list could not be parsed.
  207.      * @access private
  208.      */
  209.     function parseRecipients($recipients)
  210.     {
  211.         include_once 'Mail/RFC822.php';
  212.  
  213.         // if we're passed an array, assume addresses are valid and
  214.         // implode them before parsing.
  215.         if (is_array($recipients)) {
  216.             $recipients = implode(', ', $recipients);
  217.         }
  218.  
  219.         // Parse recipients, leaving out all personal info. This is
  220.         // for smtp recipients, etc. All relevant personal information
  221.         // should already be in the headers.
  222.         $addresses = Mail_RFC822::parseAddressList($recipients, 'localhost', false);
  223.  
  224.         // If parseAddressList() returned a PEAR_Error object, just return it.
  225.         if (PEAR::isError($addresses)) {
  226.             return $addresses;
  227.         }
  228.  
  229.         $recipients = array();
  230.         if (is_array($addresses)) {
  231.             foreach ($addresses as $ob) {
  232.                 $recipients[] = $ob->mailbox . '@' . $ob->host;
  233.             }
  234.         }
  235.  
  236.         return $recipients;
  237.     }
  238.  
  239. }
  240.  
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

Does the filename has the capital 'M' or lowercase 'm'?

Try include("../../bin/php/php5.2.9-2/PEAR/Structures/Mail.php"); instead of include("Mail.php");

I don't know if that would work... I'm running out of ideas :lol:
  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

capitol.

I also have another with a lowercase located in the dir:

bin/wamp/bin/php/php5.2.9-2/PEAR/Mail/mail.php

it contains this code:
Code: [ Select ]
<?php
//
// +----------------------------------------------------------------------+
// | PHP Version 4                                                      |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group                              |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license,     |
// | that is bundled with this package in the file LICENSE, and is      |
// | available at through the world-wide-web at                          |
// | http://www.php.net/license/2_02.txt.                                 |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to         |
// | license@php.net so we can mail you a copy immediately.              |
// +----------------------------------------------------------------------+
// | Author: Chuck Hagenbuch <chuck@horde.org>                          |
// +----------------------------------------------------------------------+
//
// $Id: mail.php,v 1.18 2006/09/13 05:32:08 jon Exp $

/**
* internal PHP-mail() implementation of the PEAR Mail:: interface.
* @package Mail
* @version $Revision: 1.18 $
*/
class Mail_mail extends Mail {

    /**
    * Any arguments to pass to the mail() function.
    * @var string
    */
    var $_params = '';

    /**
    * Constructor.
    *
    * Instantiates a new Mail_mail:: object based on the parameters
    * passed in.
    *
    * @param array $params Extra arguments for the mail() function.
    */
    function Mail_mail($params = null)
    {
        /* The other mail implementations accept parameters as arrays.
        * In the interest of being consistent, explode an array into
        * a string of parameter arguments. */
        if (is_array($params)) {
            $this->_params = join(' ', $params);
        } else {
            $this->_params = $params;
        }

        /* Because the mail() function may pass headers as command
        * line arguments, we can't guarantee the use of the standard
        * "\r\n" separator. Instead, we use the system's native line
        * separator. */
        if (defined('PHP_EOL')) {
            $this->sep = PHP_EOL;
        } else {
            $this->sep = (strpos(PHP_OS, 'WIN') === false) ? "\n" : "\r\n";
        }
    }

    /**
    * Implements Mail_mail::send() function using php's built-in mail()
    * command.
    *
    * @param mixed $recipients Either a comma-seperated list of recipients
    *             (RFC822 compliant), or an array of recipients,
    *             each RFC822 valid. This may contain recipients not
    *             specified in the headers, for Bcc:, resending
    *             messages, etc.
    *
    * @param array $headers The array of headers to send with the mail, in an
    *             associative array, where the array key is the
    *             header name (ie, 'Subject'), and the array value
    *             is the header value (ie, 'test'). The header
    *             produced from those values would be 'Subject:
    *             test'.
    *
    * @param string $body The full text of the message body, including any
    *              Mime parts, etc.
    *
    * @return mixed Returns true on success, or a PEAR_Error
    *              containing a descriptive error message on
    *              failure.
    *
    * @access public
    */
    function send($recipients, $headers, $body)
    {
        $this->_sanitizeHeaders($headers);

        // If we're passed an array of recipients, implode it.
        if (is_array($recipients)) {
            $recipients = implode(', ', $recipients);
        }

        // Get the Subject out of the headers array so that we can
        // pass it as a seperate argument to mail().
        $subject = '';
        if (isset($headers['Subject'])) {
            $subject = $headers['Subject'];
            unset($headers['Subject']);
        }

        /*
        * Also remove the To: header. The mail() function will add its own
        * To: header based on the contents of $recipients.
        */
        unset($headers['To']);

        // Flatten the headers out.
        $headerElements = $this->prepareHeaders($headers);
        if (PEAR::isError($headerElements)) {
            return $headerElements;
        }
        list(, $text_headers) = $headerElements;

        /*
        * We only use mail()'s optional fifth parameter if the additional
        * parameters have been provided and we're not running in safe mode.
        */
        if (empty($this->_params) || ini_get('safe_mode')) {
            $result = mail($recipients, $subject, $body, $text_headers);
        } else {
            $result = mail($recipients, $subject, $body, $text_headers,
                         $this->_params);
        }

        /*
        * If the mail() function returned failure, we need to create a
        * PEAR_Error object and return it instead of the boolean result.
        */
        if ($result === false) {
            $result = PEAR::raiseError('mail() returned failure');
        }

        return $result;
    }

}
  1. <?php
  2. //
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4                                                      |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2003 The PHP Group                              |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.02 of the PHP license,     |
  9. // | that is bundled with this package in the file LICENSE, and is      |
  10. // | available at through the world-wide-web at                          |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to |
  13. // | obtain it through the world-wide-web, please send a note to         |
  14. // | license@php.net so we can mail you a copy immediately.              |
  15. // +----------------------------------------------------------------------+
  16. // | Author: Chuck Hagenbuch <chuck@horde.org>                          |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: mail.php,v 1.18 2006/09/13 05:32:08 jon Exp $
  20. /**
  21. * internal PHP-mail() implementation of the PEAR Mail:: interface.
  22. * @package Mail
  23. * @version $Revision: 1.18 $
  24. */
  25. class Mail_mail extends Mail {
  26.     /**
  27.     * Any arguments to pass to the mail() function.
  28.     * @var string
  29.     */
  30.     var $_params = '';
  31.     /**
  32.     * Constructor.
  33.     *
  34.     * Instantiates a new Mail_mail:: object based on the parameters
  35.     * passed in.
  36.     *
  37.     * @param array $params Extra arguments for the mail() function.
  38.     */
  39.     function Mail_mail($params = null)
  40.     {
  41.         /* The other mail implementations accept parameters as arrays.
  42.         * In the interest of being consistent, explode an array into
  43.         * a string of parameter arguments. */
  44.         if (is_array($params)) {
  45.             $this->_params = join(' ', $params);
  46.         } else {
  47.             $this->_params = $params;
  48.         }
  49.         /* Because the mail() function may pass headers as command
  50.         * line arguments, we can't guarantee the use of the standard
  51.         * "\r\n" separator. Instead, we use the system's native line
  52.         * separator. */
  53.         if (defined('PHP_EOL')) {
  54.             $this->sep = PHP_EOL;
  55.         } else {
  56.             $this->sep = (strpos(PHP_OS, 'WIN') === false) ? "\n" : "\r\n";
  57.         }
  58.     }
  59.     /**
  60.     * Implements Mail_mail::send() function using php's built-in mail()
  61.     * command.
  62.     *
  63.     * @param mixed $recipients Either a comma-seperated list of recipients
  64.     *             (RFC822 compliant), or an array of recipients,
  65.     *             each RFC822 valid. This may contain recipients not
  66.     *             specified in the headers, for Bcc:, resending
  67.     *             messages, etc.
  68.     *
  69.     * @param array $headers The array of headers to send with the mail, in an
  70.     *             associative array, where the array key is the
  71.     *             header name (ie, 'Subject'), and the array value
  72.     *             is the header value (ie, 'test'). The header
  73.     *             produced from those values would be 'Subject:
  74.     *             test'.
  75.     *
  76.     * @param string $body The full text of the message body, including any
  77.     *              Mime parts, etc.
  78.     *
  79.     * @return mixed Returns true on success, or a PEAR_Error
  80.     *              containing a descriptive error message on
  81.     *              failure.
  82.     *
  83.     * @access public
  84.     */
  85.     function send($recipients, $headers, $body)
  86.     {
  87.         $this->_sanitizeHeaders($headers);
  88.         // If we're passed an array of recipients, implode it.
  89.         if (is_array($recipients)) {
  90.             $recipients = implode(', ', $recipients);
  91.         }
  92.         // Get the Subject out of the headers array so that we can
  93.         // pass it as a seperate argument to mail().
  94.         $subject = '';
  95.         if (isset($headers['Subject'])) {
  96.             $subject = $headers['Subject'];
  97.             unset($headers['Subject']);
  98.         }
  99.         /*
  100.         * Also remove the To: header. The mail() function will add its own
  101.         * To: header based on the contents of $recipients.
  102.         */
  103.         unset($headers['To']);
  104.         // Flatten the headers out.
  105.         $headerElements = $this->prepareHeaders($headers);
  106.         if (PEAR::isError($headerElements)) {
  107.             return $headerElements;
  108.         }
  109.         list(, $text_headers) = $headerElements;
  110.         /*
  111.         * We only use mail()'s optional fifth parameter if the additional
  112.         * parameters have been provided and we're not running in safe mode.
  113.         */
  114.         if (empty($this->_params) || ini_get('safe_mode')) {
  115.             $result = mail($recipients, $subject, $body, $text_headers);
  116.         } else {
  117.             $result = mail($recipients, $subject, $body, $text_headers,
  118.                          $this->_params);
  119.         }
  120.         /*
  121.         * If the mail() function returned failure, we need to create a
  122.         * PEAR_Error object and return it instead of the boolean result.
  123.         */
  124.         if ($result === false) {
  125.             $result = PEAR::raiseError('mail() returned failure');
  126.         }
  127.         return $result;
  128.     }
  129. }
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

You were doing right. You were opening the Mail_smtp.php VIA factory in Mail.php... did you try the address I told you? Or that didn't work?
  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

see this is the thing - I didn't write any of this code. I've tried adjusting it to work with my form but to no avail. I have these files, packages, addons, etc. for php - but have no idea what to do with them.

Most are from PEAR, I think I have some from phpcodeguru.org, and one from about.com. I have all these files and no idea how to use them.

I remember doing a site with a contact form and not having any trouble with it because the host set up all of the php on the server, and I simply wrote the form html and used the "post" action to push it to mail.php.

This time, however, I'm having to set up the smtp php and have no idea what I'm doing. I've never used php before. At this point, I don't know what I should put in my index.html, my root directory, my Mail.php or mail.php files. I'm lost :(
  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

sendemail.php is still giving me errors. I have changed the include and the "firsstname" to "firstname"

These are the errors I'm getting:
Code: [ Select ]
Warning: include(Mail.php) [function.include]: failed to open stream: No such file or directory in C:\USR\bin\wamp\www\voltec\sendemail.php on line 2

Warning: include() [function.include]: Failed opening 'Mail.php' for inclusion (include_path='.;C:\php5\pear') in C:\USR\bin\wamp\www\voltec\sendemail.php on line 2
  1. Warning: include(Mail.php) [function.include]: failed to open stream: No such file or directory in C:\USR\bin\wamp\www\voltec\sendemail.php on line 2
  2. Warning: include() [function.include]: Failed opening 'Mail.php' for inclusion (include_path='.;C:\php5\pear') in C:\USR\bin\wamp\www\voltec\sendemail.php on line 2
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

Your default PEAR location in your config is wrong. (At least I think... :lol: ) Either that, or you have put the PEAR packages in the wrong directory. Put them in php5/pear directory.

What kind of server is this? What is the host?
  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

windows server 2003 I believe. The host is a buddy of mine who owns his own server.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

Did you try what I suggested?
  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

where should I put these scripts you gave me?

should I replace mail.php with the class you gave me, or should it go somewhere else?

What do I do with the second script you gave that somehow ties the class in with my form?

Where do I put them?
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

The mail class I gave you is NOT pear, so don't replace that with the Mail.php already in the PEAR package... Just put it either in the same directory where your form is, or a different directory, not replacing anything.

The second script that I have you that somehow ties the class in with my form, you should name it something... like for this example, simply 'sendmail.php'.

Then in the form, put your action as 'sendmail.php' and all should work after that (As long as you have configured the SMTP class I gave you with the correct credentials).
  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

lol, now when I hit submit my browser is downloading sendemail.php
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

It's downloading the script I gave you???
  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

wait, just kidding. I was viewing my local copy.
  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

for some reason I'm getting these errors:
Code: [ Select ]
Warning: include(Mail.php) [function.include]: failed to open stream: No such file or directory in C:\USR\bin\wamp\www\voltec\sendemail.php on line 2

Warning: include() [function.include]: Failed opening 'Mail.php' for inclusion (include_path='.;C:\php5\pear') in C:\USR\bin\wamp\www\voltec\sendemail.php on line 2

Notice: Undefined index: firsstname in C:\USR\bin\wamp\www\voltec\sendemail.php on line 4

Fatal error: Class 'Mail' not found in C:\USR\bin\wamp\www\voltec\sendemail.php on line 22
  1. Warning: include(Mail.php) [function.include]: failed to open stream: No such file or directory in C:\USR\bin\wamp\www\voltec\sendemail.php on line 2
  2. Warning: include() [function.include]: Failed opening 'Mail.php' for inclusion (include_path='.;C:\php5\pear') in C:\USR\bin\wamp\www\voltec\sendemail.php on line 2
  3. Notice: Undefined index: firsstname in C:\USR\bin\wamp\www\voltec\sendemail.php on line 4
  4. Fatal error: Class 'Mail' not found in C:\USR\bin\wamp\www\voltec\sendemail.php on line 22


I don't enderstand why it's telling me "Undefined index: firsstname" - I fixed that last night.

And the rest of the errors don't make sense to me. This is all using your class and script
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

Did you re-upload the files to the host? I kept checking your forms periodically and came to the conclusion that you haven't re-uploaded the fixed version.
  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

I just put the entire site with Dreamweaver twice
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

Rename the mailing class to something like 'pcon.php' or something obscure like that. Don't forget to change sendemail.php to reflect the change.
  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

ok, found out that there were 2 seperate copies; two seperate directories, for the same site. I was uploading to the wrong place.

Now that it's uploaded, I'm getting this error:

Code: [ Select ]
Parse error: parse error in C:\USR\bin\wamp\www\voltec\sendemail.php on line 11


Line 11 reads:
Code: [ Select ]
$mail_prefix = 'A ' . $_POST['service'] . ' request was sent to you from ' . $_POST['firstname'] . ' ' . $_POST['lastname'] . '\r\n <hr />';
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

Change that line to:
Code: [ Select ]
$mail_prefix = 'A ' . $_POST['service'] . ' request was sent to you from ' . $_POST['firstname'] . ' ' . $_POST['lastname'] . "\r\n <hr />";

and change line 8 to:
Code: [ Select ]
$adm_email = 'your_email@your_host.com';

I forgot the semi-colon ';' after line 8, so it is giving you that error.
  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

Code: [ Select ]
Warning: include(../../bin/php/php5.2.9-2/PEAR/Structures/Mail.php) [function.include]: failed to open stream: No such file or directory in C:\USR\bin\wamp\www\voltec\sendemail.php on line 3

Warning: include() [function.include]: Failed opening '../../bin/php/php5.2.9-2/PEAR/Structures/Mail.php' for inclusion (include_path='.;C:\php5\pear') in C:\USR\bin\wamp\www\voltec\sendemail.php on line 3

Warning: require_once(mail.php) [function.require-once]: failed to open stream: No such file or directory in C:\USR\bin\wamp\www\voltec\sendemail.php on line 46

Fatal error: require_once() [function.require]: Failed opening required 'mail.php' (include_path='.;C:\php5\pear') in C:\USR\bin\wamp\www\voltec\sendemail.php on line 46
  1. Warning: include(../../bin/php/php5.2.9-2/PEAR/Structures/Mail.php) [function.include]: failed to open stream: No such file or directory in C:\USR\bin\wamp\www\voltec\sendemail.php on line 3
  2. Warning: include() [function.include]: Failed opening '../../bin/php/php5.2.9-2/PEAR/Structures/Mail.php' for inclusion (include_path='.;C:\php5\pear') in C:\USR\bin\wamp\www\voltec\sendemail.php on line 3
  3. Warning: require_once(mail.php) [function.require-once]: failed to open stream: No such file or directory in C:\USR\bin\wamp\www\voltec\sendemail.php on line 46
  4. Fatal error: require_once() [function.require]: Failed opening required 'mail.php' (include_path='.;C:\php5\pear') in C:\USR\bin\wamp\www\voltec\sendemail.php on line 46
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

Post Information

  • Total Posts in this topic: 40 posts
  • Users browsing this forum: No registered users and 112 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.