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

Form to email attachment

P: n/a
I'd like to add a form that will email a file attachment to me.
Can anyone recommend a decent free script?

Thanks
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
abracad wrote:
I'd like to add a form that will email a file attachment to me.
Can anyone recommend a decent free script?


Here's a stripped down version of what I've been using

<?php
$headers='';
if(isset($_POST['email'])){
$headers.='From: '.$_POST['email']."\r\n".
'X-from: '.$_POST['email']."\r\n".
'ReturnPath: '.$_POST['email']."\r\n";
}

$message='The following message contains a file'.
'attachment that was posted via a form.';
$subject='Posted attachment';
$e******************@example.com;
if(isset($_POST['email']))
$email_from=$_POST['email'];
else
$e***************@example.com';

// this file is available at:
// http://www.phpclasses.org/browse/package/32.html
include 'class.html.mime.mail.class';

$mail=new html_mime_mail();
$mail->set_body($message);
if(isset($_FILES['attachment']) && $_FILES['attachment']['error']==0){
$file=$mail->get_file($_FILES['attachment']['tmp_name']);
$mail->add_attachment($file,$_FILES['attachment']['name']);
}
$mail->build_message();
$result=$mail->send('',$email_to,'',$email_from,$subject);
?>

--
Justin Koivisto - sp**@koivi.com
http://www.koivi.com
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.