Help compiling .msg in PHP

Discussion in 'PHP' started by designcentral, Jun 15, 2009.

  1. #1
    Hi there,

    I have a PHP script that will compile a page and I would like it to compile the information on the page into a .msg file ready to send in outlook. I would like the subject to be set and the email recipient.

    Here is my code so far.

    <form method="post" action="process.php" />
    Auction Name: <input type="text" name="id"/>
    Email: <input type="text" name="email" />
    <input type="submit" />
    </form>
    HTML:
    <?php
    
    $url = 'http://www.trademe.co.nz/Browse/Listing.aspx?id=' . $id;
    $page = file_get_contents($url);
    
    preg_match('/<h1 id="ListingTitle_title">(.*?)<\/h1>/s', $page, $pre_title);
    $title = trim(html_entity_decode($pre_title[1]));
    
    preg_match('/<li id="ListingTitle_auctionTitleBids">Winning&nbsp;bid:&nbsp;\$(.*?)<\/li>/s', $page, $pre_price);
    $price = trim(html_entity_decode($pre_price[1]));
    
    preg_match('/<ul id="AuctionSaleDetail_ShippingDetailsList"><li>\$(.*?)&nbsp;&nbsp;/s', $page, $pre_shipping_price);
    $shipping_price = trim(html_entity_decode($pre_shipping_price[1]));
    
    $sub_total = $price+$shipping_price;
    $total = number_format($sub_total, 2);
    
    
    echo "<html>\n"; 
    echo "<p>Dear Customer,</p>\n"; 
    echo "<p>This email is to inform you that we are awaiting payment for your recent item.</p>\n"; 
    echo "<p>Amount to pay (including shipping): $$total</p>\n"; 
    echo "<p>First Last<br>\n"; 
    echo "  Bank of New Zealand<br>\n"; 
    echo "  xx-xxxx-xxxxxxx-xxx</p>\n"; 
    echo "<p>Reference #: $id<br>\n"; 
    echo "  Failure to use this reference number may result in delays in shipping.</p>\n"; 
    echo "<p>Kind Regards,<br>\n"; 
    echo "  First Last</p>\n"; 
    echo "  </html>\n";
    
    ?>
    PHP:
    I don't have a clue what I would need to put in the process.php file.

    Any help, much appreciated.
     
    designcentral, Jun 15, 2009 IP
  2. kalseo

    kalseo Active Member

    Messages:
    733
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #2
    Try to clean your cash or temporary files and it will be fine
     
    kalseo, Jun 16, 2009 IP
  3. designcentral

    designcentral Guest

    Messages:
    106
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Nah you've got the wrong end of the stick.

    I want to know what I need to put into the process.php to make the static output be a .msg file that I can open to send to someone.

    Thanks!
     
    designcentral, Jun 16, 2009 IP
  4. Social.Network

    Social.Network Member

    Messages:
    517
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    35
    #4
    Do you play left field position in baseball? Also, cash is spelled cache.
     
    Social.Network, Jun 16, 2009 IP
  5. Social.Network

    Social.Network Member

    Messages:
    517
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    35
    #5
    It appears that you want to send an HTML email, correct? Not a problem!

    Here is ONE example: http://www.php.net/manual/en/function.mail.php
     
    Social.Network, Jun 16, 2009 IP
  6. Vbot

    Vbot Peon

    Messages:
    107
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #6
    If you're going to send mail right in your php script then look at the php mail function above. If you're going to send mail manually using outlook with attachment then you want to write the output into static file using fopen,fwrite to do that.

    $filecontent = "<html>\n";
    $filecontent .= "<p>Dear Customer,</p>\n";
    $filecontent .= "<p>This email is to inform you that we are awaiting payment for your recent item.</p>\n";
    $filecontent .= "<p>Amount to pay (including shipping): $$total</p>\n";
    $filecontent .= "<p>First Last<br>\n";
    $filecontent .= "  Bank of New Zealand<br>\n";
    $filecontent .= "  xx-xxxx-xxxxxxx-xxx</p>\n";
    $filecontent .= "<p>Reference #: $id<br>\n";
    $filecontent .= "  Failure to use this reference number may result in delays in shipping.</p>\n";
    $filecontent .= "<p>Kind Regards,<br>\n";
    $filecontent .= "  First Last</p>\n";
    $filecontent .= "  </html>\n";
    
    echo $filecontent;
    
    $fp = fopen("$id.msg", "a");
    fwrite($fp, $filecontent);
    fclose($fp);
    PHP:
     
    Vbot, Jun 16, 2009 IP