Permalink
Browse files

Corrected a problem with SMTP servers that don't support the SIZE fea…

…ture.

Bug: 17942
  • Loading branch information...
1 parent f8c7715 commit b4e251123482e1c8bf0a7ce257b76a42f7464907 @jparise jparise committed Oct 20, 2010
Showing with 22 additions and 25 deletions.
  1. +21 −23 SMTP.php
  2. +1 −2 package.xml
View
@@ -919,31 +919,29 @@ function data($data, $headers = null)
return PEAR::raiseError('Expected a string or file resource');
}
- /* 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)) {
- /* Start by considering the size of the optional headers string.
- * We also account for the addition 4 character "\r\n\r\n"
- * separator sequence. */
- $size = (is_null($headers)) ? 0 : strlen($headers) + 4;
-
- if (is_resource($data)) {
- $stat = fstat($data);
- if ($stat === false) {
- return PEAR::raiseError('Failed to get file size');
- }
- $size += $stat['size'];
- } else {
- $size += strlen($data);
- }
+ /* Start by considering the size of the optional headers string. We
+ * also account for the addition 4 character "\r\n\r\n" separator
+ * sequence. */
+ $size = (is_null($headers)) ? 0 : strlen($headers) + 4;
- if ($size >= $this->_esmtp['SIZE']) {
- $this->disconnect();
- return PEAR::raiseError('Message size exceeds server limit');
+ if (is_resource($data)) {
+ $stat = fstat($data);
+ if ($stat === false) {
+ return PEAR::raiseError('Failed to get file size');
}
+ $size += $stat['size'];
+ } else {
+ $size += strlen($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". */
+ $limit = (isset($this->_esmtp['SIZE'])) ? $this->_esmtp['SIZE'] : 0;
+ if ($limit > 0 && $size >= $limit) {
+ $this->disconnect();
+ return PEAR::raiseError('Message size exceeds server limit');
}
/* Initiate the DATA command. */
View
@@ -30,8 +30,7 @@
<api>stable</api>
</stability>
<license uri="http://www.php.net/license/3_01.txt">PHP License</license>
- <notes>- Reduce peak memory usage when sending large files. (Request 17887)
-- Adding support for proxy authentication. (Request 17358)
+ <notes>Corrected a problem with SMTP servers that don't support the SIZE feature. (Bug 17942)
</notes>
<contents>
<dir baseinstalldir="Net" name="/">

0 comments on commit b4e2511

Please sign in to comment.