function smtp_send($header, $body) { global $enable_debug; $smtp = new SMTP(); $smtp->do_debug = $enable_debug; $hosts = explode(";", $this->Host); $index = 0; $connection = false; while ($index < count($hosts) && $connection == false) { if ($smtp->Connect($hosts[$index], $this->Port, $this->Timeout)) { $connection = true; } $index++; } if (!$connection) { $this->error_handler("SMTP Error: could not connect to SMTP host server(s)"); return false; } if ($this->blUseAuthLogin) { if (!$smtp->AuthHello($this->Helo, $this->AuthUser, $this->AuthPass)) { $this->error_handler("SMTP Error: Invalid username/password"); return false; } } else { $smtp->Hello($this->Helo); } $smtp->MailFrom(sprintf("<%s>", $this->From)); for ($i = 0; $i < count($this->to); $i++) { if (!$smtp->Recipient(sprintf("<%s>", $this->to[$i][0]))) { $this->error_handler("SMTP Error: Recipient not accepted. Verify your relay rules"); return false; } } for ($i = 0; $i < count($this->cc); $i++) { if (!$smtp->Recipient(sprintf("<%s>", $this->cc[$i][0]))) { $this->error_handler("SMTP Error: Recipient not accepted. Verify your relay rules"); return false; } } for ($i = 0; $i < count($this->bcc); $i++) { if (!$smtp->Recipient(sprintf("<%s>", $this->bcc[$i][0]))) { $this->error_handler("SMTP Error: Recipient not accepted. Verify your relay rules"); return false; } } if (!$smtp->Data(sprintf("%s%s", $header, $body))) { $this->error_handler("SMTP Error: Data not accepted"); return false; } $smtp->Quit(); }
function _send_mail($msgdata) { $smtp = new SMTP(); $smtp->debug = $this->debug; if (!$smtp->Connect($this->host, $this->port, $this->timeout)) { $this->errormsg = "SMTP Error: could not connect to SMTP host server"; $this->errormsg .= "[" . $this->host . ":" . $this->port . "]"; return false; } if ($this->authlogin) { if (!$smtp->AuthHello($this->helo, $this->authuser, $this->authpass)) { $this->errormsg = "SMTP Error: Invalid username/password"; if ($smtp->errormsg) { $this->errormsg .= "<br/>" . $smtp->errormsg; } return false; } } else { $smtp->Hello($this->helo); } if (!$smtp->MailFrom(sprintf("<%s>", $this->from))) { $this->errormsg = "SMTP Error: Mail from [" . $this->from . "] not accepted."; if ($smtp->errormsg) { $this->errormsg .= "<br/>" . $smtp->errormsg; } return false; } $iToCount = count($this->to); for ($i = 0; $i < $iToCount; $i++) { if (!$smtp->Recipient(sprintf("<%s>", $this->to[$i][0]))) { $this->errormsg = "SMTP Error: Recipient [" . $this->to[$i][0] . "] not accepted."; if ($smtp->errormsg) { $this->errormsg .= "<br/>" . $smtp->errormsg; } return false; } } $iCcCount = count($this->cc); for ($i = 0; $i < $iCcCount; $i++) { if (!$smtp->Recipient(sprintf("<%s>", $this->cc[$i][0]))) { $this->errormsg = "SMTP Error: Recipient [" . $this->cc[$i][0] . "] not accepted."; if ($smtp->errormsg) { $this->errormsg .= "<br/>" . $smtp->errormsg; } return false; } } $iBccCount = count($this->bcc); for ($i = 0; $i < $iBccCount; $i++) { if (!$smtp->Recipient(sprintf("<%s>", $this->bcc[$i][0]))) { $this->errormsg = "SMTP Error: Recipient [" . $this->bcc[$i][0] . "] not accepted."; if ($smtp->errormsg) { $this->errormsg .= "<br/>" . $smtp->errormsg; } return false; } } if (!$smtp->Data($msgdata)) { $this->errormsg = "SMTP Error: Data not accepted"; if ($smtp->errormsg) { $this->errormsg .= "<br/>" . $smtp->errormsg; } return false; } $smtp->Quit(); }