diff --git a/examples/dotmail b/examples/dotmail new file mode 100644 index 0000000..46d72d4 --- /dev/null +++ b/examples/dotmail @@ -0,0 +1,14 @@ +To: Blah +From: Me +Subject: Whatever +Content-Type: text/plain + +Plain text mail + +With some dot lines: + +. + +... + +Done. diff --git a/lib/mail_catcher/smtp.rb b/lib/mail_catcher/smtp.rb index eb60231..6088013 100644 --- a/lib/mail_catcher/smtp.rb +++ b/lib/mail_catcher/smtp.rb @@ -34,7 +34,10 @@ class MailCatcher::Smtp < EventMachine::Protocols::SmtpServer def receive_data_chunk(lines) current_message[:source] ||= "" - current_message[:source] += lines.join("\n") + lines.each do |line| + # RFC821 4.5.2 says leading periods should be stripped from the body data. + current_message[:source] << line.sub(/\A\./, "") << "\n" + end true end