I have built a php mail system. now I want to also send attachments whit the email’s. I have the files for the attachments uploaded to my server and want it with the following piece of code sent with the email.
<?php
$mail_ontvanger->addAttachment($filesOb->c_file_name, 'home/httpd/vhosts/mysite.nl/subdomains/user/httpdocs/beheer/uploads/', $filesOb->c_file_name);
?>
If I do this I than I get an error: (failed to open stream: No such file or directory in…)
I myself think that the error caused by wrong \ in directory (‘home/httpd/vhosts/mysite.nl/subdomains/user/httpdocs/beheer/uploads/’). but this cant not solve the problem.
When I send an email with attachments on then the mail as usual with me in my mail box, only the file is empty.
The error is pretty obvious; it can’t find the file you’re trying to attach. Maybe it’s due to the path being incorrect? Try this:
In any case, it’s better to use relative paths.