468,469 Members | 2,235 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,469 developers. It's quick & easy.

Form to email attachment

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
1 3265
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.

Similar topics

3 posts views Thread by WiseGuy | last post: by
4 posts views Thread by phatnugs420 | last post: by
4 posts views Thread by Paul Schmidt | last post: by
2 posts views Thread by Zameer | last post: by
reply views Thread by GLH42 | last post: by
1 post views Thread by budyerr | last post: by
1 post views Thread by kmladenovski | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.