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