PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
just installed - not working

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> Mail
View previous topic :: View next topic  
Author Message
jarv



Joined: 05 Nov 2010
Posts: 2

PostPosted: Fri Nov 05, 2010 1:21 pm    Post subject: just installed - not working Reply with quote

I am going through this tutorial http://www.html-form-guide.com/email-form/php-email-form-attachment.html

I have installed PEAR see here: http://www.edisongray.com/index.php

I am including the appropriate files:
Code:
include_once('../PEAR/Mail.php');
include_once('../PEAR/Mail/mime.php');


but I get the following error:
Warning: require_once(Mail/mimePart.php) [function.require-once]: failed to open stream: No such file or directory in /home/fhlinux129/e/edisongray.com/user/htdocs/PEAR/Mail/mime.php on line 75

Fatal error: require_once() [function.require]: Failed opening required 'Mail/mimePart.php' (include_path='.:/usr/share/pear-php5') in /home/fhlinux129/e/edisongray.com/user/htdocs/PEAR/Mail/mime.php on line 75

Please help?!
Back to top
View user's profile Send private message
jarv



Joined: 05 Nov 2010
Posts: 2

PostPosted: Sat Nov 06, 2010 7:24 pm    Post subject: Reply with quote

anyone?
Back to top
View user's profile Send private message
Ricky55



Joined: 13 Nov 2010
Posts: 1

PostPosted: Sat Nov 13, 2010 7:01 am    Post subject: Reply with quote

I am also doing this tutorial I've been trying for a few days to get this working.

I have PEAR installed and protected, its in the following folder from my site root. I have also installed the Mail and Mail Mime Packages successfully.

install/PEAR

My email.html is here

http://www.sanpan.co.uk/email.html

And this points to the following script send-email-form.php code below. I have set up the folder called uploads and given it the relevant permissions.

When I submit the form the browser just points to the php file but nothing happens no email no upload of the file.

What am I doing wrong? am I including the files correctly? very new to PHP and even more so to PEAR.

Code:

<?php

// Pear library includes
// You should have the pear lib installed
include('install/PEAR/Mail.php');
include('install/PEAR/Mail/mime.php');

//Settings
$max_allowed_file_size = 100; // size in KB
$allowed_extensions = array("jpg", "jpeg", "gif", "bmp");
$upload_folder = 'uploads'; //<-- this folder must be writeable by the script
$your_email = '[email protected]';//<<--  update this to your email address

$errors ='';

if(isset($_POST['submit']))
{
   //Get the uploaded file information
   $name_of_uploaded_file =  basename($_FILES['uploaded_file']['name']);
   
   //get the file extension of the file
   $type_of_uploaded_file = substr($name_of_uploaded_file,
                     strrpos($name_of_uploaded_file, '.') + 1);
   
   $size_of_uploaded_file = $_FILES["uploaded_file"]["size"]/1024;
   
   ///------------Do Validations-------------
   if(empty($_POST['name'])||empty($_POST['email']))
   {
      $errors .= "\n Name and Email are required fields. ";   
   }
   if(IsInjected($visitor_email))
   {
      $errors .= "\n Bad email value!";
   }
   
   if($size_of_uploaded_file > $max_allowed_file_size )
   {
      $errors .= "\n Size of file should be less than $max_allowed_file_size";
   }
   
   //------ Validate the file extension -----
   $allowed_ext = false;
   for($i=0; $i<sizeof($allowed_extensions); $i++)
   {
      if(strcasecmp($allowed_extensions[$i],$type_of_uploaded_file) == 0)
      {
         $allowed_ext = true;      
      }
   }
   
   if(!$allowed_ext)
   {
      $errors .= "\n The uploaded file is not supported file type. ".
      " Only the following file types are supported: ".implode(',',$allowed_extensions);
   }
   
   //send the email
   if(empty($errors))
   {
      //copy the temp. uploaded file to uploads folder
      $path_of_uploaded_file = $upload_folder . $name_of_uploaded_file;
      $tmp_path = $_FILES["uploaded_file"]["tmp_name"];
      
      if(is_uploaded_file($tmp_path))
      {
          if(!copy($tmp_path,$path_of_uploaded_file))
          {
             $errors .= '\n error while copying the uploaded file';
          }
      }
      
      //send the email
      $name = $_POST['name'];
      $visitor_email = $_POST['email'];
      $user_message = $_POST['message'];
      $to = $your_email;
      $subject="New form submission";
      $from = $your_email;
      $text = "A user  $name has sent you this message:\n $user_message";
      
      $message = new Mail_mime();
      $message->setTXTBody($text);
      $message->addAttachment($path_of_uploaded_file);
      $body = $message->get();
      $extraheaders = array("From"=>$from, "Subject"=>$subject,"Reply-To"=>$visitor_email);
      $headers = $message->headers($extraheaders);
      $mail = Mail::factory("mail");
      $mail->send($to, $headers, $body);
      //redirect to 'thank-you page
      header('Location: thank-you.html');
   }
}
///////////////////////////Functions/////////////////
// Function to validate against any email injection attempts
function IsInjected($str)
{
  $injections = array('(\n+)',
              '(\r+)',
              '(\t+)',
              '(%0A+)',
              '(%0D+)',
              '(%08+)',
              '(%09+)'
              );
  $inject = join('|', $injections);
  $inject = "/$inject/i";
  if(preg_match($inject,$str))
    {
    return true;
  }
  else
    {
    return false;
  }
}
?>

<?php
if(!empty($errors))
{
   echo nl2br($errors);
}
?>

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Mail All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement