📄 smtp.php
字号:
return true; } /** * Send the MAIL FROM: command. * * @param string $sender The sender (reverse path) to set. * @param string $params String containing additional MAIL parameters, * such as the NOTIFY flags defined by RFC 1891 * or the VERP protocol. * * If $params is an array, only the 'verp' option * is supported. If 'verp' is true, the XVERP * parameter is appended to the MAIL command. If * the 'verp' value is a string, the full * XVERP=value parameter is appended. * * @return mixed Returns a PEAR_Error with an error message on any * kind of failure, or true on success. * @access public * @since 1.0 */ function mailFrom($sender, $params = null) { $args = "FROM:<$sender>"; /* Support the deprecated array form of $params. */ if (is_array($params) && isset($params['verp'])) { /* XVERP */ if ($params['verp'] === true) { $args .= ' XVERP'; /* XVERP=something */ } elseif (trim($params['verp'])) { $args .= ' XVERP=' . $params['verp']; } } elseif (is_string($params)) { $args .= ' ' . $params; } if (PEAR::isError($error = $this->_put('MAIL', $args))) { return $error; } if (PEAR::isError($error = $this->_parseResponse(250))) { return $error; } return true; } /** * Send the RCPT TO: command. * * @param string $recipient The recipient (forward path) to add. * @param string $params String containing additional RCPT parameters, * such as the NOTIFY flags defined by RFC 1891. * * @return mixed Returns a PEAR_Error with an error message on any * kind of failure, or true on success. * * @access public * @since 1.0 */ function rcptTo($recipient, $params = null) { $args = "TO:<$recipient>"; if (is_string($params)) { $args .= ' ' . $params; } if (PEAR::isError($error = $this->_put('RCPT', $args))) { return $error; } if (PEAR::isError($error = $this->_parseResponse(array(250, 251)))) { return $error; } return true; } /** * Quote the data so that it meets SMTP standards. * * This is provided as a separate public function to facilitate * easier overloading for the cases where it is desirable to * customize the quoting behavior. * * @param string $data The message text to quote. The string must be passed * by reference, and the text will be modified in place. * * @access public * @since 1.2 */ function quotedata(&$data) { /* Change Unix (\n) and Mac (\r) linefeeds into * Internet-standard CRLF (\r\n) linefeeds. */ $data = preg_replace(array('/(?<!\r)\n/','/\r(?!\n)/'), "\r\n", $data); /* Because a single leading period (.) signifies an end to the * data, legitimate leading periods need to be "doubled" * (e.g. '..'). */ $data = str_replace("\n.", "\n..", $data); } /** * Send the DATA command. * * @param string $data The message body to send. * * @return mixed Returns a PEAR_Error with an error message on any * kind of failure, or true on success. * @access public * @since 1.0 */ function data($data) { /* RFC 1870, section 3, subsection 3 states "a value of zero * indicates that no fixed maximum message size is in force". * Furthermore, it says that if "the parameter is omitted no * information is conveyed about the server's fixed maximum * message size". */ if (isset($this->_esmtp['SIZE']) && ($this->_esmtp['SIZE'] > 0)) { if (strlen($data) >= $this->_esmtp['SIZE']) { $this->disconnect(); return PEAR::raiseError('Message size excedes the server limit'); } } /* Quote the data based on the SMTP standards. */ $this->quotedata($data); if (PEAR::isError($error = $this->_put('DATA'))) { return $error; } if (PEAR::isError($error = $this->_parseResponse(354))) { return $error; } if (PEAR::isError($result = $this->_send($data . "\r\n.\r\n"))) { return $result; } if (PEAR::isError($error = $this->_parseResponse(250))) { return $error; } return true; } /** * Send the SEND FROM: command. * * @param string The reverse path to send. * * @return mixed Returns a PEAR_Error with an error message on any * kind of failure, or true on success. * @access public * @since 1.2.6 */ function sendFrom($path) { if (PEAR::isError($error = $this->_put('SEND', "FROM:<$path>"))) { return $error; } if (PEAR::isError($error = $this->_parseResponse(250))) { return $error; } return true; } /** * Backwards-compatibility wrapper for sendFrom(). * * @param string The reverse path to send. * * @return mixed Returns a PEAR_Error with an error message on any * kind of failure, or true on success. * * @access public * @since 1.0 * @deprecated 1.2.6 */ function send_from($path) { return sendFrom($path); } /** * Send the SOML FROM: command. * * @param string The reverse path to send. * * @return mixed Returns a PEAR_Error with an error message on any * kind of failure, or true on success. * @access public * @since 1.2.6 */ function somlFrom($path) { if (PEAR::isError($error = $this->_put('SOML', "FROM:<$path>"))) { return $error; } if (PEAR::isError($error = $this->_parseResponse(250))) { return $error; } return true; } /** * Backwards-compatibility wrapper for somlFrom(). * * @param string The reverse path to send. * * @return mixed Returns a PEAR_Error with an error message on any * kind of failure, or true on success. * * @access public * @since 1.0 * @deprecated 1.2.6 */ function soml_from($path) { return somlFrom($path); } /** * Send the SAML FROM: command. * * @param string The reverse path to send. * * @return mixed Returns a PEAR_Error with an error message on any * kind of failure, or true on success. * @access public * @since 1.2.6 */ function samlFrom($path) { if (PEAR::isError($error = $this->_put('SAML', "FROM:<$path>"))) { return $error; } if (PEAR::isError($error = $this->_parseResponse(250))) { return $error; } return true; } /** * Backwards-compatibility wrapper for samlFrom(). * * @param string The reverse path to send. * * @return mixed Returns a PEAR_Error with an error message on any * kind of failure, or true on success. * * @access public * @since 1.0 * @deprecated 1.2.6 */ function saml_from($path) { return samlFrom($path); } /** * Send the RSET command. * * @return mixed Returns a PEAR_Error with an error message on any * kind of failure, or true on success. * @access public * @since 1.0 */ function rset() { if (PEAR::isError($error = $this->_put('RSET'))) { return $error; } if (PEAR::isError($error = $this->_parseResponse(250))) { return $error; } return true; } /** * Send the VRFY command. * * @param string The string to verify * * @return mixed Returns a PEAR_Error with an error message on any * kind of failure, or true on success. * @access public * @since 1.0 */ function vrfy($string) { /* Note: 251 is also a valid response code */ if (PEAR::isError($error = $this->_put('VRFY', $string))) { return $error; } if (PEAR::isError($error = $this->_parseResponse(array(250, 252)))) { return $error; } return true; } /** * Send the NOOP command. * * @return mixed Returns a PEAR_Error with an error message on any * kind of failure, or true on success. * @access public * @since 1.0 */ function noop() { if (PEAR::isError($error = $this->_put('NOOP'))) { return $error; } if (PEAR::isError($error = $this->_parseResponse(250))) { return $error; } return true; } /** * Backwards-compatibility method. identifySender()'s functionality is * now handled internally. * * @return boolean This method always return true. * * @access public * @since 1.0 */ function identifySender() { return true; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -