Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Da li je moguce citati sadrzaj ili naslov nekog maila?

[es] :: PHP :: Da li je moguce citati sadrzaj ili naslov nekog maila?

[ Pregleda: 2204 | Odgovora: 7 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

Shejn
Srbija

Član broj: 11830
Poruke: 232
*.dynamic.sbb.rs.



Profil

icon Da li je moguce citati sadrzaj ili naslov nekog maila?24.08.2008. u 20:49 - pre 190 meseci
npr. neko vam posalje mail u cijem subject-u, body-u, se nalazi neki ID, i na osnovu tog ID-a je potrebno uraditi odredjenu akciju.

Jel radio neko nesto slicno, i kako bi to moglo da se odradi?
 
Odgovor na temu

kazil
Robert Bašić
Full time PHP dev :)
Bačka Topola - Novi Sad

Član broj: 120044
Poruke: 686
93.86.116.*

Jabber: robertbasic@elitesecurity.org
ICQ: 446475288
Sajt: robertbasic.com


+2 Profil

icon Re: Da li je moguce citati sadrzaj ili naslov nekog maila?25.08.2008. u 07:15 - pre 190 meseci
Odakle se salje mail? Neko ti iskuca obican E-mail pa ti posalje, ili se salje preko skripte? Gde je potrebno odraditi tu akciju? Daj malo detaljnije. Najbolje bi bilo da das konkretan primer.
 
Odgovor na temu

Shejn
Srbija

Član broj: 11830
Poruke: 232
*.dynamic.sbb.rs.



Profil

icon Re: Da li je moguce citati sadrzaj ili naslov nekog maila?25.08.2008. u 08:40 - pre 190 meseci
Neko skucka "obican" mail, ne preko skripte vec preko mail klijenta, i posalje na adresu [email protected]. U subjectu tog maila bi trebalo da se navede neki ID (npr. id1234).
E sad, treba mi neki automatizam koji ce prvo da skonta novi mail, zatim da procite subject maila i da na osnovu ID-a odradi odredjenu akciju.

Ne znam da li je to izvodljivo, ali eto, ako imas neki predlog dobro je dosao ...

Nadam se da je sad jasnije ....

Pozdrav.
 
Odgovor na temu

kazil
Robert Bašić
Full time PHP dev :)
Bačka Topola - Novi Sad

Član broj: 120044
Poruke: 686
93.86.116.*

Jabber: robertbasic@elitesecurity.org
ICQ: 446475288
Sajt: robertbasic.com


+2 Profil

icon Re: Da li je moguce citati sadrzaj ili naslov nekog maila?25.08.2008. u 09:00 - pre 190 meseci
Evo ti neki linkovi, kreni, pa vici kad zapnes negde, pa cemo da vidimo dalje:
http://www.php.net/manual/en/book.mailparse.php
http://www.evolt.org/article/I...il_and_PHP/18/27914/index.html
http://discussion.dreamhost.co...m_programming&Number=38915
http://www.phpbuilder.com/columns/galloway20021105.php3?aid=422

Takodje, Googlaj za "php email parser script"
 
Odgovor na temu

Shejn
Srbija

Član broj: 11830
Poruke: 232
*.dynamic.sbb.rs.



Profil

icon Re: Da li je moguce citati sadrzaj ili naslov nekog maila?25.08.2008. u 09:27 - pre 190 meseci
hvala, čujemo se ako nešto zapne ...
 
Odgovor na temu

Shejn
Srbija

Član broj: 11830
Poruke: 232
*.dynamic.sbb.rs.



Profil

icon Re: Da li je moguce citati sadrzaj ili naslov nekog maila?25.08.2008. u 22:35 - pre 190 meseci
Procitao sam postove koje si postavio, ali imam problem u realizaciji. Evo kako sam pokusao:

1. Kreirao sam skriptu mail_parser.php
Code:


#!/usr/bin/php
<?php
// read from stdin
    $fd = fopen("php://stdin", "r");
    $email = "[email protected]";
    while (!feof($fd)) {
        $email .= fread($fd, 1024);
    }
    fclose($fd);
    
    // handle email
    $lines = explode("\n", $email);

    // empty vars
    $from = "";
    $subject = "";
    $headers = "";
    $message = "";
    $splittingheaders = true;
    for ($i=0; $i < count($lines); $i++) {
        if ($splittingheaders) {
            // this is a header
            $headers .= $lines[$i]."\n";

            // look out for special headers
            if (preg_match("/^Subject: (.*)/", $lines[$i], $matches)) {
                $subject = $matches[1];
            }
            if (preg_match("/^From: (.*)/", $lines[$i], $matches)) {
                $from = $matches[1];
            }
        } else {
            // not a header, but message
            $message .= $lines[$i]."\n";
        }

        if (trim($lines[$i])=="") {
            // empty line, header section has ended
            $splittingheaders = false;
        }
    }
    
    mail("[email protected]", "Imate novi mail na [email protected]", "imate novi mail ....");

