{"action":"created","issue":{"url":"https://api.github.com/repos/eventmachine/eventmachine/issues/600","labels_url":"https://api.github.com/repos/eventmachine/eventmachine/issues/600/labels{/name}","comments_url":"https://api.github.com/repos/eventmachine/eventmachine/issues/600/comments","events_url":"https://api.github.com/repos/eventmachine/eventmachine/issues/600/events","html_url":"https://github.com/eventmachine/eventmachine/pull/600","id":87043074,"number":600,"title":"SmtpClient: Properly escape leading periods in DATA","user":{"login":"davidbalbert","id":123350,"avatar_url":"https://avatars.githubusercontent.com/u/123350?v=3","gravatar_id":"","url":"https://api.github.com/users/davidbalbert","html_url":"https://github.com/davidbalbert","followers_url":"https://api.github.com/users/davidbalbert/followers","following_url":"https://api.github.com/users/davidbalbert/following{/other_user}","gists_url":"https://api.github.com/users/davidbalbert/gists{/gist_id}","starred_url":"https://api.github.com/users/davidbalbert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidbalbert/subscriptions","organizations_url":"https://api.github.com/users/davidbalbert/orgs","repos_url":"https://api.github.com/users/davidbalbert/repos","events_url":"https://api.github.com/users/davidbalbert/events{/privacy}","received_events_url":"https://api.github.com/users/davidbalbert/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"sodabrew","id":39406,"avatar_url":"https://avatars.githubusercontent.com/u/39406?v=3","gravatar_id":"","url":"https://api.github.com/users/sodabrew","html_url":"https://github.com/sodabrew","followers_url":"https://api.github.com/users/sodabrew/followers","following_url":"https://api.github.com/users/sodabrew/following{/other_user}","gists_url":"https://api.github.com/users/sodabrew/gists{/gist_id}","starred_url":"https://api.github.com/users/sodabrew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sodabrew/subscriptions","organizations_url":"https://api.github.com/users/sodabrew/orgs","repos_url":"https://api.github.com/users/sodabrew/repos","events_url":"https://api.github.com/users/sodabrew/events{/privacy}","received_events_url":"https://api.github.com/users/sodabrew/received_events","type":"User","site_admin":false},"milestone":null,"comments":9,"created_at":"2015-06-10T17:19:37Z","updated_at":"2015-06-18T18:57:15Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/eventmachine/eventmachine/pulls/600","html_url":"https://github.com/eventmachine/eventmachine/pull/600","diff_url":"https://github.com/eventmachine/eventmachine/pull/600.diff","patch_url":"https://github.com/eventmachine/eventmachine/pull/600.patch"},"body":"The DATA command of the SMTP protocol is terminated by a `\\r\\n.\\r\\n`. In order to allow for lines starting with a period or containing only a period, the protocol defines an escape mechanism. From [Section 4.5.2 of RFC5321](https://tools.ietf.org/html/rfc5321#section-4.5.2):\r\n\r\n> Before sending a line of mail text, the SMTP client checks the first character of the line.  If it is a period, one additional period is inserted at the beginning of the line.\r\n\r\n`EM::Protocols::SmtpClient` currently doesn't do this, and messages that contain the string `\\r\\n.\\r\\n` somewhere in the body will be truncated by SMTP servers. This is something we have encountered in the wild.\r\n\r\nThis PR does a few things:\r\n\r\n1. Add `:message` as an additional option to SMTP client. This accepts a string that is a valid RFC2822 Internet Message. When using this option, `SmtpClient` will escape leading periods and add a trailing `\\r\\n.\\r\\n`.\r\n\r\n2. Escape leading periods in `@args[:headers]` and `@args[:body]`. `@args[:content]` is not escaped because it expects data already in the proper format.\r\n\r\n3. Update documentation:\r\n  - Add documentation for `:message`\r\n  - Remove documentation for `:content` being specified as an array, which isn't currently supported.\r\n  - Specify that `:content` must included escaped leading periods in addition to a trailing `\\r\\n.\\r\\n`.\r\n  - Replace MailFactory example with Mail example.\r\n  - Remove outdated todo.\r\n"},"comment":{"url":"https://api.github.com/repos/eventmachine/eventmachine/issues/comments/113257677","html_url":"https://github.com/eventmachine/eventmachine/pull/600#issuecomment-113257677","issue_url":"https://api.github.com/repos/eventmachine/eventmachine/issues/600","id":113257677,"user":{"login":"sodabrew","id":39406,"avatar_url":"https://avatars.githubusercontent.com/u/39406?v=3","gravatar_id":"","url":"https://api.github.com/users/sodabrew","html_url":"https://github.com/sodabrew","followers_url":"https://api.github.com/users/sodabrew/followers","following_url":"https://api.github.com/users/sodabrew/following{/other_user}","gists_url":"https://api.github.com/users/sodabrew/gists{/gist_id}","starred_url":"https://api.github.com/users/sodabrew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sodabrew/subscriptions","organizations_url":"https://api.github.com/users/sodabrew/orgs","repos_url":"https://api.github.com/users/sodabrew/repos","events_url":"https://api.github.com/users/sodabrew/events{/privacy}","received_events_url":"https://api.github.com/users/sodabrew/received_events","type":"User","site_admin":false},"created_at":"2015-06-18T18:57:15Z","updated_at":"2015-06-18T18:57:15Z","body":"Ok, I get it now. Thanks for clarifying and pointing me in the right direction at the diff."}}