public function SMTP::Quit in SMTP Authentication Support 7.2
Same name and namespace in other branches
- 5 smtp.module \SMTP::Quit()
- 7 smtp.transport.inc \SMTP::Quit()
Sends the quit command to the server and then closes the socket if there is no error or the $close_on_error argument is TRUE.
Implements from rfc 821: QUIT <CRLF>
SMTP CODE SUCCESS: 221 SMTP CODE ERROR : 500 @access public
Return value
bool
File
- ./
smtp.transport.inc, line 581 - SMTP mail transport class for the smtp module,based on code of the phpmailer library, customized and relicensed to GPLv2
Class
- SMTP
- SMTP is rfc 821 compliant and implements all the rfc 821 SMTP commands except TURN which will always return a not implemented error. SMTP also provides some utility methods for sending mail to an SMTP server. original author: Chris Ryan
Code
public function Quit($close_on_error = TRUE) {
$this->error = NULL;
// so there is no confusion
if (!$this
->connected()) {
$this->error = array(
"error" => "Called Quit() without being connected",
);
return FALSE;
}
// send the quit command to the server
fputs($this->smtp_conn, "quit" . $this->CRLF);
// get any good-bye messages
$byemsg = $this
->get_lines();
if ($this->do_debug >= 2) {
drupal_set_message(t("SMTP -> FROM SERVER: @byemsg", array(
"@rply" => $byemsg,
)));
}
$rval = TRUE;
$e = NULL;
$code = substr($byemsg, 0, 3);
if ($code != 221) {
// use e as a tmp var cause Close will overwrite $this->error
$e = array(
"error" => "SMTP server rejected quit command",
"smtp_code" => $code,
"smtp_rply" => substr($byemsg, 4),
);
$rval = FALSE;
if ($this->do_debug >= 1) {
drupal_set_message(t("SMTP -> ERROR: @error: @rply", array(
"@error" => $this->error["error"],
"@rply" => $rply,
)));
}
}
if (empty($e) || $close_on_error) {
$this
->Close();
}
return $rval;
}