Problem with mail attachments

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi all,

I have a problem with mail with attachments.
To send e-mail with attachments from a form, I use Setec Astronomy's libmail
class (v 1.4) (available here /)

Everything is ok but if I use a specific e-mail address (say address X) in
the field To, the e-mail arrives without attachments. (even if I use two
addresses for field To, of which one is address X, the mail to address X
arrives without attachments, the other arrives with attachments)

So I think that the problem concerns a 'strange' configuration of the mail
server of address X.

Here are the functions for attachments

 function Attach ($filepath, $mimetype = "", $disposition = "inline",
$filename = "")
  if (empty ($filepath))
  { return false; }

  if (empty ($mimetype))
  { $mimetype = "application/x-unknown-content-type"; }

  if (empty ($filename))
  { $filename = basename ($filepath); }

  $this->fattach[] = $filename;
  $this->aattach[] = $filepath;
  $this->actype[] = $mimetype;
  $this->adispo[] = $disposition;

  return true;

 function _build_attachement ()
  $this->xheaders["Content-Type"] = "multipart/mixed;\n

  $this->fullBody = "This is a multi-part message in MIME
  $this->fullBody .= "Content-Type: text/plain;
charset=$this->charset\nContent-Transfer-Encoding: $this->ctencoding\n\n" .
$this->body ."\n";

  $sep = chr(13) . chr(10);

  $ata = array();
  $k = 0;

  for ($i = 0; $i < count( $this->aattach); $i++)
   $filename = $this->aattach[$i];
   $basename = basename($this->fattach[$i]);
   $ctype = $this->actype[$i]; // content-type
   $disposition = $this->adispo[$i];

   if (!file_exists ($filename))
   { return false; }

   $subhdr = "--$this->boundary\nContent-type: $ctype;\n
name=\"$basename\"\nContent-Transfer-Encoding: base64\nContent-Disposition:
$disposition;\n  filename=\"$basename\"\n";
   $ata[$k++] = $subhdr;

   $linesz = filesize ($filename) + 1;
   $fp = fopen ($filename, 'r');
   $ata[$k++] = chunk_split (base64_encode (fread ($fp, $linesz)));
   fclose ($fp);
  $this->fullBody .= implode ($sep, $ata);

Any suggestion on how to solve this problem?

Thank you,

Re: Problem with mail attachments

On Mon, 01 Nov 2004 16:35:01 GMT, "S_p_ike"

Quoted text here. Click to load it

Try this one:


     /(@ @)\  Greetings from CyBy  

Re: Problem with mail attachments


On 11/01/2004 02:35 PM, S_p_ike wrote:
Quoted text here. Click to load it

The code that opens the attachment files does not perform error
checking. Therefore, it is probably failing for some reason and the file
is not really attached.

You may want to try this other class that does error checking and will
tell you about any problems so you do not wonder why the message did not
  come with attachments:


Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP /

PHP Reviews - Reviews of PHP books and other products /

Metastorage - Data object relational mapping layer generator

Site Timeline