Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Fix emails that contain lines that start with periods #5422

Closed
wants to merge 2 commits into from
Closed

Fix emails that contain lines that start with periods #5422

wants to merge 2 commits into from

Conversation

wccoder
Copy link

@wccoder wccoder commented Nov 5, 2013

This pull request contains a unit test (which fails under the current master) and patch for the following problem:

When sending an email via SMTP that has a line in the message body that starts with a period character ("."), the message body gets chopped off at that line and the remote SMTP server closes the connection.

Although escaping code exists in Zend\Mail\Protocol\Smtp's data() method, it doesn't work since it splits the string on "\r\n" but the MimeMessage class uses "\n" for newlines.

Lines 285-291 of Mail/Protocol/Smtp.php:

foreach (explode(self::EOL, $data) as $line) {
    if (strpos($line, '.') === 0) {
        // Escape lines prefixed with a '.'
        $line = '.' . $line;
    }
    $this->_send($line);

}

https://github.com/zendframework/zf2/blob/master/library/Zend/Mail/Protocol/Smtp.php#L285-L290

Since $data is delimited on "\n" the period escaping never happens, so the message ends prematurely.

weierophinney added a commit that referenced this pull request Nov 6, 2013
Fix emails that contain lines that start with periods
weierophinney added a commit that referenced this pull request Nov 6, 2013
@ghost ghost assigned weierophinney Nov 6, 2013
weierophinney added a commit to zendframework/zend-mail that referenced this pull request May 14, 2015
Fix emails that contain lines that start with periods
weierophinney added a commit to zendframework/zend-mail that referenced this pull request May 14, 2015
weierophinney added a commit to zendframework/zend-mail that referenced this pull request May 14, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants