hi i have attached a mail_attachment file which contains the mail function in my code i have used the below code

<? 
include 'mail_attachment.php';
 $sent = mail_attachment($from, $to, $subject1, $body1, $attachment);?>

when i tried printing the variable ..........all the values are getting printed but the mail function is not working
it is not working.showing 2 warning

Warning: filesize() [function.filesize]: stat failed for http://www.website.com/profiles/resumes/158/llllll.doc in /home/website/public_html/mail_attachment.php on line 17

Warning: fread() [function.fread]: Length parameter must be greater than 0 in /home/website/public_html/mail_attachment.php on line 17

Recommended Answers

All 4 Replies

Hi Lydia, I guess that you're calling mail_attachment() with wrong information in $attachment parameter.
You're passing url while it should be a full path in the server's file system.
E.g.
/var/www/vhosts/website.com/httpdocs/profiles/resumes/....
or
./profiles/resumes....
You have to find out yourself what the path is (I don't know where your calling script (not the library) is located.
In case relative path doesn't work and you need to use absolute path try out phpinfo() command.

If I'm wrong in my assumption then please post what are mail_attachment() parameters when you call it.

hi the path is getting printed correctly when i tried echo statement
eg my wesite name is webs

when i tried printing the pathname,i got the below path as output
home/webb/public_html/profiles/9/BusinessProposal.doc

sorry,output is home/webs/public_html/profiles/9/BusinessProposal.doc

sorry,output is home/webs/public_html/profiles/9/BusinessProposal.doc

Mhm... I really doubt that.
The first error means that it cannot get file size for file:
http://www.website.com/profiles/resumes/158/llllll.doc
The file path is taken directly from the function call, so it is what you pass to the function.

But you claim that you call it with

mail_attachment(..., ..., ..., ..., '/home/webs/public_html/profiles/9/BusinessProposal.doc');

(path like this must start with /, you forgot about it in your post)

If I ignore the fact that profiles/resumes/158/llllll.doc plainly isn't profiles/9/BusinessProposal.doc, even then I don't believe you are giving me what you called the function with. I'm sure you think you do but then you most likely have a bug in the program that calls the function, not the function itself.
There is no silent translation from /home/... to http://....
Your script is passing http://... and not /home/...

Try creating a new file with only include and a function call like this:

mail_attachment('sender@pepa.info', 'petr.pavel@pepa.info', 'test subject', 'test body', '/home/webs/public_html/profiles/9/BusinessProposal.doc');

And double check that the file really exist.

I'll let you know if I receive the file. Also post error messages if you receive any.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.