Karigi tagged ‘parse email’

Kif jirċievi u parse emails li jużaw POP3 u PHP

1 Mar, 2010

Nixtieq li jiddeskrivi xi metodi dwar kif tikteb il-proċessur tal-posta dieħla. I kellhom jużaw manipulazzjoni tali parse e-mails jkun irċieva minn sorsi varji. Dan jista 'jkun utli għall-kitba sistema tiegħek spam filter, magna tweġib jew biljett tas-sistema li jirċievu applikazzjonijiet bil-posta elettronika.

Biex timplimenta l-algoritmu parser e-mail irridu

  1. jgħaqqdu u l-log-on għall-e-mail server
  2. jgħodd in-numru ta 'ittri deħlin
  3. recive e-mail mis-server jużaw protokoll POP3
  4. l headers proċess e-mail u tal-ġisem u tagħmel parsing
  5. … jimplimenta kwalunkwe azzjonijiet addizzjonali

Ok, hemm kompitu speċifiku ħafna għall- PHP kodifikazzjoni, għalhekk għandna bżonn li jospitaw li tappoġġja l-rigward esterni. Jien ma tipproponix li tikteb id-deċiżjoni għal kollox għax ħafna twettqet minn programmaturi talent diġà. For example, inti tista 'tieħu modulu lesta li tippermetti jaċċetta l-e-mails minn server remot.

Thank li Manuel Lemos u tiegħu modulu (klassi PHP) li jismu pop3.php.

Li jgħaqqdu il-klassi għal kodiċi tiegħek, inti biss bżonn jużaw jinkludu jew jitolbu kmand: jeħtieġu(“pop3.php”);


hostname=$hostname;
$result=$pop3_connection->Open();

// We are trying to open connection and display the result
echo $result;
// Trying to logon and display the error if any appear
$error=$pop3_connection->Login($user,$accesscode,$apop);
if ($żball<>"L-iżball Password: nuqqas Logon: magħruf utent isem jew il-password ħażin. ") {echo $error; ħruġ;}
// Now get the statistic how many emails are stored and the size of them $result=$pop3_connection->Statistics($messages, $size);
eku "$hostname contains  $messages ta ' $size bytes.";

//..... Hemm nistgħu tirċievi e-mails fl-ċiklu u parse minnhom .... //

// Jekk xejn ma - we can close the connection
$error=$pop3_connection->Close(); //
echo $error;
?>

Issa nafu kif għandna naslu biex jgħaqqdu u l-log-on għall-server POP3 u kif titlob l-għadd ta 'Inbox e-mails u minnhom daqsijiet. Li jmiss, għandna tirċievi kull e-mail u parse l-intestaturi u firxa korp.

Li jitkompla

Share u gost

  • wp socializer sprite mask 16px How to receive and parse emails using POP3 and PHP
  • wp socializer sprite mask 16px How to receive and parse emails using POP3 and PHP
  • wp socializer sprite mask 16px How to receive and parse emails using POP3 and PHP
  • wp socializer sprite mask 16px How to receive and parse emails using POP3 and PHP
  • wp socializer sprite mask 16px How to receive and parse emails using POP3 and PHP
  • wp socializer sprite mask 16px How to receive and parse emails using POP3 and PHP
  • wp socializer sprite mask 16px How to receive and parse emails using POP3 and PHP
  • wp socializer sprite mask 16px How to receive and parse emails using POP3 and PHP
  • wp socializer sprite mask 16px How to receive and parse emails using POP3 and PHP