General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 15th, 2003, 08:43 AM
Arash-mikaeili Arash-mikaeili is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Iran,Tehran
Posts: 7 Arash-mikaeili User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Problem in sending attachment

hi
i have a problem in sending attachment it is so strange when i try to attach a file to my mail ,it is ok but whene i

when i send the mail to the other mail address :
1- the size of mail is correct,
2- the attachmen Icon comes into the view
3- there is a link to download that attachment
4- whene i download the file it is out of order ,size and name of file are ok but i can't open it

please take a look at my script and tell me what is wrong :
PHP Code:
<?php
session_start
();
// includes
include("../functions.php");
include(
"../config.php");

if(isset(
$_POST['btnSendMail'])){
//connecting to mail server
$inbox = @imap_open ($Mail_Server,$_SESSION['UserName'], $_SESSION['MailPass']) or Die("Connect Faild");

//creating form add
$from $_SESSION['UserName'] . "@irimc.org";

//add from add to headers
  
$headers ="From: "$from ."\r\n"."Reply-To: "$from "\r\n"."Return-path: "$from "\r\n";

//check if Cc if fill
if(isset($_POST['frmCc']) and $_POST['frmCc']!=='' ){

//add cc add. to headers
$headers =$headers ."Cc : "$_POST['frmCc'] ."\r\n";
  }

//preper for using utf-8
$message $_POST['frmBody'];
//$message = utf8_decode($message );

// check if attachment is sent
//if(isset($_POST['attachment']) ){
if(isset($_FILES) and $_FILES ['attachment'] ['size']>){
print_r($_FILES );
    
//if (is_uploaded_file($_FILES['attachment']['tmp_name'])) {
  // Read the file to be attached ('rb' = read binary)
  
$file fopen($_FILES ['attachment'] ['tmp_name'],'rb');
  
$data fread($file,filesize($_FILES ['attachment'] ['tmp_name']));
  
fclose($file);
                         
              
 
// Generate a boundary string
  
$semi_rand md5(time());
  
$mime_boundary "----------------------------Arash_Mikaeili" .$semi_rand ;

  
// Add the headers for a file attachment
  
$headers .= "MIME-Version: 1.0\r\nContent-Type: Multipart/Mixed; \tboundary=\""$mime_boundary "\"\r\n";
/*              "Content-Type: multipart/mixed;\r\n" .
              " boundary=\"". $mime_boundary ."\""; */

  
  
  
$message "This is a multi-part message in MIME format.\r\n\r\n" .
             
"--" .$mime_boundary ."\r\n" .
             
"Content-Type: text/plain; charset=\"utf-8\"\r\n" .
             
"Content-Transfer-Encoding: quoted-printable\r\n\r\n" .
             
$message "\r\n\r\n" ;


        
// Base64 encode the file data
  
$data chunk_split(base64_encode($data));

  
// Add file attachment to the message
  
$message $message ."--" .$mime_boundary ."\r\nContent-Type: " .$_FILES['attachment']['type'] .";";
$message  $message ."\"\r\nContent-Transfer-Encoding: base64\r\n";
$message=$message "Content-Disposition: attachment; \r\n filename=\""$_FILES['attachment']['name'] ."\"\r\n\r\n" ;
$message =$message .$data "\r\n\r\n";
            
// "--". $mime_boundary ."--\r\n\r\n";
                     
}
              
//}
                    
// Send the message
$ok = @imap_mail($_POST['frmTo'], $_POST['frmSubject'], $message$headers);
if (
$ok) {
  echo 
"<p>Mail sent! Yay PHP!</p>";
echo
"<br />";
echo 
$headers;
} else {
  echo 
"<p>Mail could not be sent. Sorry!</p>"imap_last_error() ."<hr />";

}


//Close mailbox
imap_close($inbox);
 }
?>

Last edited by Arash-mikaeili : September 15th, 2003 at 10:56 AM.

Reply With Quote
  #2  
Old September 17th, 2003, 06:40 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
Are you receving any error messages when the email is sent?

I can't seem to spot any problems in the script...
__________________
____________________________________________
Developer Shed Weekly Writer | DevArticles Forum Moderator
Build Your Own KlipFolio Klip With PHP
FrankManno.com - Under Construction
Design Interactive Group - Under Construction

Reply With Quote
  #3  
Old September 18th, 2003, 05:38 AM
Arash-mikaeili Arash-mikaeili is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Iran,Tehran
Posts: 7 Arash-mikaeili User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hi

no I don't recive any error or notice or warning when i send the mail. so I cang find out the Problin ,it's killing me!

Reply With Quote
  #4  
Old September 18th, 2003, 07:03 AM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
Put this at the top of your script:
error_reporting(E_ALL);

Maybe you will find more info on the problem this way.
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #5  
Old September 19th, 2003, 02:02 AM
Arash-mikaeili Arash-mikaeili is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Iran,Tehran
Posts: 7 Arash-mikaeili User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks for your note but i already set error_reapoting to error_reporting = E_ALL
and
display_errors = On
and
display_startup_errors = On

so if there is any error I will recive a messege

Last edited by Arash-mikaeili : September 19th, 2003 at 02:05 AM.

Reply With Quote
  #6  
Old September 19th, 2003, 07:59 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
What do you mean you can't open the file? Is it coming across corrupt? I'm assuming you've got a program installed that can read the file. Is "out of order" the error message you're getting when you try to open the file? Does this happen for all filetypes and for a variety of file sizes?

Reply With Quote
  #7  
Old September 19th, 2003, 02:29 PM
Arash-mikaeili Arash-mikaeili is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Iran,Tehran
Posts: 7 Arash-mikaeili User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi

yes the file is corrupt . and this is for all file types including image compress and ...

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Problem in sending attachment


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT