Jump to content

Need help with fsockopen


drkylec

Recommended Posts

Does anyone know how to get a specific part of a message like the body of a email with fsockopen because I have it working. I want to make it a update page on the fly so when im not at my computer I can still send updates this is my code:

<?php
$fp=fsockopen("mail.webhost.com", 110, $errno, $errstr, 30);
if($fp){
   //echo 'Connected!<br>';
   
   $username="USER [email protected]\r\n";
   $password="PASS password1\r\n";

   $us=fwrite($fp, $username, strlen($username));
   $ur=fgets($fp);
   //echo 'Username sent, server response: '.$ur.'<br>';
   $ps=fwrite($fp, $password, strlen($password));
   $pr=fgets($fp);
   //echo 'Password sent, server response: '.$pr.'<br>';
   
   //$res=fgets($fp);
   //$parts=explode(" ", $res);
   //echo $parts[4].' messages on server<br><br>';
   
   //$cmd="LIST\r\n";
   //$get=fwrite($fp, $cmd, strlen($cmd));
   $msg=fread($fp, 8192);
   //echo '<pre>'.$msg.'</pre>';
   
   $cmd="RETR 1\r\n";
   $get=fwrite($fp, $cmd, strlen($cmd));
   $msg=fread($fp, 8192);
   echo '<pre>'.$msg.'</pre>';
}
else{
   echo 'Failed Connecting!<br>';
}
fclose($fp);
?>

 

I got the code from another forum it works for me but I need to get only the message part to show not the sender and recipient and time. This is my output

 

+OK 1856 octets
Return-Path: 
X-Original-To: [email protected]
Delivered-To: [email protected]
Received: from localhost (unknown [127.0.0.1])
by mail.webhost.com ([000webhost.com Mail System]) with ESMTP id 6FA6D1C00D6
for ; Wed, 25 Mar 2009 12:45:59 +0000 (UTC)
X-Virus-Scanned: amavisd-new at 000webhost.com
Received: from mail.webhost.com ([127.0.0.1])
by localhost (nameserver.webhost.com [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id 3OHt0bQbUrAK for ;
Wed, 25 Mar 2009 08:45:59 -0400 (EDT)
Received: from server.hosting24.com (www.webhost.com [208.43.150.234])
by mx.webhost.com ([webhost.com Mail System]) with ESMTP id 429911C00D1
for ; Wed, 25 Mar 2009 08:45:59 -0400 (EDT)
Received: from nobody by server.hosting24.com with local (Exim 4.69)
(envelope-from )
id 1LmSUU-0004Gy-7n
for [email protected]; Wed, 25 Mar 2009 07:45:54 -0500
To: [email protected]
Subject: Welcome to webhost.com Email Server
From: [email protected]
Reply-To: [email protected]
X-Mailer: PHP/5.2.6
Message-Id: 
Date: Wed, 25 Mar 2009 07:45:54 -0500
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - server.hosting24.com
X-AntiAbuse: Original Domain - axeheadstudio.com
X-AntiAbuse: Originator/Caller UID/GID - [99 99] / [47 12]
X-AntiAbuse: Sender Address Domain - server.hosting24.com

[color=red]Congratulations!

Your new email box has been created, we hope you enjoy our enterprise level email system, and if you will like our services, add a link to www.webhost.com from your website 

--
Your hard working team of webhost.com[/color]
.

 

All i want is what is in red

Link to comment
https://forums.phpfreaks.com/topic/151228-need-help-with-fsockopen/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.