Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

email file via php form

I researched over the internet, but could not find what i need :/

I have a contact form, (php). I dont have any database. it is a simple php email form, but now I need to make it with file attachment :/ how can I email file via contact form? visitor will browse any file from his computer and send email via form.

appreciate!!

like image 266
designer-trying-coding Avatar asked Jan 23 '26 17:01

designer-trying-coding


1 Answers

I've taken a look at the link in the comments and cleaned up a few things into a function. For one thing I've used an associative array of arguments and heredocs, since the use of php tags and output buffering in the example weren't exactly clean (or as clean as PHP will get).

http://aramk.com/php/php-sending-an-email-attachment/

emailFile(array(
    'to' => '[email protected]',
    'from' => '[email protected]',
    'subject' => 'Some Subject',
    'message' => '<b>Hello!</b>',
    'plain ' => 'Get a new email client!',
    'file' => '/path/to/file'
));

You can pass along the file path from $_FILES into the "file" argument.

like image 58
Aram Kocharyan Avatar answered Jan 26 '26 07:01

Aram Kocharyan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!