?>



2. Sacuvao sam skriptu u folder www/
inace, struktura foldera je sledeca:
home/acaunt_name/access-logs -> /usr/local/apache/domlogs/stacpine
home/acaunt_name/cpanel3-skel
home/acaunt_name/cpanelbranding
home/acaunt_name/etc
home/acaunt_name/mail
home/acaunt_name/public_ftp
home/acaunt_name/public_html
home/acaunt_name/tmp
home/acaunt_name/www -> public_html

3. Promenio skripti prava na 755

4. Kreirao fajl, .forward i snimio ga u root, tj. /home/acaunt_name/

Code:


[email protected],"| /home/acaunt_name/web/mail_parser.php"



I to bi u principu trebalo da je to to. Ali kada posaljem mail na [email protected], nista se ne desava.

Inace /etc/smrsh i /usr/adm/sm.bin ne postoji ...

Imas li mozda neku ideju?
 
Odgovor na temu

b0ris
Boris Vujicic
Senior PHP programer
Beograd

Član broj: 126587
Poruke: 158
*.dynamic.sbb.rs.



+2 Profil

icon Re: Da li je moguce citati sadrzaj ili naslov nekog maila?30.08.2008. u 20:14 - pre 190 meseci
Cao ja sam skoro pravio mailing liste mozta ti ovo moze pomoci.

ovo je preuzeta klasa koja odradjuje posao.
Code:

<?php
// Main ReciveMail Class File - Version 1.0 (01-03-2006)
/*
 * File: recivemail.class.php
 * Description: Reciving mail With Attechment
 * Version: 1.0
 * Created: 01-03-2006
 * Author: Mitul Koradia
 * Email: [email protected]
 * Cell : +91 9879697592
 */
class receiveMail
{
    var $server='';
    var $username='';
    var $password='';
    
    var $marubox='';                    
    
    var $email='';            
    
    function receiveMail($username,$password,$EmailAddress,$mailserver='localhost',$servertype='pop',$port='110') //Constructure
    {
        if($servertype=='imap')
        {
            if($port=='') $port='143'; 
            $strConnect='{'.$mailserver.':'.$port. '}INBOX'; 
        }
        else
        {
            $strConnect='{'.$mailserver.':'.$port. '/pop3}INBOX'; 
        }
        $this->server            =    $strConnect;
        $this->username            =    $username;
        $this->password            =    $password;
        $this->email            =    $EmailAddress;
    }
    function connect() //Connect To the Mail Box
    {
        $this->marubox=imap_open($this->server,$this->username,$this->password);
    }
    function getHeaders($mid) // Get Header info
    {
        $mail_header=imap_header($this->marubox,$mid);
        $sender=$mail_header->from[0];
        $sender_replyto=$mail_header->reply_to[0];
        if(strtolower($sender->mailbox)!='mailer-daemon' && strtolower($sender->mailbox)!='postmaster')
        {
            $mail_details=array(
                    'from'=>strtolower($sender->mailbox).'@'.$sender->host,
                    'fromName'=>$sender->personal,
                    'toOth'=>strtolower($sender_replyto->mailbox).'@'.$sender_replyto->host,
                    'toNameOth'=>$sender_replyto->personal,
                    'subject'=>$mail_header->subject,
                    'to'=>strtolower($mail_header->toaddress)
                );
        }
        return $mail_details;
    }
    function get_mime_type(&$structure) //Get Mime type Internal Private Use
    { 
        $primary_mime_type = array("TEXT", "MULTIPART", "MESSAGE", "APPLICATION", "AUDIO", "IMAGE", "VIDEO", "OTHER"); 
        
        if($structure->subtype) { 
            return $primary_mime_type[(int) $structure->type] . '/' . $structure->subtype; 
        } 
        return "TEXT/PLAIN"; 
    } 
    function get_part($stream, $msg_number, $mime_type, $structure = false, $part_number = false) //Get Part Of Message Internal Private Use
    { 
        if(!$structure) { 
            $structure = imap_fetchstructure($stream, $msg_number); 
        } 
        if($structure) { 
            if($mime_type == $this->get_mime_type($structure))
            { 
                if(!$part_number) 
                { 
                    $part_number = "1"; 
                } 
                $text = imap_fetchbody($stream, $msg_number, $part_number); 
                if($structure->encoding == 3) 
                { 
                    return imap_base64($text); 
                } 
                else if($structure->encoding == 4) 
                { 
                    return imap_qprint($text); 
                } 
                else
                { 
                    return $text; 
                } 
            } 
            if($structure->type == 1) /* multipart */ 
            { 
                while(list($index, $sub_structure) = each($structure->parts))
                { 
                    if($part_number)
                    { 
                        $prefix = $part_number . '.'; 
                    } 
                    $data = $this->get_part($stream, $msg_number, $mime_type, $sub_structure, $prefix . ($index + 1)); 
                    if($data)
                    { 
                        return $data; 
                    } 
                } 
            } 
        } 
        return false; 
    } 
    function getTotalMails() //Get Total Number off Unread Email In Mailbox
    {
        $headers=imap_headers($this->marubox);
        return count($headers);
    }
    function GetAttech($mid,$path) // Get Atteced File from Mail
    {
        $struckture = imap_fetchstructure($this->marubox,$mid);
        $ar="";
    if(is_array($struckture))
        foreach($struckture->parts as $key => $value)
        {
            $enc=$struckture->parts[$key]->encoding;
            if($struckture->parts[$key]->ifdparameters)
            {
                $name=$struckture->parts[$key]->dparameters[0]->value;
                $message = imap_fetchbody($this->marubox,$mid,$key+1);
                if ($enc == 0)
                    $message = imap_8bit($message);
                if ($enc == 1)
                    $message = imap_8bit ($message);
                if ($enc == 2)
                    $message = imap_binary ($message);
                if ($enc == 3)
                    $message = imap_base64 ($message); 
                if ($enc == 4)
                    $message = quoted_printable_decode($message);
                if ($enc == 5)
                    $message = $message;
                $fp=fopen($path.$name,"w");
                fwrite($fp,$message);
                fclose($fp);
                $ar=$ar.$name.",";
            }
        }
        $ar=substr($ar,0,(strlen($ar)-1));
        return $ar;
    }
    function getBody($mid) // Get Message Body
    {
        $body = $this->get_part($this->marubox, $mid, "TEXT/HTML");
        if ($body == "")
            $body = $this->get_part($this->marubox, $mid, "TEXT/PLAIN");
        if ($body == "") { 
            return "";
        }
        return $body;
    }
    function deleteMails($mid) // Delete That Mail
    {
        imap_delete($this->marubox,$mid);
    }
    function close_mailbox() //Close Mail Box
    {
        imap_close($this->marubox,CL_EXPUNGE);
    }
}
?>


