|
|
|
@ -49,9 +49,9 @@ $SMTP_CONN = null;
|
|
|
|
|
* @return bool Returns TRUE on success, or FALSE on error
|
|
|
|
|
* @access public
|
|
|
|
|
*/
|
|
|
|
|
function smtp_mail($from, $recipients, &$headers, &$body)
|
|
|
|
|
function smtp_mail($from, $recipients, &$headers, &$body, &$response)
|
|
|
|
|
{
|
|
|
|
|
global $SMTP_CONN, $CONFIG, $SMTP_ERROR;
|
|
|
|
|
global $SMTP_CONN, $CONFIG;
|
|
|
|
|
$smtp_timeout = null;
|
|
|
|
|
$smtp_host = $CONFIG['smtp_server'];
|
|
|
|
|
$smtp_port = is_numeric($CONFIG['smtp_port']) ? $CONFIG['smtp_port'] : 25;
|
|
|
|
@ -85,7 +85,7 @@ function smtp_mail($from, $recipients, &$headers, &$body)
|
|
|
|
|
if (PEAR::isError($result))
|
|
|
|
|
{
|
|
|
|
|
$SMTP_CONN = null;
|
|
|
|
|
$SMTP_ERROR .= "Connection failed: ".$result->getMessage()."\n";
|
|
|
|
|
$response[] = "Connection failed: ".$result->getMessage();
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -108,7 +108,7 @@ function smtp_mail($from, $recipients, &$headers, &$body)
|
|
|
|
|
if (PEAR::isError($result))
|
|
|
|
|
{
|
|
|
|
|
smtp_reset();
|
|
|
|
|
$SMTP_ERROR .= "Authentication failure: ".$result->getMessage()."\n";
|
|
|
|
|
$response[] .= "Authentication failure: ".$result->getMessage();
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -132,7 +132,7 @@ function smtp_mail($from, $recipients, &$headers, &$body)
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
smtp_reset();
|
|
|
|
|
$SMTP_ERROR .= "Invalid message headers\n";
|
|
|
|
|
$response[] .= "Invalid message headers";
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -140,7 +140,7 @@ function smtp_mail($from, $recipients, &$headers, &$body)
|
|
|
|
|
if (!isset($from))
|
|
|
|
|
{
|
|
|
|
|
smtp_reset();
|
|
|
|
|
$SMTP_ERROR .= "No From address has been provided\n";
|
|
|
|
|
$response[] .= "No From address has been provided";
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -149,7 +149,7 @@ function smtp_mail($from, $recipients, &$headers, &$body)
|
|
|
|
|
if (PEAR::isError($SMTP_CONN->mailFrom($from)))
|
|
|
|
|
{
|
|
|
|
|
smtp_reset();
|
|
|
|
|
$SMTP_ERROR .= "Failed to set sender '$from'\n";
|
|
|
|
|
$response[] .= "Failed to set sender '$from'";
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -169,21 +169,30 @@ function smtp_mail($from, $recipients, &$headers, &$body)
|
|
|
|
|
if (PEAR::isError($SMTP_CONN->rcptTo($recipient)))
|
|
|
|
|
{
|
|
|
|
|
smtp_reset();
|
|
|
|
|
$SMTP_ERROR .= "Failed to add recipient '$recipient'\n";
|
|
|
|
|
$response[] .= "Failed to add recipient '$recipient'";
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Concatenate headers and body so it can be passed by reference to SMTP_CONN->data
|
|
|
|
|
// so preg_replace in SMTP_CONN->quotedata will store a reference instead of a copy.
|
|
|
|
|
// We are still forced to make another copy here for a couple ticks so we don't really
|
|
|
|
|
// get to save a copy in the method call.
|
|
|
|
|
$data = $text_headers . "\r\n" . $body;
|
|
|
|
|
|
|
|
|
|
// unset old vars to save data and so we can pass into SMTP_CONN->data by reference.
|
|
|
|
|
unset($text_headers, $body);
|
|
|
|
|
|
|
|
|
|
// Send the message's headers and the body as SMTP data.
|
|
|
|
|
if (PEAR::isError($SMTP_CONN->data("$text_headers\r\n$body")))
|
|
|
|
|
if (PEAR::isError($SMTP_CONN->data($data)))
|
|
|
|
|
{
|
|
|
|
|
smtp_reset();
|
|
|
|
|
$SMTP_ERROR .= "Failed to send data\n";
|
|
|
|
|
$response[] .= "Failed to send data";
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$response[] = join(': ', $SMTP_CONN->getResponse());
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|