Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Script To Connect To Delete Contents Of A POP3 Mailbox


I have written a PERL script that I can run through bash, that will take in a mail server address, username and a password, login and then delete all of the mail contained within the user's mailbox.

Now I've battled to create a web interface so that my non-linux colleages can use easily wherever they happen to be, but just cannot get to work.

So, I decided it would be easier to use PHP to create the script and use $_POST to grab the address, username and password from a form and then process the connection/deletion.




View Complete Forum Thread with Replies

Related Forum Messages:
Log Into A POP3 Mailbox And Delete The Messages.
I am trying to make a simple web tool that will log into a POP3 mailbox and
delete the messages all at once. I have came up with this and if the Login
information is correct it does delete the mail,but if the login info is
incorrect you do not know until after you try to login to the mailbox again
via telnet or anything like that and notice that the mail is still there.
Does anyone have any idea how I could make this script so it will tell us
that the information is incorrect? Any help would be appreciated.

<?
$host = $_POST['address'];
$user = $_POST['username'];
$pass = $_POST['password'];

################################################## #####################
# End Configuration #
################################################## #####################
#Until I rewrite my scripts, this will suffice for bg-compatibility;
if(phpversion() >= "4.2.0"){
extract($_POST);
extract($_SERVER);
extract($_ENV);
}
#Format output for console or for web?
$nl = ((isset($REMOTE_ADDR)) ? "<br>" : "");

if(!$sock=fsockopen($host, 110, $err, $errno, 10))
die("Couldn't connect to the POP server$nl");