Ovo je primer skripte koja koristi tu klasu
Code:

<?php
include("receivemail.class.php");
// Create Object For reciveMail Class
$obj= new receiveMail('[email protected]','XXX','[email protected]','mail.example.com','pop3','110');
//Connect to the Mail Box
$obj->connect();
// Get Total Number of Unread Email in mail box
$tot=$obj->getTotalMails(); //Total Mails in Inbox Return integer value
echo "Total Mails:: $tot<br>";
for($i=1;$i<=$tot;$i++)
{
  $head=$obj->getHeaders($i);  // Get Header Info Return Array Of Headers **Key Are (subject,to,toOth,toNameOth,from,fromName)
  echo "Subjects :: ".$head['subject']."<br>";
  
  echo "TO :: ".$head['to']."<br>";
  echo "To Other :: ".$head['toOth']."<br>";
  echo "ToName Other :: ".$head['toNameOth']."<br>";
  echo "From :: ".$head['from']."<br>";
  echo "FromName :: ".$head['fromName']."<br>";
  echo "<br><BR>";
  echo "<br>*******************************************************************************************<BR>";
  echo $obj->getBody($i);  // Get Body Of Mail number Return String Get Mail id in interger
  $str=$obj->GetAttech($i,"./"); // Get attached File from Mail Return name of file in comma separated string  args. (mailid, Path to store file)
  $ar=explode(",",$str);
  foreach($ar as $key=>$value)
    echo ($value=="")?"":"Atteched File :: ".$value."<br>";
  echo "<br>------------------------------------------------------------------------------------------<BR>";
  
    //$obj->deleteMails($i); // Delete Mail from Mail box
}
$obj->close_mailbox();   //Close Mail Box
?>


Nadam se da ce ti ovo biti od pomoci
---------------------------------------------------------------------
Just do it.
 
Odgovor na temu

Shejn
Srbija

Član broj: 11830
Poruke: 232
*.dynamic.sbb.rs.



Profil

icon Re: Da li je moguce citati sadrzaj ili naslov nekog maila?30.08.2008. u 20:48 - pre 190 meseci
Hvala !!!
 
Odgovor na temu

[es] :: PHP :: Da li je moguce citati sadrzaj ili naslov nekog maila?

[ Pregleda: 2204 | Odgovora: 7 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.