Re: mail with attachment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks Manuel, I will check the class

and here is the code of the mail sending script
//======================================================
<?php
  $att_name = $_POST['att'];
  echo $att_name;
  $att_size = filesize($att_name);
  $handle= fopen($att_name, "r");
  $file = fread($handle, $att_size);

  $file = chunk_split(base64_encode($file));
  $num = md5(time());

  $hdr = "From:"."name@xxxxxxxxxx\r\n";
  $hdr .= "MIME-Version: 1.0\r\n";
  $hdr .= "Content-Type: multipart/mixed; ";
  $hdr .= "Content-Transfer-Encoding: 7bit\r\n\n";
  $hdr .= "boundary=$num\r\n";
  $hdr .= "--$num\r\n";

  $hdr .= "Content-Type: text/plain\r\n";
  $hdr .= "Content-Transfer-Encoding: 8bit\r\n\n";
  $hdr .= $_POST['content']."\r\n";
  $hdr .= "--$num\n";

  $hdr .= "Content-Type: $att_type; ";
  $hdr .= "name=\"".$_POST['att']."\"\r\n";
  $hdr .= "Content-Transfer-Encoding: base64\r\n";
  $hdr .= "Content-Disposition: attachment; ";
  $hdr .= "filename=\"".$_POST['att']."\"\r\n\n";
  $hdr .= "$file\r\n";
  $hdr .= "--$num--";

  if(mail( "another_name@xxxxxxxxx", $_POST['re'], $_POST['content'], $hdr))
  {echo "done";}
  else
  {echo "shit";}
  fclose($handle);
?>

//======================================================


"Manuel Lemos" <mlemos@xxxxxxx> wrote in message
news:41B6FF9F.1060904@xxxxxxxxxx
> Hello,
>
> Dre wrote:
> > I'm trying to send a mail with attachment, using mail() fucntion ..
> > the mail is sent with the attached file, but when I open my mail box to
> > check the mail I sent using my script, I find the normal text contents
and
> > the attachment displayed as text too !!!
> > ex. if I attached a document, it will not be just attached when I open
the
> > mail, it will be displayed as text.
> > I'm using multipart MIME
>
> You are probably doing something wrong but without seeing the source of
> your code, it is hard to tell what is the problem.
>
> Anyway, you may want to try this class that is capable of composing and
> sending messages with as many attachments as you want and works properly:
>
> http://www.phpclasses.org/mimemessage
>
>
> -- 
>
> Regards,
> Manuel Lemos
>
> PHP Classes - Free ready to use OOP components written in PHP
> http://www.phpclasses.org/
>
> PHP Reviews - Reviews of PHP books and other products
> http://www.phpclasses.org/reviews/
>
> Metastorage - Data object relational mapping layer generator
> http://www.meta-language.net/metastorage.html

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux