473,465 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem with mail attachments

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
2 2433
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Trond A. S. Andersen | last post by:
Hi, all! I'm trying to use the System.Web.Mail. "package" combinded with System.Web.Mail.SmtpMail in order to send MS Excel spreadsheets attached to mail messages. However, sending one single...
3
by: Bart Stes | last post by:
Hey Guys, I'm trying to write a very simple thing that allows a user to send an e-mail from a windows form app. I use the System.Web.Mail MailMessage class for this and then send my e-mail...
3
by: huan | last post by:
Hi, I am creating a function using C# to send emails with attachment file. And I am using File Field control to get file for attachment. Sending email works fine on development machine, however...
3
by: Tim T | last post by:
Hi, I hope there is someone reading this that has the answer, Please Help! I have the need to send a html email via asp.net. its easy enough to send an html email and add attachments. My...
5
by: RD | last post by:
In the following code, wen I get to SmtpMail.Send(myMessage) I get an exception cast is invalid. I single step through the code and everuthing is Ok till I execute that line. Can anyone tell me...
2
by: Brad | last post by:
I have a web .Net app which sends emails with attachments. After the email is sent I clean up aftermyself and delete the attachments from disk. In upgrading to .Net 2 I changed the email logic...
5
by: Robert Dufour | last post by:
I am trying to use framework 1.1 - stuck with it. to send emails from a windows form application. The email messages can have attachments, usually two and they can be either text or sounds (wav...
4
by: iheartvba | last post by:
Hi I have been able to successfully send e-mails using MS Outlook via MS Access. However I can't seem to find any error logging techniques. What I want to do is create a log of any e-mails actually...
7
by: mukeshrasm | last post by:
Hi I am no able to send mail and it is giving this error Warning: mail(): SMTP server response: 530 5.7.3 Client was not authenticated in c:\inetpub\wwwroot\eshop\includes\classes\email.php on...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.