WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Data Retrieve from mailbox and generate the SQL Syntax
Categories : PHP, IMAP, Mail
Suraj Thapaliya
Date : May 08th 2006
Grade : 4 of 5 (graded 6 times)
Viewed : 8469
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Suraj Thapaliya
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
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
imap_headerinfo -- Read the header of the message
Categories : PHP, PHP Functions, IMAP
PHP3 FormMail This script sends E-mail using PHP3 function mail(). Body of message is from text file that you create. Easily modified.
Categories : PHP, Email, IMAP
A PHP based webmail at : http://www.horde.org/imp
Categories : Email, IMAP, PHP, Complete Programs
imap_append -- Append a string message to a specified mailbox
Categories : PHP, PHP Functions, IMAP, PHP Functions
Getting newsgroup with PHP
Categories : PHP, IMAP
Email Class
Categories : PHP, Mail, PHP Classes
Simple Maiing list with newsletter support
Categories : PHP, PHP Classes, Mail
Tell a friend script :)
Categories : PHP, Mail
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
XPertMailer - Sends TRUE Mails
Categories : PHP, Mail, SMTP, PHP Classes
Query2Report : Generating Html, Pdf and Csv Reports from SQL Query
Categories : PHP, PHP, HTML, PDF, Excel
Password reminder
Categories : PHP, PHP Classes, Databases, MySQL, Mail
mail -- send mail
Categories : PHP, PHP Functions, Mail
send php mail with form data and attachment.
Categories : PHP, Email, Mail, Form Processing
 nour aboud wrote :1635
You add very usefull script can i got your aid ?
on you email plz
thanx alot