SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Confirmed Halfwit
    Join Date
    Oct 1999
    Location
    Vancouver, BC, Canada
    Posts
    983
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Easy method to attach file to email?

    Is there a quick and simple method/function to attach a file to an email using the mail() function?

    Or do I need to go through the "manual" process of reading/encoding and then build the msg body, etc..?

    For example, something like the "attach_file" function below would be perfect:

    PHP Code:
    $file "/my/file.txt";
    $msg "My message here.";
    $msg attach_file($file,$msg);
    mail($to,$sub,$msg,$headers); 
    - A simple online WYSIWYG editor for HTML code snippets.
    - Managed Web Hosting - $3.95/month (resellers welcome)
    - Why pay more? $8.95 domains & $9.95 SSL certificates!

  2. #2
    SitePoint Guru
    Join Date
    Jan 2001
    Location
    Alkmaar, Netherlands
    Posts
    710
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why dont you write a php class for it?
    PHP Code:
    $mailObj = new AdvMail();
    $mailObj->setTo("xxx@oppss.com");
    .
    .
    $mailObj->attachFile(fieldName);
    $mailObj->sendMail(); 
    You will set the header in attachFile() function.
    Check out the article about sending mails in PHP on sitepoint.com ( you probably did already ).

    Good luck


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •