471,076 Members | 1,332 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,076 software developers and data experts.

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 3342
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
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.