By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,497 Members | 1,287 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,497 IT Pros & Developers. It's quick & easy.

Problem with mail attachments

P: n/a
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
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Mon, 01 Nov 2004 16:35:01 GMT, "S_p_ike"
<s_p_ike[NOSPAM]@hotmail.com> wrote:
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


Try this one: phpmailer.sourceforge.net

--

\I/
/(@ @)\ Greetings from CyBy
---o00-(_)-00o--------------------
Jul 17 '05 #2

P: n/a
Hello,

On 11/01/2004 02:35 PM, S_p_ike wrote:
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


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:

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
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.