Connecting Tech Pros Worldwide Forums | Help | Site Map

how to retrieve mails & attachment from mbox

Newbie
 
Join Date: Mar 2007
Posts: 5
#1: Mar 8 '07
i got problem with this
i m implementing web based mail system.
i want to access mbox and retrieve mail from it and display it on web page..

can anybody help me.

ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#2: Mar 8 '07

re: how to retrieve mails & attachment from mbox


Please elaborate a bit more on your problem and show the code you have developed to tackle this requirement.

And show that code within php or code tags!!

Ronald :cool:
Newbie
 
Join Date: Mar 2007
Posts: 5
#3: Mar 12 '07

re: how to retrieve mails & attachment from mbox


i m implementing web based mail system using php.....
now i can send mail and attachments. i tried this
[php]
<?php
$to = "$name <$email>";
$from = "John-Smith <john.smith@domain.com>";
$subject = "Here is your attachment";

$fileatt = "/public_html/pdfs/mypdf.pdf";
$fileatttype = "application/pdf";
$fileattname = "newname.pdf";

$headers = "From: $from";

$file = fopen( $fileatt, 'rb' );
$data = fread( $file, filesize( $fileatt ) );
fclose( $file );

$semi_rand = md5( time() );
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";

$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";

$data = chunk_split( base64_encode( $data ) );

$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatttype};\n" .
" name=\"{$fileattname}\"\n" .
"Content-Disposition: attachment;\n" .
" filename=\"{$fileattname}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";

if( mail( $to, $subject, $message, $headers ) ) {
echo "<p>The email was sent.</p>";
}
else {
echo "<p>There was an error sending the mail.</p>";
}
}
?>[/php]

this sends attachment and encrypts it. also i want to retrieve mails from mbox
now i want to retrieve it and display it on webpage.......
can anybody help me plz......its my project

Read the Posting Guidelines on double threads and enclosing code within php or code tags!! - moderator
ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#4: Mar 12 '07

re: how to retrieve mails & attachment from mbox


That is a bit more complicated than sending emails with or without attachments.

Please have a look at the following, very useful, tutorials on building a web based email client. I am sure you'll find what you need.

Building-A-PHPBased-Mail-Client-part-1
Building-A-PHPBased-Mail-Client-part-2
Building-A-PHPBased-Mail-Client-part-3

Ronald :cool:
Newbie
 
Join Date: Mar 2007
Posts: 5
#5: Mar 13 '07

re: how to retrieve mails & attachment from mbox


sir your linked soln was nice.but i m not using any mail client .so what i want is accessing mails through php without that imap_* functions... i want to implement it like yahoomail.com ie no spcific client s/w required like outlook express.

i want to store mails on server & whenever user will request let them access that..
what exactly i want is parse mbox on server with php and retrieve mails plus attachments on webpage like yahoo,gmail web based systems.

plz give m a soln with example code.....
plzz help me
ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#6: Mar 13 '07

re: how to retrieve mails & attachment from mbox


Do not start a new thread for the same subject! I have merged the threads.

moderator
ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#7: Mar 13 '07

re: how to retrieve mails & attachment from mbox


Quote:

Originally Posted by Watermark

sir your linked soln was nice.but i m not using any mail client .so what i want is accessing mails through php without that imap_* functions... i want to implement it like yahoomail.com ie no spcific client s/w required like outlook express.

i want to store mails on server & whenever user will request let them access that..
what exactly i want is parse mbox on server with php and retrieve mails plus attachments on webpage like yahoo,gmail web based systems.

plz give m a soln with example code.....
plzz help me

If my post with links did not meet your requirement, maybe you can have a look at the email class of www.phpclasses.org. That contains a lot of email solutions, client and web based.

These classes are free to download, change and use and I am sure you'll find code and samples that can be used by you. Look at Email classes

Ronald :cool:
Reply