zion Plop | http://www.phpbuilder.com/columns/musone19990207.php3
Sinon vla un script que j'ai fait pour envoyer tous les messages venant d'un compte mail vers les newsgroups d'un groupe de dev Delphi Code :
- <?php
-
- //POP Options
- $cfgPopServer = "pop.serveur.com"; //Modifié :D
- $cfgPopPort = 110;
- $cfgUser = "tonuser"; //Modifié :D
- $cfgTimeOut = 10;
- $cfgPass = "tonpass"; //Modifié :D
- $cfgIgnore = "polom@polom.com"; //Modifié :D
- //NNTP options
- $cfgGroup = "jedi.vcl";
- $cfgServer = "forums.unserveur.com"; //Modifié :D
- $cfgPort = 119;
- function ConnectToServer()
- {
- global $cfgServer, $cfgPort, $cfgTimeOut, $handle;
- $handle = fsockopen($cfgServer, $cfgPort, $errno, $errstr, $cfgTimeOut);
- return $handle!=0;
- }
- function PostArticle($from, $subject, $reference, $body, $oldsubject)
- {
- global $handle, $cfgGroup;
- if (strpos(StrToLower($oldsubject),"jedi-vcl" )!=false)
- $group = "jedi.vcl";
- else if (strpos(StrToLower($oldsubject),"developers" )!=false)
- $group = "jedi.vcl";
- else if (strpos(StrToLower($oldsubject),"math" )!=false)
- $group = "jedi.math";
- else
- return;
- fputs($handle,"POST\r\n" );
- $tmp = fgets($handle, 1024);
- $body = "From: $from\r\n".
- "Newsgroups: $group\r\n".
- "References: $reference\r\n".
- "Subject: $subject\r\n\n".
- $body."\r\n.\r\n"; //."\r\n.\r\n"; //Do not print . as we do not remove it from the pop message
- fputs($handle,$body);
- }
- //Connect to server
- $phandle = fsockopen($cfgPopServer, $cfgPopPort, $errno, $errstr, $cfgTimeOut);
- $tmp = fgets($phandle, 4096);
- fputs($phandle,"USER $cfgUser\r\n" );
- $tmp = fgets($phandle, 4096);
- fputs($phandle,"PASS $cfgPass\r\n" );
- $tmp = fgets($phandle, 4096);
- fputs($phandle,"STAT\r\n" );
- $tmp = fgets($phandle, 4096);
- $stat = Explode(" ",$tmp);
- //Get messages
- if (ConnectToServer())
- for ($i=1;$i<=$stat[1];$i++)
- {
- $header = true;
- $footer = false;
- $from = "";
- $subject = "";
- $article = "";
- $reference = "<none>";
- //Fetch message
- fputs($phandle,"RETR $i\r\n" );
- do
- {
- $tmp = fgets($phandle, 4096);
- if (trim($tmp)=="" )
- $header = false;
- else if (StrPos($tmp,"Yahoo! Groups Sponsor" )!=false)
- {
- $footer = true;
- $article = $article."----Message transited via JEDI Script Gateway----\n";
- }
- if ((!$footer) || (trim($tmp=="." )))
- if (!$header)
- {
- if (strpos($tmp,"---Reference:" )!=false)
- {
- $tmp = substr($tmp,strpos($tmp,":" )+2,4096);
- $tmp = Trim($tmp);
- if (strpos($tmp,"-" )!=false)
- $tmp = substr($tmp,0,strpos($tmp,"-" ));
- $reference = Trim($tmp);
- }
- else if (strpos($tmp,"---" )==false)
- $article = $article.$tmp;
- }
- else
- {
- if (substr($tmp,0,4) == "From" )
- {
- $tmp = substr($tmp,6,4096);
- $from = Trim($tmp);
- }
- else if (substr($tmp,0,7) == "Subject" )
- {
- $tmp = substr($tmp,8,4096);
- $subject = $tmp;
- }
- }
- }while (trim($tmp)!="." );
- //Post article
- $oldsubject = $subject;
- $k = StrPos($subject,"]" );
- if ($k!=false) //Avoid spams (if no ] in the subject, it's not surely not a msg from the mailing list)
- {
- $subject = Trim(SubStr($subject,$k+1));
- if ((StrPos($from,$cfgIgnore)==false) && (StrPos(StrToLower($subject),"unsubscribe" )==false))
- {
- $oldfrom = $from;
- $k = StrPos($from,"<" );
- if ($k==false)
- $k = StrPos($from,"@" );
- if ($k!=false)
- $from = Trim(SubStr($from,0,$k));
- $from = $from." <".$cfgIgnore.">";
- PostArticle($from,$subject,$reference,$article,$oldsubject);
- }
- }
- /*echo "FROM: $from\n";
- echo "SUBJECT: $subject\n";
- echo "Ref: $reference\n";
- echo "$article\n";*/
- fputs($phandle,"DELE $i\r\n" );
- $tmp = fgets($phandle, 4096);
- }
- fputs($phandle,"QUIT\n" );
- $tmp = fgets($phandle, 4096);
- fclose($phandle);
- fclose($handle);
- ?>
|
c'est ni sécure, ni portable et encore moins propre, mais j'en avais besoin vite, et c'est assez perso... enfin soit, tu peux toujours t'amuser avec ca ---------------
Informaticien.be - Lancez des défis à vos amis
|