[PHP] email attachment cannot be opened

2003-09-12 Thread Chris Hayes
hi,
I've made a form to send out emails with attachments, and the attachments 
look ok when they arrive but the content is somehow bad. I cannot open gifs 
nor can word open the documents. Looking at the content something may be 
wrong with the encoding: if i open the GIF file the normal one as well as 
the attachment I sent start with GIF89a, but then they start to be different.
I think this is the relevant part of my code:

	$atta_type=$_FILES['AttachedFile']['type'];
			if 
(strpos($atta_type,';')){$atta_type=substr($atta_type,0,strpos($atta_type,';'));} 
//for  Opera
	$atta_tmp_name=$_FILES['AttachedFile']['tmp_name'];
		
	$fp = fopen($atta_tmp_name,rb);
	 	while (!feof($fp)){$filedata .= addslashes(fread($fp,1200));}

	   $filedata = chunk_split(base64_encode($filedata));

   $attachment = $atta_type.\n\n
.--$boundary\n
.Content-Type: $atta_type.; name = \$atta_name\\n
.Content-Transfer-Encoding: $encoding
.\n\n$filedata\n\n
.--$boundary--\n;
Just for fun the headers as well:

			'From: SENSE mailinglist [EMAIL PROTECTED]'
			'Subject: '.$subject
			'Reply-To: [EMAIL PROTECTED]'
			'Return-Receipt-To: [EMAIL PROTECTED]'
			'Return-Path: [EMAIL PROTECTED]'
			'MIME-Version: 1.0'
 			'Content-Type: multipart/mixed; 
boundary='.$boundary.\\n\n);'To: SENSE_List'
 			
			This is a MIME encoded message. \n\n
			.--$boundary\n
			.Content-Type: .(($IsHTML)?'text/html':'text/plain').\n
			.Content-Transfer-Encoding: 8bit\n\n
			.$mailbody .$message

	

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] email attachment cannot be opened (solved)

2003-09-12 Thread Chris Hayes
I found the culprit!
I copied the filereading part without checking too good, and it had an 
addslashes call which ruined the file content very professionaly.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP Email Attachment problem

2003-04-04 Thread Michael Arena
Just tried  the example and i can upload a file to a directory on my server.
So i can do both uploads and attachments seperately, now it's just a matter
of doing them at the same time.

-Mike


- Original Message -
From: Jason Wong [EMAIL PROTECTED]
Newsgroups: php.general
To: [EMAIL PROTECTED]
Sent: Friday, April 04, 2003 1:36 AM
Subject: Re: [PHP] PHP Email Attachment problem


 On Friday 04 April 2003 06:10, Michael Arena wrote:
  Made some progress today. Found an attachment  script in the archives. I
  was able to send an email attachment if it was already on the server.
now i
  just need the file to come from a form instead of already being on the
  server but that's not working yet.

 It sounds to me you've definitely got an upload problem.

 Try the upload example in the manual and let us know if you can get that
 working.

 --
 Jason Wong - Gremlins Associates - www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *
 --
 Search the list archives before you post
 http://marc.theaimsgroup.com/?l=php-general
 --
 /*
 Rainy days and automatic weapons always get me down.
 */




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP Email Attachment problem

2003-04-04 Thread Michael Arena
After reading the file_upload section on PHP.net i got the following script
working on the  server..it sends an attachment from a form now but it's just
of size 0 and always a txt file. I know it must be some little thing wrong
then this will work, maybe you can eye it for me and let me know if you
think i should change anything..

thanks,
Mike

-form code---
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
html
head
titleForm Test/title
meta http-equiv=Content-Type content=text/html; charset=iso-8859-1
/head

body
form action=upload.php method=post enctype=multipart/form-data
  strongFile to upload:/strong
input type=hidden name=MAX_FILE_SIZE value=20
  input type=file name=fileatt
  INPUT TYPE=SUBMIT NAME=submit VALUE=Upload File
/form
/body
/html
end form code--
-begin upload.php code--
?php
$to  = [EMAIL PROTECTED];
 $from= [EMAIL PROTECTED];
 $subject = Attachment Test;
 $message = Dear mike,br
   Thank you for taking the time to subscribe for
our free document.br
   Please find the document attached to this
email.;

 if ($fileatt != )
 {
$uploaddir = '/home/sites/webserver.agraservices.net/web/mike/';
echo it found the attachment;
   move_uploaded_file($_FILES['fileatt']['tmp_name'], uploaddir .
$_FILES['fileatt']['name']);
   }
 // Obtain file upload vars
   $fileatt  = /home/sites/webserver.agraservices.net/web/mike/;   //
