- // 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;
+ if (is_resource($body))
+ {
+ // file handle
+ $data = $body;
+ $text_headers = preg_replace('/[\r\n]+$/', '', $text_headers);
+ } else {
+ // 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);
+ }