";
$deadmsg = "";
$verbel = "1";
Class Pop {
//all these varibles can be set directly without calling the procedures,
//this just makes it simple
Function serverInfo($in_SERVER="mail.nimc1.on.home.com", $user_SERVER="me"){
$this->smtp_server = $in_SERVER;
$this->smtp_user = $user_SERVER;
}
Function setText($in_SUBJECT, $in_TEXT){
$this->mailSubject = ereg_replace("\n"," ",$in_SUBJECT);
$this->mailText = $in_TEXT;
}
Function setFrom($in_TO, $in_FROM){
$this->mailTO = $in_TO;
$this->mailFrom = $in_FROM;
}
//the main sending function..hopefully not as buggy as the original "sendmail"
Function sendmail(){
//make sure the user entered everything..don't want to be spamming :)
if(trim($this->mailSubject) != ""){
} else {
$this->deadmsg .= " A subject. Please enter a subject.\n";
}
if(trim($this->mailText) != ""){
} else {
$this->deadmsg .= " Any data. Please enter some..\n";
}
if(trim($this->mailTO) != ""){
} else {
$this->deadmsg .= " A valid send-to address..\n";
}
if(trim($this->mailFrom) != ""){
} else {
$this->deadmsg .= " A valid recepient..\n";
}
//if the user has entered something wrong
//it gets trapped out to the "End()" procedure
if ($this->deadmsg != ""){
$this->end();
}
//else..
$server = $this->smtp_server;
$smtp_sock = fsockopen($server, 25, &$errno, &$errstr, 30);
if (!$smtp_sock) {
echo "error...!!\n";
echo "$errstr ($errno)
\n";
} else {
while (!feof($smtp_sock)){
fputs($smtp_sock, "HELO ".$this->smtp_server."\r\n");
$this->echos($smtp_sock,4096,$this->verbel);
fputs($smtp_sock, "MAIL FROM:<".$this->mailFrom.">\r\n");
$this->echos($smtp_sock,4096,$this->verbel);
fputs($smtp_sock, "RCPT TO:<".$this->mailTO.">\r\n");
$this->echos($smtp_sock,4096,$this->verbel);
fputs($smtp_sock, "DATA\n");
$this->echos($smtp_sock,4096,$this->verbel);
fputs($smtp_sock, "From: ".$this->mailFrom."\nSubject: ".$this->mailSubject."\nTo: ".$this->mailTO."\n\n".$this->mailText."\n");
$this->echos($smtp_sock,4096,$this->verbel);
fputs($smtp_sock, "\r\n.\r\n");
$this->echos($smtp_sock,4096,$this->verbel);
fputs($smtp_sock, "quit\n");
}
if ($this->verbel==1)
{
echo "
";
echo "\n\nsending mail from..". $this->mailFrom ."\n";
echo "to.................". $this->mailTO ."\n";
echo "saying.............". $this->mailSubject ."\n";
echo " ". $this->mailText ."\n";
echo "Done :)\n";
echo "";
}
fclose($smtp_sock);
}
}
Function echos($pipe_IN, $size=4096, $print){ //play with this buffer if your connections slow
if ($print == 1){
echo nl2br(fgets($pipe_IN, $size)); //modifyed command for prettyness
} else {
nl2br(fgets($pipe_IN, $size)); //Sent to the bit bucket or this function hangs here.
//silent..
}
}
Function end(){
echo "\n";
echo "You have failed in these following places..\n";
echo $this->deadmsg; //echo the collected msgs's
echo "\n";
exit; //This can be deadly..remove if you are having unexplained "exits"
}
}
?>