Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/Protocol/Smtp.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,18 @@ public function data($data)
rewind($fp);

// max line length is 998 char + \r\n = 1000
while (($line = stream_get_line($fp, 1000, "\n")) !== false) {
// read the line up to PHP_SOCK_CHUNK_SIZE
while (($line = stream_get_line($fp, 0, "\n")) !== false) {
$line = rtrim($line, "\r");
if (isset($line[0]) && $line[0] === '.') {
// Escape lines prefixed with a '.'
$line = '.' . $line;
}
if (strlen($line) > 998) {
// Long lines are "folded" by inserting "<CR><LF><SPACE>"
// https://tools.ietf.org/html/rfc5322#section-2.2.3
$line = substr(chunk_split($line, 998, "\r\n "), 0, -3);
}
$this->_send($line);
}
fclose($fp);
Expand Down