Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Dec 2008
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts

    PHP Email Attachment

    Code:
    <?php
    $to = "James.Naismeth@nba.com";
    $subject = "Some Ideas For Basketball";
    $url = 'http://www.nba.com/thisweek/output.php';
    $page = file_get_contents($url);
    $body = $page;
                 
    if (mail($to, $subject, $body)) {
      echo("<p><center>Message successfully sent!</center></p>");
     } else {
      echo("<p><center>Message delivery failed...</center></p>");
     }
    ?>
    Say I have this code above, it takes the source code of output.php and send its to me in an email. How do I create a .txt attachment of this source code and have that emailed to me instead.

    Thanks.

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Look into a php mail class like PHPMailer. It makes it easy to send attachments. You'll need to create a temp file on your server and attach that.
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

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