Location of file on server
   $fileatt_type = $_FILES['fileatt']['type'];// Type of file being sent
   $fileatt_name = $_FILES['fileatt']['name'];// Name of file

 $headers = From: $from;

 if (file_exists($fileatt))
{
   // Read the file to be attached ('rb' = read binary)
   $file = fopen($fileatt,'rb');
   $data = fread($file,filesize($fileatt));
   fclose($file);

  // Generate a boundary string
   $semi_rand = md5(time());
   $mime_boundary = ==Multipart_Boundary_x{$semi_rand}x;

  // Add the headers for a file attachment
   $headers .= \nMIME-Version: 1.0\n .
  Content-Type: multipart/mixed;\n .
   boundary=\{$mime_boundary}\;

  // Add a multipart boundary above the plain message
   $message = This is a multi-part message in MIME format.\n\n .
 --{$mime_boundary}\n .
 Content-Type: text/html; charset=\iso-8859-1\\n .
 Content-Transfer-Encoding: 7bit\n\n .
 $message . \n\n;

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

   // Add file attachment to the message
   $message .= --{$mime_boundary}\n .
  Content-Type: {$fileatt_type};\n .
 name=\{$fileatt_name}\\n .
  //Content-Disposition: attachment;\n .
  // filename=\{$fileatt_name}\\n .
  Content-Transfer-Encoding: base64\n\n .
  $data . \n\n .
  --{$mime_boundary}--\n;
 }
 mail($to, $subject, $message, $headers);
echo Thanks for sending mail;
?
-end upload.php code

thanks again for your help,
Mike





- Original Message -
From: Jason Wong [EMAIL PROTECTED]
Newsgroups: php.general
To: [EMAIL PROTECTED]
Sent: Friday, April 04, 2003 1:36 AM
Subject: Re: [PHP] PHP Email Attachment problem


 On Friday 04 April 2003 06:10, Michael Arena wrote:
  Made some progress today. Found an attachment  script in the archives. I
  was able to send an email attachment if it was already on the server.
now i
  just need the file to come from a form instead of already being on the
  server but that's not working yet.

 It sounds to me you've definitely got an upload problem.

 Try the upload example in the manual and let us know if you can get that
 working.

 --
 Jason Wong - Gremlins Associates - www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *
 --
 Search the list archives before you post
 http://marc.theaimsgroup.com/?l=php-general
 --
 /*
 Rainy days and automatic weapons always get me down.
 */




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP Email Attachment problem

2003-04-04 Thread Burhan Khalid
Michael Arena wrote:
After reading the file_upload section on PHP.net i got the following script
working on the  server..it sends an attachment from a form now but it's just
of size 0 and always a txt file. I know it must be some little thing wrong
then this will work, maybe you can eye it for me and let me know if you
think i should change anything..
[ snip ]

if ($fileatt != )
 {
$uploaddir = '/home/sites/webserver.agraservices.net/web/mike/';
echo it found the attachment;
   move_uploaded_file($_FILES['fileatt']['tmp_name'], uploaddir .
$_FILES['fileatt']['name']);
   }
uploaddir needs to be $uploaddir in your move_uploaded_file function

[ snip ]

--
Burhan Khalid
phplist[at]meidomus[dot]com


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP Email Attachment problem

2003-04-04 Thread Michael Arena
did that...still sends only a file called .txt size zero   ?

thanks for the help,
mike


- Original Message -
From: Burhan Khalid [EMAIL PROTECTED]
Newsgroups: php.general
To: Michael Arena [EMAIL PROTECTED];
[EMAIL PROTECTED]
Sent: Friday, April 04, 2003 11:48 AM
Subject: Re: [PHP] PHP Email Attachment problem


 Michael Arena wrote:
  After reading the file_upload section on PHP.net i got the following
script
  working on the  server..it sends an attachment from a form now but it's
just
  of size 0 and always a txt file. I know it must be some little thing
wrong
  then this will work, maybe you can eye it for me and let me know if you
  think i should change anything..
 
 [ snip ]

  if ($fileatt != )
   {
  $uploaddir = '/home/sites/webserver.agraservices.net/web/mike/';
  echo it found the attachment;
 move_uploaded_file($_FILES['fileatt']['tmp_name'], uploaddir .
  $_FILES['fileatt']['name']);
 }

 uploaddir needs to be $uploaddir in your move_uploaded_file function

 [ snip ]

 --
 Burhan Khalid
 phplist[at]meidomus[dot]com





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP Email Attachment problem

2003-04-04 Thread Burhan Khalid
Michael Arena wrote:
did that...still sends only a file called .txt size zero   ?
try replacing $fileatt with $_POST['fileatt']



--
Burhan Khalid
phplist[at]meidomus[dot]com


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP Email Attachment problem

2003-04-04 Thread Michael Arena
When I put change the line you suggested to 
Line25 $fileatt  =
/home/sites/webserver.agraservices.net/web/mike/$_POST['fileatt'];
$fileatt_type = $_FILES['fileatt']['type'];// Type of
file being sent
$fileatt_name = $_FILES['fileatt']['name'];// Name of
file


