Public.Protocols.POP
Example usage: {code} array(mapping) options = ({ ([ "short":"u","long":"user" ]), ([ "short":"p","long":"password" ]), ([ "short":"s","long":"server"]), ([ "short":"t","long":"to"]) ([ "short":"f","long":"from"]) }); int main(int argc, array(string) argv) { foreach(options, mapping opt) { config += ([opt->long: Getopt.find_option(argv, opt->short,opt->long,"","")]); } mapping messagelist=([]); if(catch(popconnection = Public.Protocols.POP.Client(config->server))) { write("Can't connect to POP server %s.\n",config->server); return 1; } if(popconnection->auth_plain(config->user,config->password)) { write("Authentication failed.\n"); return 1; } if(catch(messagelist = popconnection->list())) { write("Connection Failed.\n"); return 1; } foreach(indices(messagelist), int messageid) { if(catch(content = popconnection->retr(messageid))) { write("Can't retrieve message.\n"); return -1; } object smtpclient = Public.Protocols.SMTP.Client("localhost"); /* The message can also be mime decoded, to guess the from address */ if(!catch(smtpclient->send_message(config->from,({config->to}),message->content[..]*""))) { catch(popconnection->dele(workermessage)) } } popconnection->quit(); return 0; } {code} Powered by PikeWiki2 |
|||
gotpike.org | Copyright © 2004 - 2009 | Pike is a trademark of Department of Computer and Information Science, Linköping University |