|
|
|
|
Like this code?
Show the author your appreciation.
|
|
| |
I have here a very challenging work that every boss tell the programmer to do
In this file i had retrieve the text from the mailbox and then i create the query once the query was created then we can easily run it.
I had test this code in my personal webmail
suraj@surajthapaliya.com.np(Use IMAP) and also i checked it on sthapaliya@wlink.com.np (POP3)
| <?php
/*
Name: Mail Retrieve
when the user send the mail it should be the format like this
Message Part
----------------------------------------
Priority~High
Message~I Have a problem in Cable Network
------------------------------------------------
*/
$pop_host = "{mail.surajthapaliya.com.np/imap}INBOX";
/*
If you use pop then
Set the Pop server for eg. {pop.surajthapaliya.com.np:110/pop3}INBOX
*/
$mbox = imap_open ("$pop_host", "username", "password");
// Open the Mailbox by given host ,Username and Password
$messages = imap_search ($mbox, "TO sthapaliya");
/*
search on the mailbox currently opened in the given imap stream
TO "string" - match messages with "string" in the To:
*/
if ($messages)
{
$messagecount = count($messages); // Count The Messages
for ($i=0; $i<$messagecount; $i++)
{
$msgheader = imap_header($mbox, $messages[$i]); // returns an object of various header elements. according to mesage number
$to = $msgheader->to[0]; // Retrieve To
$from = $msgheader->from[0]; // Retrieve From
$von = $from->mailbox . "@" . $from->host;
$betreff = $msgheader->subject; // Retrieve Subject From Header
$cc = $msgheader->ccaddress; // Retrieve CC
$datum = $msgheader->date; // Date
echo "Subject : ".$betreff." <br> From: ".$von."<br>";
$body=imap_fetchbody($mbox,$messages[$i],"1"); // Fetch The Retrieve from body
//echo "<pre>".$body."</pre><br>";
// Make Query
$pos=strpos("$body","--"); // It search the position according to the -- string (it may be virus scaning text)
if($pos) {
$mainbody=substr($body,0,$pos);
} else {
$mainbody=$body;
}
// // Now Retrieve the data exclude the virus text
echo "Main".$mainbody."<br>";
$a=explode("\n",$mainbody); // seprate the main body text by Enter
$c=sizeof($a);
for($loop=0;$loop<$c;$loop++)
{
$innerE=explode("~",$a[$loop]); // Seprate the text by ~
$sE=sizeof($innerE);
for($j=0;$j<$sE;$j++)
{
if($j==1){
$data=$data."'".trim($innerE[$j])."',"; // Now retrieve the value text not a field
} else {
$field=$field."$innerE[$j]";
}
}
}
$pos=strpos($data,",",1);
$len=strlen($data);
$mainbody=substr($data,0,$len-1);
$sql="insert into tickets(Open_date,Opened_by,subject,priority,message,problem_id,active)
values (sysdate,'$von','$betreff',$mainbody,1,'y')";
$data="";
echo $sql."<br><hr>";
// Now You Can Insert the data Into the Table
// End of Makigng Query
imap_delete($mbox,$messages[$i]); // Mark As Deletion
}
}
imap_expunge($mbox); // when Mark It Will Delete the Message
imap_close($mbox); // Close the Mailbox
?> | | |
|
| Convert text to 'quoted printable' without the IMAP package installed. Categories : PHP, Mail, IMAP | | | Using this script anyone can easily get a form result to his/her mailbox. You can use this script for any form 2 mail purpose. Categories : PHP, Mail, Form Processing | | | Getting newsgroup with PHP Categories : PHP, IMAP | | | Email Class Categories : PHP, Mail, PHP Classes | | | A PHP based webmail at : http://www.horde.org/imp Categories : Email, IMAP, PHP, Complete Programs | | | Protect your email links from being spidered by spam email robots! Categories : PHP, Security, Mail, Email | | | XPertMailer - Sends TRUE Mails Categories : PHP, Mail, SMTP, PHP Classes | | | imap_sort Categories : IMAP, Email, PHP, PHP Functions | | | Tell a friend script :) Categories : PHP, Mail | | | mail -- send mail Categories : PHP, PHP Functions, Mail | | | imap_subscribe -- Subscribe to a mailbox Categories : PHP, PHP Functions, IMAP, Email | | | Simple Maiing list with newsletter support Categories : PHP, PHP Classes, Mail | | | imap_headerinfo -- Read the header of the message Categories : PHP, PHP Functions, IMAP | | | tinySendMail and tinySockMail functions for generating SMTP mail within PHP Categories : PHP, Mail, SMTP | | | Query2Report : Generating Html, Pdf and Csv Reports from SQL Query Categories : PHP, PHP, HTML, PDF, Excel | |
| | | | nour aboud wrote :1635
You add very usefull script can i got your aid ?
on you email plz
thanx alot
| |
|
|
|