Changeset View
Changeset View
Standalone View
Standalone View
externals/phpmailer/class.smtp.php
Context not available. | |||||
// SMTP server can take longer to respond, give longer timeout for first read | // SMTP server can take longer to respond, give longer timeout for first read | ||||
// Windows does not have support for this timeout function | // Windows does not have support for this timeout function | ||||
if(substr(PHP_OS, 0, 3) != "WIN") | if(@substr(PHP_OS, 0, 3) != "WIN") | ||||
socket_set_timeout($this->smtp_conn, $tval, 0); | socket_set_timeout($this->smtp_conn, $tval, 0); | ||||
// get any announcement | // get any announcement | ||||
Context not available. | |||||
fputs($this->smtp_conn,"STARTTLS" . $this->CRLF); | fputs($this->smtp_conn,"STARTTLS" . $this->CRLF); | ||||
$rply = $this->get_lines(); | $rply = $this->get_lines(); | ||||
$code = substr($rply,0,3); | $code = @substr($rply,0,3); | ||||
if($this->do_debug >= 2) { | if($this->do_debug >= 2) { | ||||
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; | echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; | ||||
Context not available. | |||||
$this->error = | $this->error = | ||||
array("error" => "STARTTLS not accepted from server", | array("error" => "STARTTLS not accepted from server", | ||||
"smtp_code" => $code, | "smtp_code" => $code, | ||||
"smtp_msg" => substr($rply,4)); | "smtp_msg" => @substr($rply,4)); | ||||
if($this->do_debug >= 1) { | if($this->do_debug >= 1) { | ||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; | ||||
} | } | ||||
Context not available. | |||||
fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF); | fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF); | ||||
$rply = $this->get_lines(); | $rply = $this->get_lines(); | ||||
$code = substr($rply,0,3); | $code = @substr($rply,0,3); | ||||
if($code != 334) { | if($code != 334) { | ||||
$this->error = | $this->error = | ||||
array("error" => "AUTH not accepted from server", | array("error" => "AUTH not accepted from server", | ||||
"smtp_code" => $code, | "smtp_code" => $code, | ||||
"smtp_msg" => substr($rply,4)); | "smtp_msg" => @substr($rply,4)); | ||||
if($this->do_debug >= 1) { | if($this->do_debug >= 1) { | ||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; | ||||
} | } | ||||
Context not available. | |||||
fputs($this->smtp_conn, base64_encode($username) . $this->CRLF); | fputs($this->smtp_conn, base64_encode($username) . $this->CRLF); | ||||
$rply = $this->get_lines(); | $rply = $this->get_lines(); | ||||
$code = substr($rply,0,3); | $code = @substr($rply,0,3); | ||||
if($code != 334) { | if($code != 334) { | ||||
$this->error = | $this->error = | ||||
array("error" => "Username not accepted from server", | array("error" => "Username not accepted from server", | ||||
"smtp_code" => $code, | "smtp_code" => $code, | ||||
"smtp_msg" => substr($rply,4)); | "smtp_msg" => @substr($rply,4)); | ||||
if($this->do_debug >= 1) { | if($this->do_debug >= 1) { | ||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; | ||||
} | } | ||||
Context not available. | |||||
fputs($this->smtp_conn, base64_encode($password) . $this->CRLF); | fputs($this->smtp_conn, base64_encode($password) . $this->CRLF); | ||||
$rply = $this->get_lines(); | $rply = $this->get_lines(); | ||||
$code = substr($rply,0,3); | $code = @substr($rply,0,3); | ||||
if($code != 235) { | if($code != 235) { | ||||
$this->error = | $this->error = | ||||
array("error" => "Password not accepted from server", | array("error" => "Password not accepted from server", | ||||
"smtp_code" => $code, | "smtp_code" => $code, | ||||
"smtp_msg" => substr($rply,4)); | "smtp_msg" => @substr($rply,4)); | ||||
if($this->do_debug >= 1) { | if($this->do_debug >= 1) { | ||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; | ||||
} | } | ||||
Context not available. | |||||
fputs($this->smtp_conn,"DATA" . $this->CRLF); | fputs($this->smtp_conn,"DATA" . $this->CRLF); | ||||
$rply = $this->get_lines(); | $rply = $this->get_lines(); | ||||
$code = substr($rply,0,3); | $code = @substr($rply,0,3); | ||||
if($this->do_debug >= 2) { | if($this->do_debug >= 2) { | ||||
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; | echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; | ||||
Context not available. | |||||
$this->error = | $this->error = | ||||
array("error" => "DATA command not accepted from server", | array("error" => "DATA command not accepted from server", | ||||
"smtp_code" => $code, | "smtp_code" => $code, | ||||
"smtp_msg" => substr($rply,4)); | "smtp_msg" => @substr($rply,4)); | ||||
if($this->do_debug >= 1) { | if($this->do_debug >= 1) { | ||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; | ||||
} | } | ||||
Context not available. | |||||
// normalize the line breaks so we know the explode works | // normalize the line breaks so we know the explode works | ||||
$msg_data = str_replace("\r\n","\n",$msg_data); | $msg_data = str_replace("\r\n","\n",$msg_data); | ||||
$msg_data = str_replace("\r","\n",$msg_data); | $msg_data = str_replace("\r","\n",$msg_data); | ||||
$lines = explode("\n",$msg_data); | $lines = @explode("\n",$msg_data); | ||||
/* we need to find a good way to determine is headers are | /* we need to find a good way to determine is headers are | ||||
* in the msg_data or if it is a straight msg body | * in the msg_data or if it is a straight msg body | ||||
Context not available. | |||||
* headers. | * headers. | ||||
*/ | */ | ||||
$field = substr($lines[0],0,strpos($lines[0],":")); | $field = @substr($lines[0],0,@strpos($lines[0],":")); | ||||
$in_headers = false; | $in_headers = false; | ||||
if(!empty($field) && !strstr($field," ")) { | if(!empty($field) && !strstr($field," ")) { | ||||
$in_headers = true; | $in_headers = true; | ||||
Context not available. | |||||
$in_headers = false; | $in_headers = false; | ||||
} | } | ||||
// ok we need to break this line up into several smaller lines | // ok we need to break this line up into several smaller lines | ||||
while(strlen($line) > $max_line_length) { | while(@strlen($line) > $max_line_length) { | ||||
$pos = strrpos(substr($line,0,$max_line_length)," "); | $pos = strrpos(@substr($line,0,$max_line_length)," "); | ||||
// Patch to fix DOS attack | // Patch to fix DOS attack | ||||
if(!$pos) { | if(!$pos) { | ||||
$pos = $max_line_length - 1; | $pos = $max_line_length - 1; | ||||
$lines_out[] = substr($line,0,$pos); | $lines_out[] = @substr($line,0,$pos); | ||||
$line = substr($line,$pos); | $line = @substr($line,$pos); | ||||
} else { | } else { | ||||
$lines_out[] = substr($line,0,$pos); | $lines_out[] = @substr($line,0,$pos); | ||||
$line = substr($line,$pos + 1); | $line = @substr($line,$pos + 1); | ||||
} | } | ||||
/* if processing headers add a LWSP-char to the front of new line | /* if processing headers add a LWSP-char to the front of new line | ||||
Context not available. | |||||
// send the lines to the server | // send the lines to the server | ||||
while(list(,$line_out) = @each($lines_out)) { | while(list(,$line_out) = @each($lines_out)) { | ||||
if(strlen($line_out) > 0) | if(@strlen($line_out) > 0) | ||||
{ | { | ||||
if(substr($line_out, 0, 1) == ".") { | if(@substr($line_out, 0, 1) == ".") { | ||||
$line_out = "." . $line_out; | $line_out = "." . $line_out; | ||||
} | } | ||||
} | } | ||||
Context not available. | |||||
fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF); | fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF); | ||||
$rply = $this->get_lines(); | $rply = $this->get_lines(); | ||||
$code = substr($rply,0,3); | $code = @substr($rply,0,3); | ||||
if($this->do_debug >= 2) { | if($this->do_debug >= 2) { | ||||
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; | echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; | ||||
Context not available. | |||||
$this->error = | $this->error = | ||||
array("error" => "DATA not accepted from server", | array("error" => "DATA not accepted from server", | ||||
"smtp_code" => $code, | "smtp_code" => $code, | ||||
"smtp_msg" => substr($rply,4)); | "smtp_msg" => @substr($rply,4)); | ||||
if($this->do_debug >= 1) { | if($this->do_debug >= 1) { | ||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; | ||||
} | } | ||||
Context not available. | |||||
fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF); | fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF); | ||||
$rply = $this->get_lines(); | $rply = $this->get_lines(); | ||||
$code = substr($rply,0,3); | $code = @substr($rply,0,3); | ||||
if($this->do_debug >= 2) { | if($this->do_debug >= 2) { | ||||
echo "SMTP -> FROM SERVER: " . $rply . $this->CRLF . '<br />'; | echo "SMTP -> FROM SERVER: " . $rply . $this->CRLF . '<br />'; | ||||
Context not available. | |||||
$this->error = | $this->error = | ||||
array("error" => $hello . " not accepted from server", | array("error" => $hello . " not accepted from server", | ||||
"smtp_code" => $code, | "smtp_code" => $code, | ||||
"smtp_msg" => substr($rply,4)); | "smtp_msg" => @substr($rply,4)); | ||||
if($this->do_debug >= 1) { | if($this->do_debug >= 1) { | ||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; | ||||
} | } | ||||
Context not available. | |||||
fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF); | fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF); | ||||
$rply = $this->get_lines(); | $rply = $this->get_lines(); | ||||
$code = substr($rply,0,3); | $code = @substr($rply,0,3); | ||||
if($this->do_debug >= 2) { | if($this->do_debug >= 2) { | ||||
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; | echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; | ||||
Context not available. | |||||
$this->error = | $this->error = | ||||
array("error" => "MAIL not accepted from server", | array("error" => "MAIL not accepted from server", | ||||
"smtp_code" => $code, | "smtp_code" => $code, | ||||
"smtp_msg" => substr($rply,4)); | "smtp_msg" => @substr($rply,4)); | ||||
if($this->do_debug >= 1) { | if($this->do_debug >= 1) { | ||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; | ||||
} | } | ||||
Context not available. | |||||
$rval = true; | $rval = true; | ||||
$e = null; | $e = null; | ||||
$code = substr($byemsg,0,3); | $code = @substr($byemsg,0,3); | ||||
if($code != 221) { | if($code != 221) { | ||||
// use e as a tmp var cause Close will overwrite $this->error | // use e as a tmp var cause Close will overwrite $this->error | ||||
$e = array("error" => "SMTP server rejected quit command", | $e = array("error" => "SMTP server rejected quit command", | ||||
"smtp_code" => $code, | "smtp_code" => $code, | ||||
"smtp_rply" => substr($byemsg,4)); | "smtp_rply" => @substr($byemsg,4)); | ||||
$rval = false; | $rval = false; | ||||
if($this->do_debug >= 1) { | if($this->do_debug >= 1) { | ||||
echo "SMTP -> ERROR: " . $e["error"] . ": " . $byemsg . $this->CRLF . '<br />'; | echo "SMTP -> ERROR: " . $e["error"] . ": " . $byemsg . $this->CRLF . '<br />'; | ||||
Context not available. | |||||
fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF); | fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF); | ||||
$rply = $this->get_lines(); | $rply = $this->get_lines(); | ||||
$code = substr($rply,0,3); | $code = @substr($rply,0,3); | ||||
if($this->do_debug >= 2) { | if($this->do_debug >= 2) { | ||||
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; | echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; | ||||
Context not available. | |||||
$this->error = | $this->error = | ||||
array("error" => "RCPT not accepted from server", | array("error" => "RCPT not accepted from server", | ||||
"smtp_code" => $code, | "smtp_code" => $code, | ||||
"smtp_msg" => substr($rply,4)); | "smtp_msg" => @substr($rply,4)); | ||||
if($this->do_debug >= 1) { | if($this->do_debug >= 1) { | ||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; | ||||
} | } | ||||
Context not available. | |||||
fputs($this->smtp_conn,"RSET" . $this->CRLF); | fputs($this->smtp_conn,"RSET" . $this->CRLF); | ||||
$rply = $this->get_lines(); | $rply = $this->get_lines(); | ||||
$code = substr($rply,0,3); | $code = @substr($rply,0,3); | ||||
if($this->do_debug >= 2) { | if($this->do_debug >= 2) { | ||||
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; | echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; | ||||
Context not available. | |||||
$this->error = | $this->error = | ||||
array("error" => "RSET failed", | array("error" => "RSET failed", | ||||
"smtp_code" => $code, | "smtp_code" => $code, | ||||
"smtp_msg" => substr($rply,4)); | "smtp_msg" => @substr($rply,4)); | ||||
if($this->do_debug >= 1) { | if($this->do_debug >= 1) { | ||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; | ||||
} | } | ||||
Context not available. | |||||
fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF); | fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF); | ||||
$rply = $this->get_lines(); | $rply = $this->get_lines(); | ||||
$code = substr($rply,0,3); | $code = @substr($rply,0,3); | ||||
if($this->do_debug >= 2) { | if($this->do_debug >= 2) { | ||||
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; | echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; | ||||
Context not available. | |||||
$this->error = | $this->error = | ||||
array("error" => "SAML not accepted from server", | array("error" => "SAML not accepted from server", | ||||
"smtp_code" => $code, | "smtp_code" => $code, | ||||
"smtp_msg" => substr($rply,4)); | "smtp_msg" => @substr($rply,4)); | ||||
if($this->do_debug >= 1) { | if($this->do_debug >= 1) { | ||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; | ||||
} | } | ||||
Context not available. | |||||
echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '<br />'; | echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '<br />'; | ||||
} | } | ||||
// if 4th character is a space, we are done reading, break the loop | // if 4th character is a space, we are done reading, break the loop | ||||
if(substr($str,3,1) == " ") { break; } | if(@substr($str,3,1) == " ") { break; } | ||||
} | } | ||||
return $data; | return $data; | ||||
} | } | ||||
Context not available. |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0