fputs($sock, "USER $user");
$buf = fgets($sock, 1024);
if($buf[0] != '+')
die("POP server didn't like USER $user$nl");
fputs($sock, "PASS $pass
");
$buf = fgets($sock, 1024);
if($buf[0] != '+')
die("POP server didn't like PASS$nl");

fputs($sock, "STAT");
$buf = fgets($sock, 1024);
fputs($sock, "STAT");
$buf2 = fgets($sock, 1024);
list($stat, $num, $size) = split(' ', $buf2, 3);
echo "Mailbox has $num messages$nl";

for($i=1; $i<=$num; $i++){
$command = "DELE $i";
echo "Deleting message $i with DELE $i$nl";
fputs($sock, $command);
$buf = fgets($sock, 1024);
if($buf[0] != '+')
die("POP server didn't like DELE $i: ($buf)$nl");
}
fputs($sock, "QUIT");
$buf = fgets($sock, 1024);
fclose($sock);
?>

View Replies !
Access To A POP3 Mailbox
I am in preliminary design of a contact management program. The
user would like to use his current mail server (POP3 - remote).

I have done some reading on the IMAP functions but am unclear if
the following is possible:

Using the IMAP functions can I write a PHP script to:
scan the subject lines of all mail in the mailbox ?
pop just certain messages from the inbox ?
delete those messages from the inbox ?

all without disturbing the other messages in his inbox that are
downloaded to his usual email client (Thunderbird).

View Replies !
Mailbox That Uses Pop3 And Smtp?
does anyone know of a PHP mailbox that uses pop3 and smtp? I have Gmail, and I want to install a mailbox to my own server that uses gmails smtp and pop3.

View Replies !
Connect To Pop3 Mail Server
I have a piece of code that connects to a mail server running on the same machine. It all works fine but it just takes an age to connect to the mail server, like 30 seconds or so.
Looking at the log for the mail server, I noticed the following lines at the beginning of each request:

[Date / Time] CAPA
[Date / Time] -ERR Unknown Command
[Date / Time] AUTH
[Date / Time] -ERR Unknown Command

Could this be the reason that it takes so long to connect to the mail server? And if so is it possible to suppress certain commands sent to the server if they are not required?
The PHP code I use to connect is simply:

$mbox = imap_open ("{mailserver:110/pop3}INBOX", "username", "password");

And then imap_close($mbox); to clean up.

View Replies !
Use Fsockopen To Connect To Pop3 Mail Server
I am writing a application which use fsockopen to connect to pop3 mail server and check mails. It works fine for me. But, Now i am having problem with checking same server.

I mean when i try to connect to example.com from a script running at http://www.example.com/myscript.php it doesn't connect to server gives

PHP Code:

View Replies !
Delete Folder And Its Contents
is there any way of deleteing a folder and all of its contents using PHP?

View Replies !
Delete File Contents
Can someone post some code to show me how to delete a file from a folder please? I need to delete a file first, and then upload something in it's place. Maybe a bit of code to slide in what i have already would work? Code:

View Replies !
Delete Table Contents?
ive got a table thats too big to dump the records in myphpadmin, how can i dump all the fileds (i think there are 4 or 5) but keep the table and fileds intact to be used again?

View Replies !
Delete Column Contents
Is there a way, through PHP, to delete the contents of a column without deleting the actual column. I know I could do it by deleting the column and adding it again but just wondering if there's a more efficient way.

View Replies !
Delete Row From Mysql Only Deletes The Contents?
mysql_query("DELETE FROM cart WHERE ItemId=$ItemId");

There is the code but the result in my databse is that the ID number changes
from, lets say, 77 to 78 with 78's contents being empty. Therefore when I
look at the results - the deleted ID77 is gone but now I have ID78 with no
content!

Does anyone know why and how do I make it stop?

View Replies !
Delete Entire Folder Contents
What is the best way of deleting an entire folders contents in php I looked at this, but not sure exactly how to implement. http://uk.php.net/manual/en/function.unlink.php

I dont want to get involved with something that could mash my system if I get it wrong.

View Replies !
Mailbox In Linux
I want to create a site which provides web based mail something like yahoo, hotmail.

By using php I was able to read and send mail.But i was not able to create a new mail account for the users who come and register in my site.Somebody gave me a sugesstion that we can execute the
system commands in php.I just tried this but it doesn't work
" $val=system("vadduser hari"); "

If anyone know how to do that in php it will be a great help for me.

View Replies !
Checking A Mailbox
I want to run a cron job that checks my mailbox every 10 minutes and checks for new messages. If it finds a message, I want it to then extract the body and sender of the message which I can then process. I'm on a shared CPanel style shared host. No virtual root. I see a /mail and /public_html, as well as some others.


View Replies !
How Can I Create A Postfix Mailbox
I have postfix running and working as it should. I can add, remove and
administer mailboxes and aliases using postfixadmin. All well there
too.

Now, I want to be able to add mailboxes and aliases using my own
php-code. Therefore I studied the postfixadmin code (which is working),

and it looked like the only thing needed was entries in the postfix
database. Nevertheless, I must be missing something. My code adds the
appropriate entries for the mailbox and alias, yet I can't log in and
get an imap error. I also thought postfix added the appropriate
directories automatically for the new mailboxes. What am I missing?

View Replies !
List Of Mailbox Folders
PHP Code:

<?php

$MAILSERVER="{localhost:143}$mailbox" ;
$link =imap_open($MAILSERVER,$user,$pass);

$headers=imap_headers($link);
$list = imap_list($link, "{localhost}", "*");


echo "<font size=&#391;' face='verdana'>";
foreach ($list as $val) {
list($o1, $o2) =  explode('}', $val);
list($o3, $o4) =  explode('.', $o2);
$fname=  imap_utf7_decode($o4);
.........

View Replies !
What Is The Best Way To Implement User Mailbox On A Site?
what would be the best way to implement user mailbox on a site, it should be similar to 'use cp' in this forum. I don ot have an email server although that would be nice, i have access to a mysql db. Oprion A: if I go with the database (which seems most logical to me at the moment) how should I set up my tables in db if there is an example out there please point me to it.

View Replies !
Save IMAP Mailbox Attachements
The folloing code login to IMAP/POP3 box and retrieve it's contents. Attachements saved to a folder.

My problem is the following:

if more than 1 attachement exist,it's name and content being used for the rest of them. So basically the first overwrite all the following.

Is the any idea what's wrong with this script ....

View Replies !
Adding LDAP Users WITH Mailbox-enabled
I've have been racking my brain for some time now on why all my AD users created via my php interface did not have any exchange mailbox attributes associated to them. I have built an application that uses the ldap extention in PHP for managing our user base withing our organization. Because our organization uses Exchange, it would be nice if i were able to create the mailbox for any new user that is created via my application... This is the source of my conundrum...

I was wondering if there was anyone out there who has had experience in creating AD users via PHP but more importantly also created the exchange user object. I have spent most of today searching the web for examples and all i have found are vb scripts that use the Collaboration Data Objects for Exchange Management (CDOEXM).

Does this mean that i will need to use the PHP ldap functions for AD user creation, and then switch to COM functions for adding the user to exchange?

View Replies !
Make Folder In Mailbox Using Imap Functions
some users don't seem to have a standard "Trash" folder, so they can't move mails to Trash if they don't have any, you could say "just make a trash on the server", but thats not what i want, i have over 3500 users by now, if i have to check for each of them if they have a trash or not,....

so what i want to do is make that Trash folder in their mailbox, using an imap function
its easy to detect in php if they have a Trash or not, that part i do have already, but what function (IMAP) do i need to use to CREATE the folder?

View Replies !
Read Contents Of An External XML Page And Then Parse Its Contents
I have a URL that generates an XML page. I'm trying to read its contents and parse the information. But, I keep receiving these error messages: Code:

View Replies !
How To Connect Remote Site - Can't Connect To MySQL Server
Lets say, i have two php sites named Site-A and Site-B. I want to use MySql
Datbase of Site-B for Site-A.

Generally i use :

$Host="localhost";
$User="username";
$Pass="password";
$DB="databse";
mysql_connect($Host,$User,$Pass);
mysql_select_bd($DB);

When i connect to Site-B database from Site-A what will be the $Host name?
I have tried with: $Host="www.mysite.com";

but it shows the warning:
Warning: mysql_connect(): Can't connect to MySQL server on....

View Replies !
Merge The Contents Of One Array Into The Contents Of Another.
There are many times when I need to merge the contents of one array into the contents of another. Below is how I make this happen now. Do you know of a better or quicker way to do this? The main reason I am concerned is that the arrays I'm merging now have 40,000+ items in each array. I want to streamline the process if possible.

$arrayA = array('item0', 'item1','item2');
$arrayB = array('item3', 'item4', 'item5');

for($i=0;$i<count($arrayB);$i++) {
     $arrayA[] = $arrayB[$i];
}

print_r($arrayA);

View Replies !
Delete Record - When The Delete Link Is Clicked The Next Page Is Blank And Nothing Is Deleted.
This is my "delete.php" and this "todo/delete.php?id=64" an example of a link to it generated from the index.php page. When the delete link is clicked the next page is blank and nothing is deleted. What have I done wrong?

<?
include("dbinfo.inc.php");

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$id="delete from todo where id='$id'";
mysql_query($id);

mysql_close();
?>

View Replies !
Mysql Delete - $query = Mysql_query("DELETE
how would i do the following ?

$query = mysql_query("DELETE notes, datestamp, abs_value, ID FROM absence_mgt  WHERE datestamp='$date' AND ID='$vtc_login' ") or die(mysql_error());
im just getting "Unknown table 'notes' in MULTI DELETE" ?

View Replies !
PHP And POP3
Can anyone point me to a tutorial on using PHP to retrieve email from a POP3
account? I need to take mail messages and parse their content into a mydql DB.

View Replies !
Another Question Regarding Pop3
What is the procedure for running a php script automatically as soon as our
mail server receives a new email. please help in setting up the flags of emails
through pop3 and idea about formatting and displaying the recevied emails.

View Replies !
POP3 Access
I have a script that will access a smtp server and send mail via it, but I'm looking for a code that will let me pop authenticate first so that it will let me send.

View Replies !
Imap - Pop3
I'm writing a script to read view and store my emails. Something like hotmail. Would I need to use IMAP or POP3?

View Replies !
Pop3 Mail
How does one specify which smtp server, (POP3), php should use when sending a mail using the PHP Code:

mail()

function.

View Replies !
Pop3 Over Sockets
on a php page I want to display the content of a POP3 mailbox and to show the following informations:

current number, content-length, sender, subject

// open the socket
$socketPOP = fsockopen($pop, 110);
fgets($socketPOP);
fputs($socketPOP, "USER myName");
fgets($socketPOP);
fputs($socketPOP, "PASS myPassword");
fgets($socketPOP);

// load list
fputs($socketPOP, "LIST");

Now I read the lines with

$zeile = fgets($socketPOP);

and get from it the current numbers and the content lengths.

Then I send for every mail:

fputs($socketPOP, "RETR $currentNumber");

and parse the returnd lines for the strings "From:" and "Subject:".

My problem is, that the whole mail is sended and I have to read ALL data from the socket, before I can get the data from the next mail. If I have lots of large mails, I create with this code very much traffic. How can I avoid this unnecessary traffic?

View Replies !
POP3 Class
Can anyone reccomend a good class for retrieving mail messages from pop3 server? I need basic funcionality (i've checked pop3 class from phpclasses.org) which is to download message body (both plain text and html messages) and display it correctly in browser. I'm not developing a webmail app, I just need to display mails properly.

View Replies !
Pop3 Instead Of IMAP For This?
We want to make a page called 'mail.php' which will check 5 mailboxes. Our mail server uses POP3, not IMAP and we want this page to return a syntax like this:

mailbox@domain.com: 15 messages, 2 new
mailbox2@domain.com: 23 messages, 3 new

The IMAP script we had was:

$mbox = imap_open("{mail.domain.com}", "mailbox1@domain.com", "password", OP_HALFOPEN)
or die("can't connect: " . imap_last_error());

$status = imap_status($mbox, "{mail.domain.com}INBOX", SA_ALL);
if ($status) {
echo "Messages: " . $status->messages . "<br />";
echo "Recent: " . $status->recent . "<br />";
echo "Unseen: " . $status->unseen . "<br />";
echo "UIDnext: " . $status->uidnext . "<br />";
echo "UIDvalidity:" . $status->uidvalidity . "<br />";
} else {
echo "imap_status failed: " . imap_last_error() . "";
}

imap_close($mbox);

However, our mail server isn't IMAP. Is it possible for PHP to do this with POP3 instead, what would I need to use?

View Replies !
Pop3 Function Explanation
i have found a function that does exactly what i want to do but i dont know how it works and i really need to to get another program to work.

the function retrieves a message from a pop3 server which has already been connected to:

function get ($msgNum)
{
//Retrieve the specified msg number. Returns an array
//where each line of the msg is an array element.

if(!isset($this->FP))
{
$this->ERROR = "POP3 get: No connection to server";
return false;
}

$this->update_timer();

$fp = $this->FP;
$buffer = $this->BUFFER;
$cmd = "RETR $msgNum";
$reply = $this->send_cmd($cmd);

if(!$this->is_ok($reply))
{
$this->ERROR = "POP3 get: Error [$reply]";
return false;
}

$count = 0;
$MsgArray = array();

$line = fgets($fp,$buffer);
while ( !ereg("^.
",$line))
{
$MsgArray[$count] = $line;
$count++;
$line = fgets($fp,$buffer);
if(empty($line)){ break; }
}
return $MsgArray;
}

View Replies !
PHP POP3 Password Changer. Possible?
I have built a PHP webmail app and I was wondering if it is possible or not to create a script to allow my POP3 users to change their password if they want to. Also, is it possible to create and delete POP3 accounts with PHP? Examples would be great or links to examples.

View Replies !
POP3 E-Mail Script? Is There One?
I was wondering if there was a script written in PHP were you can check your mail through POP3. All I need is to simple send and receive mail. What scripts do you suggest?

View Replies !
How To Know When A New Message Arrives Without POP3
I am designing a PHP-MySQL web based email and I have a question. How can I get the messages sent to a specific user. I mean how do I know if there is a new message in the mail server. And if I am doing the web-based email without POP3, how can I know when a new message arrives.

View Replies !
Reading POP3 Mails
I want to read POP3 mails through PHP Script. Is it possible? If it is possible.

View Replies !
POP3, Access & Handle With PHP
I wrote some classes for easy handling of POP3-mailboxes with PHP.
Because I think others will benefit from them also, I'd like to notify
their exist here. I know they're not PEAR, but I think they work
rather well - no support for APOP- or MD5-authorisation though.

http://www.disconova.com/open_sourc...html#example002

If you find any bugs, please let me know. Also I'd be interested in
hearing what people like these classes.



View Replies !
Pop3 - Imap_open Sometimes Works
I have been using the same script for almost a year to check pop3 mails for user accounts on my server. It hasnt worked well since I first wrote it.
Sometimes it connects and gets the mails fine but a lot of times it just hangs. It doesnt timeout or anything..it just hangs and the page keeps trying to load. Actually, if I want to use my site anymore, I have to restart the browser.

here is the code i use to connect:

$mbox_open = "{" . $server . ":110/pop3}INBOX";
$mbox = imap_open($mbox_open, $user, $password);

...where $server = mail.mysite.com

My server is running php4.

Is there a better/faster way to connect?
If nothing else is there a way I can set it to timeout at least and retry?

View Replies !
Accesing Gmail From POP3
I'm trying to make a mail client in PHP, i can send mails using smtp, throw my gmail account, and i can download all my mails from gmail using pop3. But the problem is that i dont know how to download the mails in the spam folder or how to know if a mail is unread or not. 

For connect to pop.gmail.com im using the class NET_POP3, from PEAR.  Somebody know how can i solve this problem???

View Replies !
Imap_open - POP3 Problem
I am setting up an autoresponder system that checks a certain email account. I have checked my account settings and logged in with telnet to test. However I get these errormessages when testing the system. Anyone have a clue? Code:

View Replies !
EMail Deletion In POP3
Looking for a simple PHP code that will open a mailbox in pop3 and then delete all the mail that's in the said box then exit?

View Replies !
Access Pop3 Attachments
If there is an easier way then please tell me. I've tried using the imap_open function to access the mailbox specifying port 110 instead of 143, but no dice.  So I've been relegated to using fsockopen and sending telnet commands. I can use all the basic commands and retrieve individual messages, but the caveat is that I need to be able to open WAV files that are attached to these emails.

I'm not having any luck with this. If I could just somehow store the wav file somewhere on the server in a tmp folder or something that would work great. For full disclosure, yes I am connecting to a remote pop3 server, if it was on the same host i imagine that would make this somewhat easier.

View Replies !
IMAP/POP3 And Message_id/UID
I have the following script that connects to a POP3 account and gets the header of the first message on the server, however when I try to get the body I get an error complaining that the message number is invalid, I am using the messages UID rather than the message number, but I've got the UID flag in there so what’s wrong? Code:

View Replies !
POP3 Mail Access
I am trying to code a script that connect to the pop3 server connect it and get the no of mail counts. For this i try imap_open function but server when i run the script i got undefine function error. Next I try searching this forum find a code for the socket connection but that too give error that gethostaddress fails error for the php complier.
I need to connect through the domain name and not through IP address. My application is actual let the user now the count of mails in his pop3 accounts like gmail account has x mails your personal domain has y mails.

View Replies !
POP3 Mail Boxes
PHP script that will connect and read mail from a POP3 box. I need to read the POP3 and populate a database with the senders email, receivers email, date sent, date received, subject, and message. I also want to leave the mail on the server, and flag them somehow so next time the script runs it does not extract the same message twice.

View Replies !
POP3 Email Access
I'm looking for a PHP script that I can install on my server that will allow me to access my google email account via POP3. Had a quick search and the only possible candidate that I could find was "project zen" which i'm finding quite hard to configure.

Has anyone got any alternate suggestions?

View Replies !
Register Pop3 Account
I'm currently working on a website offering free email. However I came across a problem of allowing users to self-register, I am only able to create accounts through cpanel.

I thought of using PHP to log into cpanel and create the account by use of form posting. However my knowledge in PHP is very limited.

View Replies !
Pop3 Mail Fetch With PHP
i need to fetch mails using POP3 in php. i done with imap in php(imap_open). but i am not aware of POP3 in php.

View Replies !
Could Not Connect To MySQL: Can't Connect To Local MySQL Server Through Socket
To connect to a MySQL database, hosted on my machine, an iMAC G5 with OS 10.4, I am using the following code:

$dbc = mysql_connect ('localhost', 'guestuser', &#65533;')
OR die ('Could not connect to MySQL: '.mysql_error() );

However, I receive an error message: Could not connect to MySQL: Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2). MySQL server is running, and user name/password are valid.

View Replies !
Connect To MySQL - Can't Connect To Local MySQL Server Through Socket
I've finished coding php, run it localhost and uploaded to my Apache server with Linux OS. However, I'm seemingly unable to connect to mysql at the server side. and received the following message: Could not connect to database: Can't connect to local MySQL server through socket '/tmp/mysql.sock'(111) What's this message abt? I tried to get into MySQL without php on the server. and received the same message at the console.

View Replies !
Imap_open Works With Pop3 But Not With Imap
I have used the following code and it works fine:

$inbox = imap_open("{".$host."/pop3:110}",$user,$pass);

But the problem is that, with pop3 many imap functions (i.e imap_createmailbox, imap_getmailboxes etc.) does not work.
So I wanted to connect with imap with the following code:

$inbox = imap_open("{".$host.":143}",$user,$pass);

but getting the same error
Coudn't open stream

So whats the solution? I have browsed the whole site and found many solutions (almost same thing) but none of them worked.

How can to make mail folders, rename them, delete them etc. with php??

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved