48 define(
'PEAR_MAIL_SMTP_ERROR_CREATE', 10000);
51 define(
'PEAR_MAIL_SMTP_ERROR_CONNECT', 10001);
54 define(
'PEAR_MAIL_SMTP_ERROR_AUTH', 10002);
57 define(
'PEAR_MAIL_SMTP_ERROR_FROM', 10003);
60 define(
'PEAR_MAIL_SMTP_ERROR_SENDER', 10004);
63 define(
'PEAR_MAIL_SMTP_ERROR_RECIPIENT', 10005);
66 define(
'PEAR_MAIL_SMTP_ERROR_DATA', 10006);
193 if (isset($params[
'host'])) $this->host = $params[
'host'];
194 if (isset($params[
'port'])) $this->port = $params[
'port'];
195 if (isset($params[
'auth'])) $this->auth = $params[
'auth'];
196 if (isset($params[
'username'])) $this->username = $params[
'username'];
197 if (isset($params[
'password'])) $this->password = $params[
'password'];
198 if (isset($params[
'localhost'])) $this->localhost = $params[
'localhost'];
199 if (isset($params[
'timeout'])) $this->timeout = $params[
'timeout'];
200 if (isset($params[
'debug'])) $this->debug = (bool)$params[
'debug'];
201 if (isset($params[
'persist'])) $this->persist = (
bool)$params[
'persist'];
202 if (isset($params[
'pipelining'])) $this->pipelining = (
bool)$params[
'pipelining'];
205 if (isset($params[
'verp'])) {
209 register_shutdown_function(array(&$this,
'_Mail_smtp'));
245 function send($recipients, $headers, $body)
253 if (!is_array($headers)) {
260 if (is_a($headerElements,
'PEAR_Error')) {
261 $this->_smtp->rset();
262 return $headerElements;
264 list($from, $textHeaders) = $headerElements;
269 if (!empty($headers[
'Return-Path'])) {
270 $from = $headers[
'Return-Path'];
274 $this->_smtp->rset();
280 if (!empty($this->_extparams)) {
281 foreach ($this->_extparams as $key => $val) {
282 $params .=
' ' . $key . (is_null($val) ?
'' :
'=' . $val);
287 $this->_smtp->rset();
292 if (is_a($recipients,
'PEAR_Error')) {
293 $this->_smtp->rset();
297 foreach ($recipients as $recipient) {
298 $res = $this->_smtp->rcptTo($recipient);
299 if (is_a(
$res,
'PEAR_Error')) {
301 $this->_smtp->rset();
307 $res = $this->_smtp->data($textHeaders .
"\r\n\r\n" . $body);
308 list(,$args) = $this->_smtp->getResponse();
310 if (preg_match(
"/Ok: queued as (.*)/", $args, $queued)) {
311 $this->queued_as = $queued[1];
316 $this->greeting = $this->_smtp->getGreeting();
318 if (is_a(
$res,
'PEAR_Error')) {
320 $this->_smtp->rset();
325 if ($this->persist ===
false) {
344 if (is_object($this->_smtp) !==
false) {
348 include_once
'Net/SMTP.php';
349 $this->_smtp = &
new Net_SMTP($this->host,
354 if (is_object($this->_smtp) ===
false) {
361 $this->_smtp->setDebug(
true);
367 $this->host .
':' . $this->port,
374 $method = is_string($this->auth) ? $this->auth :
'';
379 $error = $this->
_error(
"$method authentication failure",
381 $this->_smtp->rset();
400 $this->_extparams[$keyword] = $value;
414 if (is_object($this->_smtp) && $this->_smtp->disconnect()) {
419 return ($this->_smtp === null);
436 list($code, $response) = $this->_smtp->getResponse();
440 .
' [SMTP: ' .
$error->getMessage()
441 .
" (code: $code, response: $response)]";