I get the following error:
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or
`T_NUM_STRING' in /home/sites/home/web/upload.php on line 25

???


- Original Message -
From: Burhan Khalid [EMAIL PROTECTED]
Newsgroups: php.general
To: Michael Arena [EMAIL PROTECTED];
[EMAIL PROTECTED]
Sent: Friday, April 04, 2003 1:21 PM
Subject: Re: [PHP] PHP Email Attachment problem


 Michael Arena wrote:
  did that...still sends only a file called .txt size zero   ?

 try replacing $fileatt with $_POST['fileatt']



 --
 Burhan Khalid
 phplist[at]meidomus[dot]com





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP Email Attachment problem

2003-04-04 Thread Burhan Khalid
Michael Arena wrote:
When I put change the line you suggested to 
Line25 $fileatt  =
/home/sites/webserver.agraservices.net/web/mike/$_POST['fileatt'];
$fileatt_type = $_FILES['fileatt']['type'];// Type of
file being sent
$fileatt_name = $_FILES['fileatt']['name'];// Name of
file

/home ... .$_POST['fileatt'];

[ snip ]

--
Burhan Khalid
phplist[at]meidomus[dot]com


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP Email Attachment problem

2003-04-04 Thread Jason Wong
On Saturday 05 April 2003 00:41, Michael Arena wrote:
 After reading the file_upload section on PHP.net i got the following script
 working on the  server..it sends an attachment from a form now but it's
 just of size 0 and always a txt file. I know it must be some little thing
 wrong then this will work, maybe you can eye it for me and let me know if
 you think i should change anything..

Michael, I referred you to the upload example in the manual (which you say you 
got working) so that you will have a solid working foundation to build upon. 
In the example, the code to check whether a file has been uploaded is:

  if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {

So why are you using this:

  if ($fileatt != )
  {





 $uploaddir = '/home/sites/webserver.agraservices.net/web/mike/';
 echo it found the attachment;
move_uploaded_file($_FILES['fileatt']['tmp_name'], uploaddir .
 $_FILES['fileatt']['name']);
}

As has been pointed out you're missing the $ in uploaddir.

  // Obtain file upload vars
$fileatt  = /home/sites/webserver.agraservices.net/web/mike/;   //
 Location of file on server
$fileatt_type = $_FILES['fileatt']['type'];// Type of file being sent
$fileatt_name = $_FILES['fileatt']['name'];// Name of file

  $headers = From: $from;

  if (file_exists($fileatt))
 {
// Read the file to be attached ('rb' = read binary)
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);

$fileatt is pointing to a directory. You need to define it as:

$fileatt = 
/home/sites/webserver.agraservices.net/web/mike/{$_FILES['fileatt']['name']};

Note the braces {}. Read the language reference of the manual (not sure where 
exactly it is so can't be more specific) to see why they're needed and how 
they work.

Not sure whether there are any more errors in your code, but correct the above 
first and see where that gets you.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Hailing frequencies open, Captain.
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP Email Attachment problem

2003-04-03 Thread Michael Arena
Made some progress today. Found an attachment  script in the archives. I was
able to send an email attachment if it was already on the server. now i just
need the file to come from a form instead of already being on the server but
that's not working yet.

HTML form code to submit file user wants uploaded---
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
html
head
titleForm Test/title
meta http-equiv=Content-Type content=text/html; charset=iso-8859-1
/head

body
form action=upload.php method=post enctype=multipart/form-data
name=form1
  File to upload:
  input type=file name=fileatt
  input type=submit name=Submit value=Submit
/form
/body
/html
--end html code--
---upload.php code-
?php
$to  = [EMAIL PROTECTED];
 $from= [EMAIL PROTECTED];
 $subject = Attachment Test;
 $message = Dear mike,br
   Thank you for taking the time to subscribe for
our free document.br
   Please find the document attached to this
email.;

 // Obtain file upload vars
 $fileatt = $_FILES['fileatt']['tmp_name'];
$fileatt_type = $_FILES['fileatt']['type'];
$fileatt_name = $_FILES['fileatt']['name'];
 $headers = From: $from;

 // If the file exists...
 if (!file_exists($fileatt))
  {
echo the file doesn't exist;
  }

 if (file_exists($fileatt))
{
   // Read the file to be attached ('rb' = read binary)
   $file = fopen($fileatt,'rb');
   $data = fread($file,filesize($fileatt));
   fclose($file);

  // Generate a boundary string
   $semi_rand = md5(time());
   $mime_boundary = ==Multipart_Boundary_x{$semi_rand}x;

  // Add the headers for a file attachment
   $headers .= \nMIME-Version: 1.0\n .
  Content-Type: multipart/mixed;\n .
   boundary=\{$mime_boundary}\;

  // Add a multipart boundary above the plain message
   $message = This is a multi-part message in MIME format.\n\n .
 --{$mime_boundary}\n .
 Content-Type: text/html; charset=\iso-8859-1\\n .
 Content-Transfer-Encoding: 7bit\n\n .
 $message . \n\n;

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

   // Add file attachment to the message
   $message .= --{$mime_boundary}\n .
  Content-Type: {$fileatt_type};\n .
 name=\{$fileatt_name}\\n .
  //Content-Disposition: attachment;\n .
  // filename=\{$fileatt_name}\\n .
  Content-Transfer-Encoding: base64\n\n .
  $data . \n\n .
  --{$mime_boundary}--\n;
 }
 mail($to, $subject, $message, $headers);
echo Thanks for sending mail;
?
---end upload.php code-

any suggestions on how to get this form going

thanks a million, you've been a big help,
Mike



- Original Message -
From: Jason Wong [EMAIL PROTECTED]
Newsgroups: php.general
To: [EMAIL PROTECTED]
Sent: Thursday, April 03, 2003 11:48 AM
Subject: Re: [PHP] PHP Email Attachment problem


 On Thursday 03 April 2003 22:30, Michael Arena wrote:

  I just checked the directory that I specified for temporary uploads
  (/tmpuploads) and there is nothing there which leads me to believe the
file
  isn't getting uploaded.

 I'm not sure *how* you're checking that there's nothing there but please
read
 the chapter in the manual about file uploads (yes all of it) and note that
 uploaded files are deleted upon termination of the script.

  Does the PHP code look ok? I suspect there's
  something in there that's not right.

 OK, you said on the RAQ server you don't get an attachment, have you
checked
 that:

  if (is_uploaded_file($fileatt))

 is true?

  I could email you a copy of my PHP.ini file

 No thank you.

  if you want to check that out
  as well because I didn't see anything in there called file_upload.

 Make sure your php.ini has the following line

 file_uploads = On

 Also make sure you're not uploading any files that are exceeding the
limits
 set in php.ini (see manual for the relevant config settings which governs
 this).

 --
 Jason Wong - Gremlins Associates - www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *
 --
 Search the list archives before you post
 http://marc.theaimsgroup.com/?l=php-general
 --
 /*
 spagmumps, n.:
 Any of the millions of Styrofoam wads that accompany mail-order items.
 -- Sniglets, Rich Hall  Friends
 */




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP Email Attachment problem

2003-04-03 Thread Jason Wong
On Friday 04 April 2003 06:10, Michael Arena wrote:
 Made some progress today. Found an attachment  script in the archives. I
 was able to send an email attachment if it was already on the server. now i
 just need the file to come from a form instead of already being on the
 server but that's not working yet.

It sounds to me you've definitely got an upload problem.

Try the upload example in the manual and let us know if you can get that 
working.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Rainy days and automatic weapons always get me down.
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] PHP Email Attachment problem

2003-04-03 Thread Steve Jackson
I also had a similar problem and it was simply because the directory
holding the attachment didn't have permission to send the attachment, so
check the permissions on the directory. Once I changed it it sends fine.
Cheers,
Steve Jackson
Web Developer
Viola Systems Ltd.
http://www.violasystems.com
[EMAIL PROTECTED]
Mobile +358 50 343 5159





 -Original Message-
 From: Jason Wong [mailto:[EMAIL PROTECTED] 
 Sent: 3. huhtikuuta 2003 8:23
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP] PHP Email Attachment problem
 
 
 On Wednesday 02 April 2003 04:19, Michael Arena wrote:
  the only difference in the server setup is on my remote 
 server it's a 
  RAQ and locally i'm using Xitami with PHP. I don't 
 understand why it 
  won't send. I get the email over the RAQ but no attachment...
 
 Have you checked that the file actually gets uploaded?
 
  are there any other
  settings that could differ that I would need to set? Like in the 
  php.ini file?
 
 Have you enabled file_uploads in php.ini?
 
 -- 
 Jason Wong - Gremlins Associates - www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications 
 Development *
 --
 Search the list archives before you post 
 http://marc.theaimsgroup.com/?l=php-general
 
 --
 /*
 Our ISP is having {switching,routing,SMDS,frame relay} problems */
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP Email Attachment problem

2003-04-03 Thread Chris Edwards
make sure your form tag has enctype=multipart/form-data in it

-- 
Chris Edwards
Web Application Developer
Outer Banks Internet, Inc.
252-441-6698
[EMAIL PROTECTED]
http://www.OuterBanksInternet.com

- Original Message - 
From: Steve Jackson [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, April 03, 2003 8:00 AM
Subject: RE: [PHP] PHP Email Attachment problem


 I also had a similar problem and it was simply because the directory
 holding the attachment didn't have permission to send the attachment, so
 check the permissions on the directory. Once I changed it it sends fine.
 Cheers,
 Steve Jackson
 Web Developer
 Viola Systems Ltd.
 http://www.violasystems.com
 [EMAIL PROTECTED]
 Mobile +358 50 343 5159
 
 
 
 
 
  -Original Message-
  From: Jason Wong [mailto:[EMAIL PROTECTED] 
  Sent: 3. huhtikuuta 2003 8:23
  To: [EMAIL PROTECTED]
  Subject: Re: [PHP] PHP Email Attachment problem
  
  
  On Wednesday 02 April 2003 04:19, Michael Arena wrote:
   the only difference in the server setup is on my remote 
  server it's a 
   RAQ and locally i'm using Xitami with PHP. I don't 
  understand why it 
   won't send. I get the email over the RAQ but no attachment...
  
  Have you checked that the file actually gets uploaded?
  
   are there any other
   settings that could differ that I would need to set? Like in the 
   php.ini file?
  
  Have you enabled file_uploads in php.ini?
  
  -- 
  Jason Wong - Gremlins Associates - www.gremlins.biz
  Open Source Software Systems Integrators
  * Web Design  Hosting * Internet  Intranet Applications 
  Development *
  --
  Search the list archives before you post 
  http://marc.theaimsgroup.com/?l=php-general
  
  --
  /*
  Our ISP is having {switching,routing,SMDS,frame relay} problems */
  
  
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
  
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP Email Attachment problem

2003-04-03 Thread Michael Arena
I just checked the directory that I specified for temporary uploads
(/tmpuploads) and there is nothing there which leads me to believe the file
isn't getting uploaded. Does the PHP code look ok? I suspect there's
something in there that's not right.
I could email you a copy of my PHP.ini file if you want to check that out as
well because I didn't see anything in there called file_upload.

Thanks,
Mike

- Original Message -
From: Jason Wong [EMAIL PROTECTED]
Newsgroups: php.general
To: [EMAIL PROTECTED]
Sent: Thursday, April 03, 2003 12:23 AM
Subject: Re: [PHP] PHP Email Attachment problem


 On Wednesday 02 April 2003 04:19, Michael Arena wrote:
  the only difference in the server setup is on my remote server it's a
RAQ
  and locally i'm using Xitami with PHP. I don't understand why it won't
  send. I get the email over the RAQ but no attachment...

 Have you checked that the file actually gets uploaded?

  are there any other
  settings that could differ that I would need to set? Like in the php.ini
  file?

 Have you enabled file_uploads in php.ini?

 --
 Jason Wong - Gremlins Associates - www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *
 --
 Search the list archives before you post
 http://marc.theaimsgroup.com/?l=php-general
 --
 /*
 Our ISP is having {switching,routing,SMDS,frame relay} problems
 */




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP Email Attachment problem

2003-04-03 Thread Jason Wong
On Thursday 03 April 2003 22:30, Michael Arena wrote:

 I just checked the directory that I specified for temporary uploads
 (/tmpuploads) and there is nothing there which leads me to believe the file
 isn't getting uploaded. 

I'm not sure *how* you're checking that there's nothing there but please read 
the chapter in the manual about file uploads (yes all of it) and note that 
uploaded files are deleted upon termination of the script.

 Does the PHP code look ok? I suspect there's
 something in there that's not right.

OK, you said on the RAQ server you don't get an attachment, have you checked 
that:

 if (is_uploaded_file($fileatt))

is true?

 I could email you a copy of my PHP.ini file 

No thank you.

 if you want to check that out
 as well because I didn't see anything in there called file_upload.

Make sure your php.ini has the following line

file_uploads = On

Also make sure you're not uploading any files that are exceeding the limits 
set in php.ini (see manual for the relevant config settings which governs 
this).

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
spagmumps, n.:
Any of the millions of Styrofoam wads that accompany mail-order items.
-- Sniglets, Rich Hall  Friends
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Email Attachment Problem....

2003-04-02 Thread Mike
Hello,
I want to send an email attachment using PHP and the below code works
locally but when i upload to my RAQ Cobalt server it doesn't send the
attachment and i can't figure out why. If you can offer me any guidance as
to why this is happening it is greatly appreciated.
**The sendmail is a custom function listed below also, not the one inherent
to PHP.**

Thanks,
Mike

-Begin Code--

case(send_message):

// Obtain file upload vars
$fileatt  = $_FILES['fileatt']['tmp_name'];
$fileatt_type = $_FILES['fileatt']['type'];
$fileatt_name = $_FILES['fileatt']['name'];
$from = [EMAIL PROTECTED];

if (is_uploaded_file($fileatt)) {
  // Read the file to be attached ('rb' = read binary)
  $file = fopen($fileatt,'rb');
  $data = fread($file,filesize($fileatt));
  fclose($file);

  // Generate a boundary string
  $semi_rand = md5(time());
  $mime_boundary = ==Multipart_Boundary_x{$semi_rand}x;

  // Add the headers for a file attachment
  $messaggio = \nMIME-Version: 1.0\n .
  Content-Type: multipart/mixed;\n .
   boundary=\{$mime_boundary}\;

  // Add a multipart boundary above the plain message
  $messaggio .= This is a multi-part message in MIME format.\n\n .
 --{$mime_boundary}\n .
 Content-Type: text/plain; charset=\iso-8859-1\\n .
 Content-Transfer-Encoding: 7bit\n\n .
 $messaggio . \n\n;

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

  // Add file attachment to the message
  $messaggio .= --{$mime_boundary}\n .
  Content-Type: {$fileatt_type};\n .
   name=\{$fileatt_name}\\n .
  //Content-Disposition: attachment;\n .
  // filename=\{$fileatt_name}\\n .
  Content-Transfer-Encoding: base64\n\n .
  $data . \n\n .
  --{$mime_boundary}--\n;
}

// Send the message
include(header.php);
SendMail($ml, $member_mail, $oggetto, $messaggio, $linkpage);
echoh2brbrbrbr$message_success/h2brbrbrbr\n;
break;

---Sendmail Function-
function SendMail($from_address, $to_address, $subject_mail, $message_mail,
$site_address){
$from=$from_address;
$to =$to_address;
$subject=$subject_mail;
$message=$message_mail;


// removes html tags and whitespace from input data
$to =strip_tags(trim($to));
$subject =strip_tags(trim($subject));
$from =strip_tags(trim($from));

$message .=\n\n;
$message .=\n-\n;
$message .= $site_address\n;
$message .= $headers\n;
$from_address=[EMAIL PROTECTED];
@$send=mail($to,$subject,$message,From: $from_address\r\nReply-To:
$from_address\r\nX-Mailer: ADP_FormMail);
}
---End Sendmail function

---End Code





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP Email Attachment problem

2003-04-02 Thread Jason Wong
On Wednesday 02 April 2003 04:19, Michael Arena wrote:
 the only difference in the server setup is on my remote server it's a RAQ
 and locally i'm using Xitami with PHP. I don't understand why it won't
 send. I get the email over the RAQ but no attachment...

Have you checked that the file actually gets uploaded?

 are there any other
 settings that could differ that I would need to set? Like in the php.ini
 file?

Have you enabled file_uploads in php.ini?

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Our ISP is having {switching,routing,SMDS,frame relay} problems
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] PHP Email Attachment problem

2003-04-01 Thread Mike
Hello,
I want to send an email attachment using PHP and the below code works
locally but when i upload to my RAQ Cobalt server it doesn't send the
attachment and i can't figure out why. If you can offer me any guidance as
to why this is happening it is greatly appreciated.
**The sendmail is a custom function listed below also, not the one inherent
to PHP.**

Thanks,
Mike

-Begin Code--

case(send_message):

// Obtain file upload vars
$fileatt  = $_FILES['fileatt']['tmp_name'];
$fileatt_type = $_FILES['fileatt']['type'];
$fileatt_name = $_FILES['fileatt']['name'];
$from = [EMAIL PROTECTED];

if (is_uploaded_file($fileatt)) {
  // Read the file to be attached ('rb' = read binary)
  $file = fopen($fileatt,'rb');
  $data = fread($file,filesize($fileatt));
  fclose($file);

  // Generate a boundary string
  $semi_rand = md5(time());
  $mime_boundary = ==Multipart_Boundary_x{$semi_rand}x;

  // Add the headers for a file attachment
  $messaggio = \nMIME-Version: 1.0\n .
  Content-Type: multipart/mixed;\n .
   boundary=\{$mime_boundary}\;

  // Add a multipart boundary above the plain message
  $messaggio .= This is a multi-part message in MIME format.\n\n .
 --{$mime_boundary}\n .
 Content-Type: text/plain; charset=\iso-8859-1\\n .
 Content-Transfer-Encoding: 7bit\n\n .
 $messaggio . \n\n;

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

  // Add file attachment to the message
  $messaggio .= --{$mime_boundary}\n .
  Content-Type: {$fileatt_type};\n .
   name=\{$fileatt_name}\\n .
  //Content-Disposition: attachment;\n .
  // filename=\{$fileatt_name}\\n .
  Content-Transfer-Encoding: base64\n\n .
  $data . \n\n .
  --{$mime_boundary}--\n;
}

// Send the message
include(header.php);
SendMail($ml, $member_mail, $oggetto, $messaggio, $linkpage);
echoh2brbrbrbr$message_success/h2brbrbrbr\n;
break;

---Sendmail Function-
function SendMail($from_address, $to_address, $subject_mail, $message_mail,
$site_address){
$from=$from_address;
$to =$to_address;
$subject=$subject_mail;
$message=$message_mail;


// removes html tags and whitespace from input data
$to =strip_tags(trim($to));
$subject =strip_tags(trim($subject));
$from =strip_tags(trim($from));

$message .=\n\n;
$message .=\n-\n;
$message .= $site_address\n;
$message .= $headers\n;
$from_address=[EMAIL PROTECTED];
@$send=mail($to,$subject,$message,From: $from_address\r\nReply-To:
$from_address\r\nX-Mailer: ADP_FormMail);
}
---End Sendmail function

---End Code




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP Email Attachment problem

2003-04-01 Thread Jason Wong
On Wednesday 02 April 2003 03:33, Mike wrote:

 I want to send an email attachment using PHP and the below code works
 locally but when i upload to my RAQ Cobalt server it doesn't send the
 attachment and i can't figure out why. If you can offer me any guidance as
 to why this is happening it is greatly appreciated.
 **The sendmail is a custom function listed below also, not the one inherent
 to PHP.**

[snip]

1) How does the server setups differ?

2) How does your code not work?

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
This isn't brain surgery; it's just television.
- David Letterman
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP Email Attachment problem

2003-04-01 Thread Michael Arena
the only difference in the server setup is on my remote server it's a RAQ
and locally i'm using Xitami with PHP. I don't understand why it won't send.
I get the email over the RAQ but no attachment...are there any other
settings that could differ that I would need to set? Like in the php.ini
file?

Thanks,
Mike


- Original Message -
From: Jason Wong [EMAIL PROTECTED]
Newsgroups: php.general
To: [EMAIL PROTECTED]
Sent: Tuesday, April 01, 2003 2:49 PM
Subject: Re: [PHP] PHP Email Attachment problem


 On Wednesday 02 April 2003 03:33, Mike wrote:

  I want to send an email attachment using PHP and the below code works
  locally but when i upload to my RAQ Cobalt server it doesn't send the
  attachment and i can't figure out why. If you can offer me any guidance
as
  to why this is happening it is greatly appreciated.
  **The sendmail is a custom function listed below also, not the one
inherent
  to PHP.**

 [snip]

 1) How does the server setups differ?

 2) How does your code not work?

 --
 Jason Wong - Gremlins Associates - www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *
 --
 Search the list archives before you post
 http://marc.theaimsgroup.com/?l=php-general
 --
 /*
 This isn't brain surgery; it's just television.
 - David Letterman
 */




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Email-attachment not working

2002-05-02 Thread Swati Patil

hi all,
i m using php4.0.1
can anyone pls help me out, in doing email-attachment.
the code written for it, working and sending the email but the attachment is
not getting done.
Do we have to upload the file first, which is to be attached?

swati.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Email-attachment not working

2002-05-02 Thread 1LT John W. Holmes

 Do we have to upload the file first, which is to be attached?

No. When you press the submit button, just speak slowly and clearly where
the file is and PHP will understand you. What kind of video card do you
have?

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Email-attachment not working

2002-05-02 Thread Jason Wong

On Thursday 02 May 2002 19:31, 1LT John W. Holmes wrote:
  Do we have to upload the file first, which is to be attached?

 No. When you press the submit button, just speak slowly and clearly where
 the file is and PHP will understand you. What kind of video card do you
 have?

I prefer faxing the file over to the server.

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
micro:
Thinker toys.
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Email-attachment not working

2002-05-02 Thread David Robley

In article 001401c1f1cc$f5461dc0$2f7e3393@TB447CCO3, 
[EMAIL PROTECTED] says...
  Do we have to upload the file first, which is to be attached?
 
 No. When you press the submit button, just speak slowly and clearly where
 the file is and PHP will understand you. What kind of video card do you
 have?
 
 ---John Holmes...
 
 

Now I have to clean coffee off my monitor

-- 
David Robley
Temporary Kiwi!

Quod subigo farinam

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Email-attachment not working

2002-05-02 Thread Ashley M. Kirchner

Jason Wong wrote:

 On Thursday 02 May 2002 19:31, 1LT John W. Holmes wrote:
   Do we have to upload the file first, which is to be attached?
 
  No. When you press the submit button, just speak slowly and clearly where
  the file is and PHP will understand you. What kind of video card do you
  have?

 I prefer faxing the file over to the server.

It's much easier holding it up to the screen and scanning it in.
Try it sometime.  You'll love it.

--
W | I haven't lost my mind; it's backed up on tape somewhere.
  +
  Ashley M. Kirchner mailto:[EMAIL PROTECTED]   .   303.442.6410 x130
  IT Director / SysAdmin / WebSmith . 800.441.3873 x130
  Photo Craft Laboratories, Inc.. 3550 Arapahoe Ave. #6
  http://www.pcraft.com . .  ..   Boulder, CO 80303, U.S.A.




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Email Attachment

2002-02-04 Thread Mauricio Sthandier

Thanxs... I couldn't use your script (because of my lack of experiencie
maybe) but you gave me a very good hint about what to look for.
I sent an attachment (with a class located in this URL :
http://renoir.vill.edu/~ylee/mailfile.txt), but that wasn't what my boss was
thinking of.
(Now he tells !)
Anyway, is useful and I repeat my gratitude.

Frank Hertogs [EMAIL PROTECTED] escribió en el mensaje
000401c1ab7e$4b2e7790$3400a8c0@fritzzz57619dp">news:000401c1ab7e$4b2e7790$3400a8c0@fritzzz57619dp...
 This should do the trick, experiment wit hit;

 function mail_attachment($email, $buffer)
  {
 //subject
 $subject = Testing pdf attachment..
 //sender
 $x_sender = F. Hertogs;
 //extra (optional) headers
 $x_headers = From: [EMAIL PROTECTED]\n;
 $x_headers .= PHP mailer\n;
 $x_headers .= MIME-version: 1.0\n;
 //tell mail program it's multipart/mixed
 $x_headers .= Content-type: multipart/mixed; ;
 //tell mail program what boundary looks like
 $x_headers .= boundary=\Message-Boundary\\n;
 //encoding
 $x_headers .= Content-transfer-encoding: 7BIT\n;
 //to prevent error in case email is empty (I only use this for testing
 //normally; use php or javascript to check forms before submitting
 if(!IsSet($email))
  $email = [EMAIL PROTECTED];
 //first boundary
 $body = --Message-Boundary\n;
 //start text message
 $body .= Content-type: text/plain; charset=US-ASCII\n;
 $body .= Content-transfer-encoding: 7BIT\n;
 $body .= Content-description: Mail message body\n\n;
 //text for message
 $body .= Dear sir,\n\nHere is the requested file blabla
 //end text message
 $body .= \n\n--Message-Boundary\n;
 //start application pdf in this example
 $body .= Content-type: application/pdf name=\attach.pdf\\n;
 $body .= Content-Transfer-Encoding: base64\n;
 $body .= Content-disposition: attachment; filename=\attach.pdf\\n\n;
 $enc_pdf = chunk_split(base64_encode($buffer));
 $body .= $enc_pdf . \n; }
 $body .= --Message-Boundary--\n;
 //mail actual message
 mail($email, $subject, $body, $x_headers);
 }

 I hope this helps you.

 Frank.

 -Oorspronkelijk bericht-
 Van: Mauricio Sthandier [mailto:[EMAIL PROTECTED]]
 Verzonden: vrijdag 1 februari 2002 20:45
 Aan: [EMAIL PROTECTED]
 Onderwerp: [PHP] Email Attachment

 Hello, I'm new in php development... I was wondering how can I attach a
 Word
 (.doc) Document in an email sent with the mail() function (if I can do
 it
 just with it).

 I know it has to see with the additional headers of the email, but I
 would
 be grateful If anyone could tell where can i go to for this specific
 information.

 I couldn't find it in PHP manual (.pdf version).

 Thanxs !




 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Email Attachment

2002-02-01 Thread Mauricio Sthandier

Hello, I'm new in php development... I was wondering how can I attach a Word
(.doc) Document in an email sent with the mail() function (if I can do it
just with it).

I know it has to see with the additional headers of the email, but I would
be grateful If anyone could tell where can i go to for this specific
information.

I couldn't find it in PHP manual (.pdf version).

Thanxs !




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Email Attachment

2002-02-01 Thread Frank Hertogs

This should do the trick, experiment wit hit;

function mail_attachment($email, $buffer)
 {
//subject 
$subject = Testing pdf attachment..
//sender
$x_sender = F. Hertogs;
//extra (optional) headers
$x_headers = From: [EMAIL PROTECTED]\n;
$x_headers .= PHP mailer\n;
$x_headers .= MIME-version: 1.0\n;
//tell mail program it's multipart/mixed
$x_headers .= Content-type: multipart/mixed; ; 
//tell mail program what boundary looks like
$x_headers .= boundary=\Message-Boundary\\n;
//encoding
$x_headers .= Content-transfer-encoding: 7BIT\n;
//to prevent error in case email is empty (I only use this for testing 
//normally; use php or javascript to check forms before submitting
if(!IsSet($email))
 $email = [EMAIL PROTECTED];
//first boundary
$body = --Message-Boundary\n;
//start text message
$body .= Content-type: text/plain; charset=US-ASCII\n;
$body .= Content-transfer-encoding: 7BIT\n;
$body .= Content-description: Mail message body\n\n;
//text for message
$body .= Dear sir,\n\nHere is the requested file blabla
//end text message
$body .= \n\n--Message-Boundary\n;
//start application pdf in this example
$body .= Content-type: application/pdf name=\attach.pdf\\n; 
$body .= Content-Transfer-Encoding: base64\n;
$body .= Content-disposition: attachment; filename=\attach.pdf\\n\n;
$enc_pdf = chunk_split(base64_encode($buffer));
$body .= $enc_pdf . \n; }
$body .= --Message-Boundary--\n;
//mail actual message
mail($email, $subject, $body, $x_headers);
}

I hope this helps you.

Frank. 

-Oorspronkelijk bericht-
Van: Mauricio Sthandier [mailto:[EMAIL PROTECTED]] 
Verzonden: vrijdag 1 februari 2002 20:45
Aan: [EMAIL PROTECTED]
Onderwerp: [PHP] Email Attachment

Hello, I'm new in php development... I was wondering how can I attach a
Word
(.doc) Document in an email sent with the mail() function (if I can do
it
just with it).

I know it has to see with the additional headers of the email, but I
would
be grateful If anyone could tell where can i go to for this specific
information.

I couldn't find it in PHP manual (.pdf version).

Thanxs !




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Email Attachment

2001-02-03 Thread Richard Lynch

 I know how to send a standard email, but I`m having a bit of trouble
adding
 an attachment, can anyone put me right?

 this is my code which works fine...

 $subject="Hi";
 $email="[EMAIL PROTECTED]";
 $from="[EMAIL PROTECTED]";
 $message="Hi this is me testing my PHP mail script";

 mail($email, $subject, $message, $from);

Email attachments are quite a bit more convoluted than just adding a From
header...

You may want to use Manuel Lemos email class or some other pre-written
user-contributed function to do it.

Otherwise, you get the joy of figuring out MIME-encoding and making up
unique boundary lines to segment the mime-parts and other gnarly stuff I've
managed to not have to figure out...

Even if you want to roll your own, read their source as well as the RFCs
they used to figure all this out.

--
Visit the Zend Store at http://www.zend.com/store/
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Email Attachment

2001-02-01 Thread Website4S

Hi,

I know how to send a standard email, but I`m having a bit of trouble adding 
an attachment, can anyone put me right?

this is my code which works fine...

$subject="Hi";
$email="[EMAIL PROTECTED]";
$from="[EMAIL PROTECTED]";
$message="Hi this is me testing my PHP mail script";

mail($email, $subject, $message, $from);

TIA
Ade

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]