SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Guru
    Join Date
    Mar 2006
    Posts
    701
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    send a php file as email

    I have a php file (the details of an order) and I want to send it as the text of an email to confirm the order, how can I do it-to read this file and not to create it from the script?
    Dimis

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,157
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)
    If you're transferring PHP files by email, IMHO it would be better to send them as attachments, not in the text of the email. I wouldn't trust every email client to not mangle the byte code into something not copy/paste-able.

  3. #3
    SitePoint Guru
    Join Date
    Mar 2006
    Posts
    701
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How can we send a php file as attachments?

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,157
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)
    AFAIK, You can send any kind of file as an attachment as long as you specify the correct MIME and Content types. An older article, but it should be enough to see if the technique will meet your needs. http://www.sitepoint.com/article/advanced-email-php/

    Or, as the article itself suggests
    Note: This article was written back when things like HTML email and file attachments were a lot more difficult to do in PHP than they are today. Before you dive into the from-scratch solutions presented in this article, you might consider investigating PHPMailer, a free library for PHP that provides all of these features with minimal hair-pulling and gnashing of teeth.

  5. #5
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    ob_start();
    include 
    'foo.php';
    $output ob_get_clean(); 
    $output contains a string. You can send strings in emails.

  6. #6
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,157
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)
    Text, PHP code, and HTML mark-up are all plain text (strings). Are you certain email clients won't parse any mark-up? eg.
    PHP Code:
    echo '<b>bold text</b> &amp; more'
    won't show as
    echo 'bold text & more';

    Do you need to put in a "boundary" or send the email as all plain text (not an HTML email)?


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
  •