28, May 2012

Sending email with multiple attachments - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Miscellaneous scripts or snippets (Moderator: Olaf)
Topic: Sending email with multiple attachments
« previous next »
Pages: [1] Print

Author Topic: Sending email with multiple attachments  (Read 2779 times)
Kill the googlebot
*
Posts: 6
44 credits
Members referred : 0


« on: Feb 28, 2007, 12:45:44 pm »

HI again i used the phpmail class
Here is the code below but somehow i can't get the attachment with the email.
I created a form to select a file from a local drive but its not sending the attachment.



<?php
include_once("attach_mailer_class.php");
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form enctype="multipart/form-data" action="test.php" method="post">
  <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
  Choose a file to upload: <input name="userfile" type="file" />
 
<br><br>  <input type="submit" value="Upload File" />
</form>
<?php

print_r($_FILES);

$test = new attach_mailer("Joseph Luong", "diep@chariot.net.au", "diep@chariot.net.au", "copy@provider.com", "blind@copy.org", "Test mime email class subject");
$test->text_body = "...Some body text\n\n the admin";
$test->add_attach_file($_FILES['userfile']['name'],$encoding = "base64", $dispo = "attachment",$type=$_FILES['userfile']['tmp_name']);

$test->process_mail();
?>

</body>
</html>

Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #1 on: Feb 28, 2007, 12:56:03 pm »

first place the php code above the html code (like in the example files)

this example you showed me is for one file...

Kill the googlebot
*
Posts: 6
44 credits
Members referred : 0


« Reply #2 on: Feb 28, 2007, 01:12:46 pm »

HI

yes i changed the code.  But still it is not attaching the file i upload.  if i change it to below
$test->add_attach_file($_FILES['userfile']['tmp_name']);

instead of
$test->add_attach_file($_FILES['userfile']['name']);

then it attaches but doesn't have the correct filename. 




<?php
include_once("attach_mailer_class.php");



if(isset($_FILES['userfile']['tmp_name'])){
print_r($_FILES);
$test = new attach_mailer("Joseph Luong", "diep@chariot.net.au", "diep@chariot.net.au", "copy@provider.com", "blind@copy.org", "Test mime email class subject");
$test->text_body = "...Some body text\n\n the admin";
//$test->add_attach_file($_FILES['userfile']['name'],$encoding = "base64", $dispo = "attachment",$type=$_FILES['userfile']['tmp_name']);
//$test->add_attach_file('ip2nation.zip');
$test->add_attach_file($_FILES['userfile']['name']);
$test->process_mail();
}

?>


<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form enctype="multipart/form-data" action="test.php" method="post">
  <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
  Choose a file to upload: <input name="userfile" type="file" />
 
<br><br>  <input type="submit" value="Upload File" />
</form>


</body>
</html>
Kill the googlebot
*
Posts: 6
44 credits
Members referred : 0


« Reply #3 on: Feb 28, 2007, 01:39:09 pm »

thanks for ur help i solved the problem.  Had to modify the function add_attach_file() a bit.
Works perfectly now even sending multiple files.

Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #4 on: Feb 28, 2007, 04:57:07 pm »

thanks for ur help i solved the problem.  Had to modify the function add_attach_file() a bit.
Works perfectly now even sending multiple files.



thats the not the best way: never change standard classes, btw why not using the example I have provided?

Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=6127
Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Miscellaneous scripts or snippets (Moderator: Olaf)
Topic: Sending email with multiple attachments
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 05:16:41 pm





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.