Form to email attachment

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • abracad

    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
  • Justin Koivisto

    #2
    Re: Form to email attachment

    abracad wrote:[color=blue]
    > I'd like to add a form that will email a file attachment to me.
    > Can anyone recommend a decent free script?[/color]

    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='Poste d attachment';
    $email_to='reci pient@example.c om;
    if(isset($_POST['email']))
    $email_from=$_P OST['email'];
    else
    $email_from='no ne@example.com' ;

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

    $mail=new html_mime_mail( );
    $mail->set_body($mess age);
    if(isset($_FILE S['attachment']) && $_FILES['attachment']['error']==0){
    $file=$mail->get_file($_FIL ES['attachment']['tmp_name']);
    $mail->add_attachment ($file,$_FILES['attachment']['name']);
    }
    $mail->build_message( );
    $result=$mail->send('',$email _to,'',$email_f rom,$subject);
    ?>

    --
    Justin Koivisto - spam@koivi.com

    Comment

    Working...