wenmark 0 Newbie Poster

I am attempting to send emails with attachments, and am having a problem getting the following message:

Fatal error: Class 'Mail' not found in C:\xampp\htdocs\includes\Mail\mail.php on line 26
I am using the following code on my page

<?php 
require_once('Connections/wheeldeals2.php'); 
require_once('includes/include.php'); 

session_start();

mysql_select_db($database_wheeldeals2, $wheeldeals2);

$PageID = "PlaceAd";
require_once('includes/ads.php');
require_once('includes/Mail/mail.php');
require_once('includes/Mail/mime.php');

$TrackNo = mt_rand();
$AdLevel = $_POST['AdLevel'];
$TotalCharge = $_POST['TotalCharge'];
$VIN = $_POST['VIN'];
$Mileage = $_POST['Mileage'];
$Price = $_POST['Price'];
$EngSize = $_POST['Size'];
$Units = $_POST['Units'];
$Cylinder = $_POST['Cylinder'];
$TransType = $_POST['TransType'];
$Drive = $_POST['Drive'];
$Fuel = $_POST['Fuel'];
$ExtColor = $_POST['ExtColor'];
$IntColor = $_POST['IntColor'];
$Ad_Name = $_POST['Name'];
$Ad_Phone = $_POST['Phone'];
$Ad_Email = $_POST['Email'];
$Photos = $_POST['Photos'];
if($AdLevel > 1) {
	$CCType = $_POST['CCType'];
	$CCNum = $_POST['CCNum'];
	$CCExp = $_POST['CCExp'];
	$CCSec = $_POST['CCSec'];
	$CCName = $_POST['CCName'];
	$CCAddress = $_POST['CCAddress'];
	$CCity = $_POST['CCity'];
	$CCZip = $_POST['CCZip'];
	$CCPhone = $_POST['CCPhone'];
	$CCEmail = $_POST['CCEmail'];
}

$cnt = 0;
for($i=0;$i <= ($Photos-1);$i++) {
	$Dst_Temp = "temp/".$TrackNo."T.jpg";
	if($_FILES['Photo']['name'][$i] != "") {
		$PhotoName = $_FILES['Photo']['name'][$i];
		$PhotoTemp = $_FILES['Photo']['tmp_name'][$i];
		$PhotoSize = $_FILES['Photo']['size'][$i];
		if(move_uploaded_file($_FILES['Photo']['tmp_name'][$i], $Dst_Temp)) {
			$cnt++;
			$photo_name = $TrackNo."P".$cnt.".jpg";
			$Dst_Disp= "temp/".$TrackNo."P".$cnt.".jpg";
			$Size = getimagesize($Dst_Temp); 							//Get uploaded file sizes
			$SrcX = $Size[0];
			$SrcY = $Size[1];
			$DispSize = 640; 									//Set display size (Square)
			$DstXdisp = 640; 								// Set display width to maximum
			$DispRatio = $SrcX / $DispSize; 			//generate display scaling ratio
			$DstYdisp = round($SrcY / $DispRatio); 			// generate display height
			$SrcImage = imagecreatefromjpeg($Dst_Temp); 				//get internal orig image
			$DispDstImage = imagecreatetruecolor($DstXdisp,$DstYdisp); 		// Create blank display image
			//resample downloaded image into display image
			imagecopyresampled($DispDstImage,$SrcImage,0,0,0,0,$DstXdisp,$DstYdisp,$SrcX,$SrcY); 	
			$saveimage = imagejpeg($DispDstImage,$Dst_Disp,100);			//output display image
			imagedestroy($SrcImage); 						// Get rid of image objects
			imagedestroy($DispDstImage);					// Get rid of image objects
			unlink($Dst_Temp);							    //Delete original uploaded file
			$attachment[$i] = chunk_split(base64_encode(file_get_contents($Dst_Disp)));
		}
	}
}

$Engine = $EngSize." ".$Units." ".$Cylinder;
$Transmission = $TransType;

$To = "sales@wheeldealsonline.net; webadmin@wheeldealsonline.net";
$MainMsg = "<title>Wheel Deals Online Individual Ad</title>\r\n";
$MainMsg .= "<head>\r\n</head>\r\n<body>\r\n<table>\r\n";
$MainMsg .= "	<tr><td>Tracking No: $TrackNo</td></tr>\r\n";
$MainMsg .= "	<tr><td>Ad Level: $AdLevel</td></tr>\r\n";
$MainMsg .= "	<tr><td>Mileage: $Mileage</td></tr>\r\n";
$MainMsg .= "	<tr><td>VIN: $VIN</td></tr>\r\n";
$MainMsg .= "	<tr><td>Exterior Color: $ExtColor</td></tr>\r\n";
$MainMsg .= "	<tr><td>Interior Color: $IntColor</td></tr>\r\n";
$MainMsg .= "	<tr><td>Engine: $Engine</td></tr>\r\n";
$MainMsg .= "	<tr><td>Fuel: $Fuel</td></tr>\r\n";
$MainMsg .= "	<tr><td>Drive: $Drive</td></tr>\r\n";
$MainMsg .= "	<tr><td>Transmission: $Transmission</td></tr>\r\n";
$MainMsg .= "	<tr><td>Ad Name: $Ad_Name</td></tr>\r\n";
$MainMsg .= "	<tr><td>Ad Phone: $Ad_Phone</td></tr>\r\n";
$MainMsg .= "	<tr><td>Ad Email: $Ad_Email</td></tr>\r\n";
if($AdLevel > 1) {
	$MainMsg .= "
			<tr><td>**************Credit Card Info***************************************</td></tr>\r\n
			<tr><td>Cost: $TotalCharge</td></tr>\r\n
			<tr><td>Credit Card Type: $CCType</td></tr>\r\n
			<tr><td>Credit Card Number: $CCNum</td></tr>\r\n
			<tr><td>Credit Card Expiration: $CCExp</td></tr>\r\n
			<tr><td>Credit Card Security: $CCSec</td></tr>\r\n
			<tr><td>Credit Card Name: $CCName</td></tr>\r\n
			<tr><td>Credit Card Address: $CCAddress</td></tr>\r\n
			<tr><td>Credit Card City, State, Zip: $CCCity, $CCState $CCZip</td></tr>\r\n
			<tr><td>Credit Card Name: $CCPhone</td></tr>\r\n
			<tr><td>Credit Card Name: $CCEmail</td></tr>\r\n";
}
$MainMsg .= "</table>\r\n</body></html>\r\n\n";

$mime = new Mail_mime();
$mime -> setHTMLBody($MainMsg);

for($i=0;$i <= $cnt-1;$i++) $mime = addAttachment($attachment[$i]);

$body = $mime -> get();
$hdrs = $mime -> headers(array('From' => 'webadmin@wheeldealsonline.net','Subject' => 'Ad Placed'));
$mail =& mail::factory('mail');
if(!is_a($mail,'Pear_Error')) {
	if($mail->send($To,$hdrs,$body)) $Msg = "Mail Sent";
	else $Msg = "Message could not be sent, please contact Wheel Deals at (719)444-0289";
}
else die("Error: Email Internal Error, please contact Wheel Deals at (719)444-0289");

?>

And the include file that is generating the error is:

<?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;
    }

}

What have I done wrong? I presume I need another include file??

Thanks in advance for any help
Mark

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.