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 http://www.phpclasses.org/)
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
boundary=\"$this->boundary\"";
$this->fullBody = "This is a multi-part message in MIME
format.\n--$this->boundary\n";
$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,
Paolo