summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-08-19 18:00:13 -0700
committerDouwe Maan <douwe@gitlab.com>2015-08-19 18:00:13 -0700
commit83081f167397c6c325a4f8c604191e766b2c3d3b (patch)
treeda06920b4cb257a24f74429088bfd0474c7efaa1 /spec
parent19a049ece9e350623e3adb141298c00344cab02d (diff)
downloadgitlab-ce-83081f167397c6c325a4f8c604191e766b2c3d3b.tar.gz
Start on tests.
Diffstat (limited to 'spec')
-rw-r--r--spec/fixtures/emails/android_gmail.eml177
-rw-r--r--spec/fixtures/emails/attachment.eml351
-rw-r--r--spec/fixtures/emails/auto_reply.eml21
-rw-r--r--spec/fixtures/emails/big5.eml26
-rw-r--r--spec/fixtures/emails/bottom_reply.eml160
-rw-r--r--spec/fixtures/emails/boundary.eml61
-rw-r--r--spec/fixtures/emails/dutch.eml20
-rw-r--r--spec/fixtures/emails/empty.eml21
-rw-r--r--spec/fixtures/emails/gmail_web.eml181
-rw-r--r--spec/fixtures/emails/hebrew.eml17
-rw-r--r--spec/fixtures/emails/html_only.eml93
-rw-r--r--spec/fixtures/emails/html_paragraphs.eml205
-rw-r--r--spec/fixtures/emails/inline_reply.eml60
-rw-r--r--spec/fixtures/emails/ios_default.eml136
-rw-r--r--spec/fixtures/emails/iphone_signature.eml29
-rw-r--r--spec/fixtures/emails/multiple_destinations.eml40
-rw-r--r--spec/fixtures/emails/newlines.eml84
-rw-r--r--spec/fixtures/emails/no_content_reply.eml34
-rw-r--r--spec/fixtures/emails/on_wrote.eml277
-rw-r--r--spec/fixtures/emails/outlook.eml188
-rw-r--r--spec/fixtures/emails/paragraphs.cooked7
-rw-r--r--spec/fixtures/emails/paragraphs.eml42
-rw-r--r--spec/fixtures/emails/previous.eml38
-rw-r--r--spec/fixtures/emails/previous_replies.eml180
-rw-r--r--spec/fixtures/emails/too_many_mentions.eml31
-rw-r--r--spec/fixtures/emails/too_short.eml21
-rw-r--r--spec/fixtures/emails/valid_incoming.cooked5
-rw-r--r--spec/fixtures/emails/valid_incoming.eml25
-rw-r--r--spec/fixtures/emails/valid_reply.cooked4
-rw-r--r--spec/fixtures/emails/valid_reply.eml40
-rw-r--r--spec/fixtures/emails/via_line.eml25
-rw-r--r--spec/fixtures/emails/windows_8_metro.eml173
-rw-r--r--spec/fixtures/emails/wrong_reply_key.eml40
-rw-r--r--spec/lib/gitlab/email_receiver_spec.rb481
34 files changed, 3293 insertions, 0 deletions
diff --git a/spec/fixtures/emails/android_gmail.eml b/spec/fixtures/emails/android_gmail.eml
new file mode 100644
index 00000000000..21c5dde2346
--- /dev/null
+++ b/spec/fixtures/emails/android_gmail.eml
@@ -0,0 +1,177 @@
+Delivered-To: reply@discourse.org
+Return-Path: <walter.white@googlemail.com>
+MIME-Version: 1.0
+In-Reply-To: <topic/22638/86406@meta.discourse.org>
+References: <topic/22638@meta.discourse.org>
+ <topic/22638/86406@meta.discourse.org>
+Date: Fri, 28 Nov 2014 12:53:21 -0800
+Subject: Re: [Discourse Meta] [Lounge] Testing default email replies
+From: Walter White <walter.white@googlemail.com>
+To: Discourse Meta <reply@discourse.org>
+Content-Type: multipart/alternative; boundary=089e0149cfa485c6630508f173df
+
+--089e0149cfa485c6630508f173df
+Content-Type: text/plain; charset=UTF-8
+
+### this is a reply from Android 5 gmail
+
+The quick brown fox jumps over the lazy dog. The quick brown fox jumps over
+the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown
+fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog.
+
+This is **bold** in Markdown.
+
+This is a link to http://example.com
+On Nov 28, 2014 12:36 PM, "Arpit Jalan" <info@discourse.org> wrote:
+
+> techAPJ <https://meta.discourse.org/users/techapj>
+> November 28
+>
+> Test reply.
+>
+> First paragraph.
+>
+> Second paragraph.
+>
+> To respond, reply to this email or visit
+> https://meta.discourse.org/t/testing-default-email-replies/22638/3 in
+> your browser.
+> ------------------------------
+> Previous Replies codinghorror
+> <https://meta.discourse.org/users/codinghorror>
+> November 28
+>
+> We're testing the latest GitHub email processing library which we are
+> integrating now.
+>
+> https://github.com/github/email_reply_parser
+>
+> Go ahead and reply to this topic and I'll reply from various email clients
+> for testing.
+> ------------------------------
+>
+> To respond, reply to this email or visit
+> https://meta.discourse.org/t/testing-default-email-replies/22638/3 in
+> your browser.
+>
+> To unsubscribe from these emails, visit your user preferences
+> <https://meta.discourse.org/my/preferences>.
+>
+
+--089e0149cfa485c6630508f173df
+Content-Type: text/html; charset=UTF-8
+Content-Transfer-Encoding: quoted-printable
+
+<p dir=3D"ltr">### this is a reply from Android 5 gmail</p>
+<p dir=3D"ltr">The quick brown fox jumps over the lazy dog. The quick brown=
+ fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. =
+The quick brown fox jumps over the lazy dog. The quick brown fox jumps over=
+ the lazy dog. The quick brown fox jumps over the lazy dog. </p>
+<p dir=3D"ltr">This is **bold** in Markdown.</p>
+<p dir=3D"ltr">This is a link to <a href=3D"http://example.com">http://exam=
+ple.com</a></p>
+<div class=3D"gmail_quote">On Nov 28, 2014 12:36 PM, &quot;Arpit Jalan&quot=
+; &lt;<a href=3D"mailto:info@discourse.org">info@discourse.org</a>&gt; wrot=
+e:<br type=3D"attribution"><blockquote class=3D"gmail_quote" style=3D"margi=
+n:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
+
+<table style=3D"margin-bottom:25px" cellspacing=3D"0" cellpadding=3D"0" bor=
+der=3D"0">
+ <tbody>
+ <tr>
+ <td style=3D"vertical-align:top;width:55px">
+ <img src=3D"https://meta-discourse.global.ssl.fastly.net/user_avata=
+r/meta.discourse.org/techapj/45/3281.png" title=3D"techAPJ" style=3D"max-wi=
+dth:100%" width=3D"45" height=3D"45">
+ </td>
+ <td>
+ <a href=3D"https://meta.discourse.org/users/techapj" style=3D"text-=
+decoration:none;font-weight:bold;color:#006699;font-size:13px;font-family:&=
+#39;lucida grande&#39;,tahoma,verdana,arial,sans-serif;color:#3b5998;text-d=
+ecoration:none;font-weight:bold" target=3D"_blank">techAPJ</a><br>
+ <span style=3D"text-align:right;color:#999999;padding-right:5px;fon=
+t-family:&#39;lucida grande&#39;,tahoma,verdana,arial,sans-serif;font-size:=
+11px">November 28</span>
+ </td>
+ </tr>
+ <tr>
+ <td style=3D"padding-top:5px" colspan=3D"2">
+<p style=3D"margin-top:0;border:0">Test reply.</p>
+
+<p style=3D"margin-top:0;border:0">First paragraph.</p>
+
+<p style=3D"margin-top:0;border:0">Second paragraph.</p>
+</td>
+ </tr>
+ </tbody>
+</table>
+
+
+ <div style=3D"color:#666">
+ <p>To respond, reply to this email or visit <a href=3D"https://meta.dis=
+course.org/t/testing-default-email-replies/22638/3" style=3D"text-decoratio=
+n:none;font-weight:bold;color:#006699;color:#666" target=3D"_blank">https:/=
+/meta.discourse.org/t/testing-default-email-replies/22638/3</a> in your bro=
+wser.</p>
+ </div>
+ <hr style=3D"background-color:#ddd;min-height:1px;border:1px;background-c=
+olor:#ddd;min-height:1px;border:1px">
+ <h4>Previous Replies</h4>
+
+ <table style=3D"margin-bottom:25px" cellspacing=3D"0" cellpadding=3D"0" b=
+order=3D"0">
+ <tbody>
+ <tr>
+ <td style=3D"vertical-align:top;width:55px">
+ <img src=3D"https://meta-discourse.global.ssl.fastly.net/user_avata=
+r/meta.discourse.org/codinghorror/45/5297.png" title=3D"codinghorror" style=
+=3D"max-width:100%" width=3D"45" height=3D"45">
+ </td>
+ <td>
+ <a href=3D"https://meta.discourse.org/users/codinghorror" style=3D"=
+text-decoration:none;font-weight:bold;color:#006699;font-size:13px;font-fam=
+ily:&#39;lucida grande&#39;,tahoma,verdana,arial,sans-serif;color:#3b5998;t=
+ext-decoration:none;font-weight:bold" target=3D"_blank">codinghorror</a><br=
+>
+ <span style=3D"text-align:right;color:#999999;padding-right:5px;fon=
+t-family:&#39;lucida grande&#39;,tahoma,verdana,arial,sans-serif;font-size:=
+11px">November 28</span>
+ </td>
+ </tr>
+ <tr>
+ <td style=3D"padding-top:5px" colspan=3D"2">
+<p style=3D"margin-top:0;border:0">We&#39;re testing the latest GitHub emai=
+l processing library which we are integrating now.</p>
+
+<p style=3D"margin-top:0;border:0"><a href=3D"https://github.com/github/ema=
+il_reply_parser" style=3D"text-decoration:none;font-weight:bold;color:#0066=
+99" target=3D"_blank">https://github.com/github/email_reply_parser</a></p>
+
+<p style=3D"margin-top:0;border:0">Go ahead and reply to this topic and I&#=
+39;ll reply from various email clients for testing.</p>
+</td>
+ </tr>
+ </tbody>
+</table>
+
+
+<hr style=3D"background-color:#ddd;min-height:1px;border:1px;background-col=
+or:#ddd;min-height:1px;border:1px">
+
+<div style=3D"color:#666">
+<p>To respond, reply to this email or visit <a href=3D"https://meta.discour=
+se.org/t/testing-default-email-replies/22638/3" style=3D"text-decoration:no=
+ne;font-weight:bold;color:#006699;color:#666" target=3D"_blank">https://met=
+a.discourse.org/t/testing-default-email-replies/22638/3</a> in your browser=
+.</p>
+</div>
+<div style=3D"color:#666">
+<p>To unsubscribe from these emails, visit your <a href=3D"https://meta.dis=
+course.org/my/preferences" style=3D"text-decoration:none;font-weight:bold;c=
+olor:#006699;color:#666" target=3D"_blank">user preferences</a>.</p>
+</div>
+</div>
+</blockquote></div>
+
+--089e0149cfa485c6630508f173df--
diff --git a/spec/fixtures/emails/attachment.eml b/spec/fixtures/emails/attachment.eml
new file mode 100644
index 00000000000..f25c3d1a449
--- /dev/null
+++ b/spec/fixtures/emails/attachment.eml
@@ -0,0 +1,351 @@
+Message-ID: <51C22E52.1030509@darthvader.ca>
+Date: Wed, 19 Jun 2013 18:18:58 -0400
+From: Anakin Skywalker <FROM>
+User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6
+MIME-Version: 1.0
+To: Han Solo via Death Star <TO>
+Subject: Re: [Death Star] [PM] re: Regarding your post in "Site Customization
+ not working"
+References: <51d23d33f41fb_5f4e4b35d7d60798@xwing.mail>
+In-Reply-To: <51d23d33f41fb_5f4e4b35d7d60798@xwing.mail>
+Content-Type: multipart/mixed; boundary=047d7b45041e19c68004eb9f3de8
+
+--047d7b45041e19c68004eb9f3de8
+Content-Type: multipart/alternative; boundary=047d7b45041e19c67b04eb9f3de6
+
+--047d7b45041e19c67b04eb9f3de6
+Content-Type: text/plain; charset=ISO-8859-1
+
+here is an image attachment
+
+
+On Tue, Nov 19, 2013 at 5:11 PM, Neil <info@discourse.org> wrote:
+
+> Neil <http://meta.discourse.org/users/neil>
+> November 19
+>
+> Actually, deleting a spammer does what it's supposed to. It does mark the
+> topic as deleted.
+>
+> That topic has id 11002, and you're right that the user was deleted.
+>
+> @eviltrout <http://users/eviltrout> Any idea why it showed up in
+> suggested topics?
+>
+> To respond, reply to this email or visit
+> http://meta.discourse.org/t/spam-post-pops-back-up-in-suggested-topics/11005/5in your browser.
+> ------------------------------
+> Previous Replies Neil <http://meta.discourse.org/users/neil>
+> November 19
+>
+> Looks like a bug when deleting a spammer. I'll look at it.
+> riking <http://meta.discourse.org/users/riking>
+> November 19
+>
+> codinghorror:
+>
+> I can't even find that topic by name.
+>
+> In that case, I'm fairly certain someone used the 'Delete Spammer'
+> function on the user, which would explain your inability to find it - it's
+> gone.
+>
+> I'm raising this because, well, it's gone and shouldn't be showing up. And
+> even if it was hanging around, it should be invisible to me, and not
+> showing up in Suggested Topics.
+> codinghorror <http://meta.discourse.org/users/codinghorror>
+> November 19
+>
+> Hmm, that's interesting -- can you have a look @eviltrout<http://users/eviltrout>?
+> I can't even find that topic by name.
+> riking <http://meta.discourse.org/users/riking>
+> November 19
+>
+> I'm one of the users who flagged this particular spam post, and it was
+> promptly deleted/hidden, but it just popped up in the Suggested Topics box:
+>
+> Pasted image1125x220 27.7 KB
+> <//cdn.discourse.org/uploads/meta_discourse/2158/50b8b49557cb249e.png>
+>
+> We may want to recheck the suppression on these.
+> ------------------------------
+>
+> To respond, reply to this email or visit
+> http://meta.discourse.org/t/spam-post-pops-back-up-in-suggested-topics/11005/5in your browser.
+>
+> To unsubscribe from these emails, visit your user preferences<http://meta.discourse.org/user_preferences>
+> .
+>
+
+--047d7b45041e19c67b04eb9f3de6
+Content-Type: text/html; charset=ISO-8859-1
+Content-Transfer-Encoding: quoted-printable
+
+<div dir=3D"ltr">here is an image attachment</div><div class=3D"gmail_extra=
+"><br><br><div class=3D"gmail_quote">On Tue, Nov 19, 2013 at 5:11 PM, Neil =
+<span dir=3D"ltr">&lt;<a href=3D"mailto:info@discourse.org" target=3D"_blan=
+k">info@discourse.org</a>&gt;</span> wrote:<br>
+<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
+x #ccc solid;padding-left:1ex"><div>
+<table style=3D"margin-bottom:25px;max-width:761px" cellspacing=3D"0" cellp=
+adding=3D"0" border=3D"0"><tbody>
+<tr>
+<td style=3D"vertical-align:top;width:55px">
+ <img src=3D"http://www.gravatar.com/avatar/42776c4982dff1fa45ee8248=
+532f8ad0.png?s=3D45&amp;r=3Dpg&amp;d=3Didenticon" title=3D"Neil" style=3D"m=
+ax-width:694px" width=3D"45" height=3D"45">
+</td>
+ <td>
+ <a href=3D"http://meta.discourse.org/users/neil" style=3D"font-size=
+:13px;font-family:&#39;lucida grande&#39;,tahoma,verdana,arial,sans-serif;c=
+olor:#3b5998;text-decoration:none;font-weight:bold" target=3D"_blank">Neil<=
+/a><br>
+<span style=3D"text-align:right;color:#999999;padding-right:5px;font-family=
+:&#39;lucida grande&#39;,tahoma,verdana,arial,sans-serif;font-size:11px">No=
+vember 19</span>
+ </td>
+ </tr>
+<tr>
+<td style=3D"padding-top:5px" colspan=3D"2">
+<p style=3D"margin-top:0">Actually, deleting a spammer does what it&#39;s s=
+upposed to. It does mark the topic as deleted.</p>
+
+<p style=3D"margin-top:0">That topic has id 11002, and you&#39;re right tha=
+t the user was deleted.</p>
+
+<p style=3D"margin-top:0"><a href=3D"http://users/eviltrout" target=3D"_bla=
+nk">@eviltrout</a> Any idea why it showed up in suggested topics? </p>
+</td>
+ </tr>
+</tbody></table>
+<div style=3D"color:#666">
+ <p>To respond, reply to this email or visit <a href=3D"http://meta.disc=
+ourse.org/t/spam-post-pops-back-up-in-suggested-topics/11005/5" style=3D"co=
+lor:#666" target=3D"_blank">http://meta.discourse.org/t/spam-post-pops-back=
+-up-in-suggested-topics/11005/5</a> in your browser.</p>
+
+ </div>
+ <hr style=3D"background-color:#ddd;min-height:1px;border:1px">
+<h4>Previous Replies</h4>
+
+ <table style=3D"margin-bottom:25px;max-width:761px" cellspacing=3D"0" cel=
+lpadding=3D"0" border=3D"0"><tbody>
+<tr>
+<td style=3D"vertical-align:top;width:55px">
+ <img src=3D"http://www.gravatar.com/avatar/42776c4982dff1fa45ee8248=
+532f8ad0.png?s=3D45&amp;r=3Dpg&amp;d=3Didenticon" title=3D"Neil" style=3D"m=
+ax-width:694px" width=3D"45" height=3D"45">
+</td>
+ <td>
+ <a href=3D"http://meta.discourse.org/users/neil" style=3D"font-size=
+:13px;font-family:&#39;lucida grande&#39;,tahoma,verdana,arial,sans-serif;c=
+olor:#3b5998;text-decoration:none;font-weight:bold" target=3D"_blank">Neil<=
+/a><br>
+<span style=3D"text-align:right;color:#999999;padding-right:5px;font-family=
+:&#39;lucida grande&#39;,tahoma,verdana,arial,sans-serif;font-size:11px">No=
+vember 19</span>
+ </td>
+ </tr>
+<tr>
+<td style=3D"padding-top:5px" colspan=3D"2"><p style=3D"margin-top:0">Looks=
+ like a bug when deleting a spammer. I&#39;ll look at it.</p></td>
+ </tr>
+</tbody></table>
+<table style=3D"margin-bottom:25px;max-width:761px" cellspacing=3D"0" cellp=
+adding=3D"0" border=3D"0"><tbody>
+<tr>
+<td style=3D"vertical-align:top;width:55px">
+ <img src=3D"http://www.gravatar.com/avatar/5120fc4e345db0d1a9648882=
+72073819.png?s=3D45&amp;r=3Dpg&amp;d=3Didenticon" title=3D"riking" style=3D=
+"max-width:694px" width=3D"45" height=3D"45">
+</td>
+ <td>
+ <a href=3D"http://meta.discourse.org/users/riking" style=3D"font-si=
+ze:13px;font-family:&#39;lucida grande&#39;,tahoma,verdana,arial,sans-serif=
+;color:#3b5998;text-decoration:none;font-weight:bold" target=3D"_blank">rik=
+ing</a><br>
+<span style=3D"text-align:right;color:#999999;padding-right:5px;font-family=
+:&#39;lucida grande&#39;,tahoma,verdana,arial,sans-serif;font-size:11px">No=
+vember 19</span>
+ </td>
+ </tr>
+<tr>
+<td style=3D"padding-top:5px" colspan=3D"2">
+<p style=3D"margin-top:0"><u></u></p><div>
+<div></div>
+<img width=3D"20" height=3D"20" src=3D"http://www.gravatar.com/avatar/51d62=
+3f33f8b83095db84ff35e15dbe8.png?s=3D40&amp;r=3Dpg&amp;d=3Didenticon" style=
+=3D"max-width:694px">codinghorror:</div>
+<blockquote><p style=3D"margin-top:0">I can&#39;t even find that topic by n=
+ame.</p></blockquote><u></u><p></p>
+
+<p style=3D"margin-top:0">In that case, I&#39;m fairly certain someone used=
+ the &#39;Delete Spammer&#39; function on the user, which would explain you=
+r inability to find it - it&#39;s gone.</p>
+
+<p style=3D"margin-top:0">I&#39;m raising this because, well, it&#39;s gone=
+ and shouldn&#39;t be showing up. And even if it was hanging around, it sho=
+uld be invisible to me, and not showing up in Suggested Topics.</p>
+</td>
+ </tr>
+</tbody></table>
+<table style=3D"margin-bottom:25px;max-width:761px" cellspacing=3D"0" cellp=
+adding=3D"0" border=3D"0"><tbody>
+<tr>
+<td style=3D"vertical-align:top;width:55px">
+ <img src=3D"http://www.gravatar.com/avatar/51d623f33f8b83095db84ff3=
+5e15dbe8.png?s=3D45&amp;r=3Dpg&amp;d=3Didenticon" title=3D"codinghorror" st=
+yle=3D"max-width:694px" width=3D"45" height=3D"45">
+</td>
+ <td>
+ <a href=3D"http://meta.discourse.org/users/codinghorror" style=3D"f=
+ont-size:13px;font-family:&#39;lucida grande&#39;,tahoma,verdana,arial,sans=
+-serif;color:#3b5998;text-decoration:none;font-weight:bold" target=3D"_blan=
+k">codinghorror</a><br>
+<span style=3D"text-align:right;color:#999999;padding-right:5px;font-family=
+:&#39;lucida grande&#39;,tahoma,verdana,arial,sans-serif;font-size:11px">No=
+vember 19</span>
+ </td>
+ </tr>
+<tr>
+<td style=3D"padding-top:5px" colspan=3D"2"><p style=3D"margin-top:0">Hmm, =
+that&#39;s interesting -- can you have a look <a href=3D"http://users/evilt=
+rout" target=3D"_blank">@eviltrout</a>? I can&#39;t even find that topic by=
+ name. </p>
+</td>
+ </tr>
+</tbody></table>
+<table style=3D"margin-bottom:25px;max-width:761px" cellspacing=3D"0" cellp=
+adding=3D"0" border=3D"0"><tbody>
+<tr>
+<td style=3D"vertical-align:top;width:55px">
+ <img src=3D"http://www.gravatar.com/avatar/5120fc4e345db0d1a9648882=
+72073819.png?s=3D45&amp;r=3Dpg&amp;d=3Didenticon" title=3D"riking" style=3D=
+"max-width:694px" width=3D"45" height=3D"45">
+</td>
+ <td>
+ <a href=3D"http://meta.discourse.org/users/riking" style=3D"font-si=
+ze:13px;font-family:&#39;lucida grande&#39;,tahoma,verdana,arial,sans-serif=
+;color:#3b5998;text-decoration:none;font-weight:bold" target=3D"_blank">rik=
+ing</a><br>
+<span style=3D"text-align:right;color:#999999;padding-right:5px;font-family=
+:&#39;lucida grande&#39;,tahoma,verdana,arial,sans-serif;font-size:11px">No=
+vember 19</span>
+ </td>
+ </tr>
+<tr>
+<td style=3D"padding-top:5px" colspan=3D"2">
+<p style=3D"margin-top:0">I&#39;m one of the users who flagged this particu=
+lar spam post, and it was promptly deleted/hidden, but it just popped up in=
+ the Suggested Topics box:</p>
+
+<p style=3D"margin-top:0"></p>
+<div><a href=3D"//cdn.discourse.org/uploads/meta_discourse/2158/50b8b49557c=
+b249e.png" target=3D"_blank"><img src=3D"http://cdn.discourse.org/uploads/m=
+eta_discourse/_optimized/ab1/c92/acd2c33402_584x134.png" width=3D"584" heig=
+ht=3D"134" style=3D"max-width:694px"><div>
+
+<span>Pasted image</span><span>1125x220 27.7 KB</span><span></span>
+</div></a></div>
+
+<p style=3D"margin-top:0">We may want to recheck the suppression on these.<=
+/p>
+</td>
+ </tr>
+</tbody></table>
+<hr style=3D"background-color:#ddd;min-height:1px;border:1px">
+<div style=3D"color:#666">
+<p>To respond, reply to this email or visit <a href=3D"http://meta.discours=
+e.org/t/spam-post-pops-back-up-in-suggested-topics/11005/5" style=3D"color:=
+#666" target=3D"_blank">http://meta.discourse.org/t/spam-post-pops-back-up-=
+in-suggested-topics/11005/5</a> in your browser.</p>
+
+</div>
+<div style=3D"color:#666">
+<p>To unsubscribe from these emails, visit your <a href=3D"http://meta.disc=
+ourse.org/user_preferences" style=3D"color:#666" target=3D"_blank">user pre=
+ferences</a>.</p>
+</div>
+</div></blockquote></div><br></div>
+
+--047d7b45041e19c67b04eb9f3de6--
+--047d7b45041e19c68004eb9f3de8
+Content-Type: image/png; name="bricks.png"
+Content-Disposition: attachment; filename="bricks.png"
+Content-Transfer-Encoding: base64
+X-Attachment-Id: f_ho8uteve0
+
+iVBORw0KGgoAAAANSUhEUgAAASEAAAB+CAIAAADk0DDaAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJ
+bWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdp
+bj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6
+eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEz
+NDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJo
+dHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlw
+dGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAv
+IiB4b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qn3r/5DsqRtJNqWLHYX8fFtSXYVjJDsNoykJWIkFwlVZBg2+dhK59CP
+VJbtmDEhjWsW8fs2/HoAcx3z/gvX9/dIUj6XLYLiDNuOWJI5DE+qB3BINp8Skme3CRNiRQAQjxWV
+46A77jwFi0QCJPc1XjD45kv/fbT8Cx+p3a8Z7sEmmQiLZXjoQrzQug0gGTUPABDUsZwYt8gMJrub
+06iXjTtXP/UayiLcLkeydvtmcJo/swH2+JkM55BMJvsw51KVJTnOcDcwzX8Sw6rMGPkYAIjomOsP
+MudT5/ycOA/+jFX3hmmRNkf8Mfn06eEpz/cijQm5/+DPhUkmDE+aS2Xv+xdpc5zhU3QdUgG3JA8x
+rMqMMZcKAATzseboncfB0dp/XL151//0j3/W7uHc2WNfwQq624Igt5WUMLzWgf9Jvnjyphsp9CQT
+hn2SM6OGGgxrI9kw/PqlGy/HmG+prRAcXaMjjTDepDtPumOOKeghuY9hgtvicBgGyXGY0WXoRawI
+ABLYOr+jYk6KWVGV1Dy6icvZAqMMu/7VAnvbFzdjN0yAjgHA0mseZukO4lnNv70zMI4BjrZgjOA7
+WqhZcZJde4aOAUDlfOz7r+6SYdd7OPJv51Si3AQp6CD9Hw65TytW/tCPwz9y/FyRb7r/Tu3pEFHx
+/g7pCbOR8SP7Le/DBNI7v+Uckl2VC2YdkQMmXAi/zfGm+t8hJ2U2tdQldr/5nwADACLM1IGrPYuL
+AAAAAElFTkSuQmCC
+--047d7b45041e19c68004eb9f3de8--
diff --git a/spec/fixtures/emails/auto_reply.eml b/spec/fixtures/emails/auto_reply.eml
new file mode 100644
index 00000000000..7999c8d78b7
--- /dev/null
+++ b/spec/fixtures/emails/auto_reply.eml
@@ -0,0 +1,21 @@
+Return-Path: <jake@adventuretime.ooo>
+Received: from iceking.adventuretime.ooo ([unix socket]) by iceking (Cyrus v2.2.13-Debian-2.2.13-19+squeeze3) with LMTPA; Thu, 13 Jun 2013 17:03:50 -0400
+Received: from mail-ie0-x234.google.com (mail-ie0-x234.google.com [IPv6:2607:f8b0:4001:c03::234]) by iceking.adventuretime.ooo (8.14.3/8.14.3/Debian-9.4) with ESMTP id r5DL3nFJ016967 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for <reply+59d8df8370b7e95c5a49fbf86aeb2c93@discourse.example.com>; Thu, 13 Jun 2013 17:03:50 -0400
+Received: by mail-ie0-f180.google.com with SMTP id f4so21977375iea.25 for <reply+59d8df8370b7e95c5a49fbf86aeb2c93@discourse.example.com>; Thu, 13 Jun 2013 14:03:48 -0700
+Received: by 10.0.0.1 with HTTP; Thu, 13 Jun 2013 14:03:48 -0700
+Date: Thu, 13 Jun 2013 17:03:48 -0400
+From: Jake the Dog <jake@adventuretime.ooo>
+To: reply+636ca428858779856c226bb145ef4fad@appmail.adventuretime.ooo
+Message-ID: <CADkmRc+rNGAGGbV2iE5p918UVy4UyJqVcXRO2=otppgzduJSg@mail.gmail.com>
+Subject: re: [Discourse Meta] eviltrout posted in 'Adventure Time Sux'
+Mime-Version: 1.0
+Content-Type: text/plain;
+ charset=ISO-8859-1
+Content-Transfer-Encoding: 7bit
+Auto-Submitted: auto-generated
+X-Sieve: CMU Sieve 2.2
+X-Received: by 10.0.0.1 with SMTP id n7mr11234144ipb.85.1371157428600; Thu,
+ 13 Jun 2013 14:03:48 -0700 (PDT)
+X-Scanned-By: MIMEDefang 2.69 on IPv6:2001:470:1d:165::1
+
+Test reply to Discourse email digest
diff --git a/spec/fixtures/emails/big5.eml b/spec/fixtures/emails/big5.eml
new file mode 100644
index 00000000000..4a7b2082486
--- /dev/null
+++ b/spec/fixtures/emails/big5.eml
@@ -0,0 +1,26 @@
+
+Delivered-To: discourse-reply+cd480e301683c9902891f15968bf07a5@discourse.org
+Received: by 10.194.216.104 with SMTP id op8csp80593wjc;
+ Wed, 24 Jul 2013 07:59:14 -0700 (PDT)
+Return-Path: <walter.white@googlemail.com>
+References: <topic/5043@discourse.org> <51efeb9b36c34_66dc2dfce6811866@discourse.mail>
+From: Walter White <walter.white@googlemail.com>
+In-Reply-To: <51efeb9b36c34_66dc2dfce6811866@discourse.mail>
+Mime-Version: 1.0 (1.0)
+Date: Wed, 24 Jul 2013 15:59:10 +0100
+Message-ID: <4597127794206131679@unknownmsgid>
+Subject: Re: [Discourse] new reply to your post in 'Crystal Blue'
+To: walter via Discourse <reply+cd480e301683c9902891f15968bf07a5@appmail.adventuretime.ooo>
+Content-Type: multipart/alternative; boundary=20cf301cc47ada510404f040b262
+
+--20cf301cc47ada510404f040b262
+Content-Type: text/plain; charset=Big5
+Content-Transfer-Encoding: base64
+
+tv2hSafapFe5cbX4pEahSQ0K
+--20cf301cc47ada510404f040b262
+Content-Type: text/html; charset=Big5
+Content-Transfer-Encoding: base64
+
+PGRpdiBkaXI9Imx0ciI+tv2hSafapFe5cbX4pEahSTxicj48L2Rpdj4NCg==
+--20cf301cc47ada510404f040b262--
diff --git a/spec/fixtures/emails/bottom_reply.eml b/spec/fixtures/emails/bottom_reply.eml
new file mode 100644
index 00000000000..5fc992971fc
--- /dev/null
+++ b/spec/fixtures/emails/bottom_reply.eml
@@ -0,0 +1,160 @@
+Received: by 10.107.19.29 with SMTP id b29csp111716ioj;
+ Wed, 30 Jul 2014 17:52:05 -0700 (PDT)
+X-Received: by 10.194.238.6 with SMTP id vg6mr11340975wjc.24.1406767925330;
+ Wed, 30 Jul 2014 17:52:05 -0700 (PDT)
+Received: from localhost (localhost [127.0.0.1])
+ by bendel.debian.org (Postfix) with QMQP
+ id 18F5C417; Thu, 31 Jul 2014 00:52:04 +0000 (UTC)
+Old-Return-Path: <vorlon@debian.org>
+X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on bendel.debian.org
+X-Spam-Level:
+X-Spam-Status: No, score=-25.9 required=4.0 tests=FOURLA,LDOSUBSCRIBER,
+ LDO_WHITELIST,MURPHY_DEBIAN_MESSAGE,PGPSIGNATURE autolearn=unavailable
+ version=3.3.2
+X-Original-To: lists-debian-ctte@bendel.debian.org
+Delivered-To: lists-debian-ctte@bendel.debian.org
+Received: from localhost (localhost [127.0.0.1])
+ by bendel.debian.org (Postfix) with ESMTP id CE6CDEE
+ for <lists-debian-ctte@bendel.debian.org>; Thu, 31 Jul 2014 00:51:52 +0000 (UTC)
+X-Virus-Scanned: at lists.debian.org with policy bank en-lt
+X-Amavis-Spam-Status: No, score=-11.9 tagged_above=-10000 required=5.3
+ tests=[BAYES_00=-2, FOURLA=0.1, LDO_WHITELIST=-5, PGPSIGNATURE=-5]
+ autolearn=ham
+Received: from bendel.debian.org ([127.0.0.1])
+ by localhost (lists.debian.org [127.0.0.1]) (amavisd-new, port 2525)
+ with ESMTP id SB451DwGZCOe for <lists-debian-ctte@bendel.debian.org>;
+ Thu, 31 Jul 2014 00:51:47 +0000 (UTC)
+X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_BL_NJABL=-1.5 CL_IP_EQ_HELO_IP=-2 (check from: .debian. - helo: .becquer.dodds. - helo-domain: .dodds.) FROM/MX_MATCHES_NOT_HELO(DOMAIN)=0; rate: -5
+Received: from becquer.dodds.net (becquer.dodds.net [207.224.24.209])
+ by bendel.debian.org (Postfix) with ESMTP id 8E89A2B4
+ for <debian-ctte@lists.debian.org>; Thu, 31 Jul 2014 00:51:47 +0000 (UTC)
+Received: from virgil.dodds.net (unknown [192.168.15.59])
+ by becquer.dodds.net (Postfix) with ESMTPA id 9B0A9256EB
+ for <debian-ctte@lists.debian.org>; Wed, 30 Jul 2014 17:51:19 -0700 (PDT)
+Received: by virgil.dodds.net (Postfix, from userid 1000)
+ id 942FB60199; Wed, 30 Jul 2014 17:51:15 -0700 (PDT)
+Date: Wed, 30 Jul 2014 17:51:15 -0700
+From: Jake <jake@adventuretime.ooo>
+To: incoming+amazing@appmail.adventuretime.ooo
+Subject: Re: Next Debian CTTE IRC Meeting at date -d'Thu Jul 31 17:00:00 UTC
+ 2014'
+Message-ID: <20140731005115.GA19044@virgil.dodds.net>
+Mail-Followup-To: debian-ctte@lists.debian.org
+References: <20140730213924.GA12356@teltox.donarmstrong.com>
+MIME-Version: 1.0
+Content-Type: multipart/signed; micalg=pgp-sha256;
+ protocol="application/pgp-signature"; boundary="qMm9M+Fa2AknHoGS"
+Content-Disposition: inline
+In-Reply-To: <20140730213924.GA12356@teltox.donarmstrong.com>
+User-Agent: Mutt/1.5.23 (2014-03-12)
+X-Debian-Message: Signature check passed for Debian member
+X-Rc-Virus: 2007-09-13_01
+X-Rc-Spam: 2008-11-04_01
+Resent-Message-ID: <c_LGA2C2wUK.A.URD.zMZ2TB@bendel>
+Resent-From: debian-ctte@lists.debian.org
+X-Mailing-List: <debian-ctte@lists.debian.org> archive/latest/4791
+X-Loop: debian-ctte@lists.debian.org
+List-Id: <debian-ctte.lists.debian.org>
+List-Post: <mailto:debian-ctte@lists.debian.org>
+List-Help: <mailto:debian-ctte-request@lists.debian.org?subject=help>
+List-Subscribe: <mailto:debian-ctte-request@lists.debian.org?subject=subscribe>
+List-Unsubscribe: <mailto:debian-ctte-request@lists.debian.org?subject=unsubscribe>
+Precedence: list
+Resent-Sender: debian-ctte-request@lists.debian.org
+Resent-Date: Thu, 31 Jul 2014 00:52:04 +0000 (UTC)
+
+
+--qMm9M+Fa2AknHoGS
+Content-Type: text/plain; charset=us-ascii
+Content-Disposition: inline
+Content-Transfer-Encoding: quoted-printable
+
+On Wed, Jul 30, 2014 at 02:39:24PM -0700, Don Armstrong wrote:
+> The next Debian CTTE IRC meeting is at=20
+
+> date -d 'Thu Jul 31 17:00:00 UTC 2014' on irc.debian.org in
+> #debian-ctte.
+
+> The current meeting agenda is here, and more up-to-date ones may be
+> found in the git repository.
+
+> #startmeeting
+
+> #topic Who is here?
+
+> #topic Next Meeting?
+
+> #topic #717076 Decide between libjpeg-turbo and libjpeg8 et al.
+
+This has been voted on; should probably be removed from the agenda, someone
+just needs to confirm the vote results and get it on the website. (AIUI the
+archive has already begun moving on accordingly.)
+
+> #topic #636783 constitution: super-majority bug
+
+> #topic #636783 constitution: casting vote
+
+> #topic #636783 constitution: minimum discussion period
+
+> #topic #636783 constitution: TC member retirement/rollover
+
+> #topic #636783 constitution: TC chair retirement/rollover
+
+> #topic #681419 Depends: foo | foo-nonfree
+
+> #topic #741573 menu systems and mime-support
+
+> #topic #746715 init system fallout
+
+Also voted and just needs to be confirmed.
+
+> #topic #750135 Maintainer of aptitude package
+>=20
+> #topic #752400 Advice on util-linux
+
+This has been closed by mutual agreement of the people involved and doesn't
+require any action from the TC. Removed from the agenda.
+
+There's also bug #744246, which was assigned to the TC at my request but
+without any preamble so it may have escaped notice. However, that situation
+has been evolving constructively among the related parties (apparently, an
+informal comment from a member of the release team was mistaken for a
+release team position, so that's now being revisited), so I don't believe
+this is anything we need to put on the agenda for tomorrow despite being on
+the open bug list.
+
+--=20
+Steve Langasek Give me a lever long enough and a Free OS
+Debian Developer to set it on, and I can move the world.
+Ubuntu Developer http://www.debian.org/
+slangasek@ubuntu.com vorlon@debian.org
+
+--qMm9M+Fa2AknHoGS
+Content-Type: application/pgp-signature; name="signature.asc"
+Content-Description: Digital signature
+
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1
+
+iQIcBAEBCAAGBQJT2ZMDAAoJEFaNMPMhshM9GLsP/244S3wtYZEeVgJWIdB5PE0A
+sZVezEA692y++/0oVZVecwV67yBOyfSjPPetdAph2UDMRtfurwxfj2BkbOFA2+Y6
+++MErbmC3V7IGpd/L/fFGdXgvMQT2MNBpw0fnMA7bLpNjCvoj+Hr1HXRUcWoJSlj
+WmHWwWSTVRcHg8a3iWYJzY6XfLyEEgHlahrlKvJExsTx/9mc1qg7g8KGdnhzHFBl
+ttdH2fxpAk/624dReCcw5RKmOLfZ1HsEl9XcVe1cb4K+MDaQiXmoEK5v3xaNz1tS
+NK5v2D5gDs229zoxKzQnnzOPLHxqI5E0L9PpI/mu4T9z7H2bHR3U5BvhnT99t5uw
+ydf2cZNGY0uFCV3Rvn07BfAIW5WSXhOfN/5IymRKmdhjsTiwZ/wFjFrK8tVjtERu
+yeyA7RIYiblGCEKYIYLWSxhoXeEdmAdfp6EA2/IA1CpgMB+ZdSfaeMgFY7xosgmG
+ax3NTnaKyhr1QEUJ2gjAwHnKjuGbRVDAinYrSvP0o8Bh9sAs2BN2negWBCZVwwkN
+S9hWTjVqsBmpaPOt5SEDwDo9O9dfzkmaamDsxOuUEz9F7v5jYg0mxA/WbogGty9R
+vOMKxdxRkzflL/CferVbkzL/EkZRDfWDp9SleZggrpz7miiNDbS7jdRzJ4EttmJ8
+gHBAVrOzcnbIPOIkk9pw
+=KXIu
+-----END PGP SIGNATURE-----
+
+--qMm9M+Fa2AknHoGS--
+
+
+--
+To UNSUBSCRIBE, email to debian-ctte-REQUEST@lists.debian.org
+with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
+Archive: https://lists.debian.org/20140731005115.GA19044@virgil.dodds.net
diff --git a/spec/fixtures/emails/boundary.eml b/spec/fixtures/emails/boundary.eml
new file mode 100644
index 00000000000..1250fe498b0
--- /dev/null
+++ b/spec/fixtures/emails/boundary.eml
@@ -0,0 +1,61 @@
+
+MIME-Version: 1.0
+Received: by 10.64.14.41 with HTTP; Wed, 19 Jun 2013 06:29:41 -0700 (PDT)
+In-Reply-To: <51c19490e928a_13442dd8ae892548@tree.mail>
+References: <51c19490e928a_13442dd8ae892548@tree.mail>
+Date: Wed, 19 Jun 2013 09:29:41 -0400
+Delivered-To: finn@adventuretime.ooo
+Message-ID: <CADkmRcL=2aPV7jOcs2i00QGZNwmjYj3qMaJTsKnB7DTP5sgyFQ@mail.gmail.com>
+Subject: Re: [Adventure Time] jake mentioned you in 'peppermint butler is
+ missing'
+From: Finn the Human <finn@adventuretime.ooo>
+To: jake via Adventure Time <reply+96dcd9072ba9072d06226009d4223a6e@appmail.adventuretime.ooo>
+Content-Type: multipart/alternative; boundary=001a11c206a073876a04df81d2a9
+
+--001a11c206a073876a04df81d2a9
+Content-Type: text/plain; charset=ISO-8859-1
+
+I'll look into it, thanks!
+
+
+On Wednesday, June 19, 2013, jake via Discourse wrote:
+
+> jake mentioned you in 'peppermint butler is missing' on Adventure
+> Time:
+> ------------------------------
+>
+> yeah, just noticed this cc @jake
+> ------------------------------
+>
+> Please visit this link to respond:
+> http://adventuretime.ooo/t/peppermint-butler-is-missing/7628/2
+>
+> To unsubscribe from these emails, visit your user preferences
+> <http://adventuretime.ooo/user_preferences>.
+>
+
+--001a11c206a073876a04df81d2a9
+Content-Type: text/html; charset=ISO-8859-1
+Content-Transfer-Encoding: quoted-printable
+
+I&#39;ll look into it, thanks!<span></span><br><br>On Wednesday, June 19, 2=
+013, jake via Adventure Time wrote:<br><blockquote class=3D"gmail_quote" st=
+yle=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p>sa=
+m mentioned you in &#39;Duplicate message are shown in profile&#39; on Adve=
+nture Time</p>
+
+
+<hr><p>yeah, just noticed this cc <a href=3D"http://users/eviltrout" target=
+=3D"_blank">@eviltrout</a> </p>
+
+<hr><p>Please visit this link to respond: <a href=3D"http://adventuretime.oo=
+o/t/duplicate-message-are-shown-in-profile/7628/2" target=3D"_blank">http=
+://adventuretime.ooo/t/peppermint-butler-is-missing/7628/2</a></=
+p>
+
+
+<p>To unsubscribe from these emails, visit your <a href=3D"http://adventuret=
+ime.ooo/user_preferences" target=3D"_blank">user preferences</a>.</p>
+</blockquote>
+
+--001a11c206a073876a04df81d2a9--
diff --git a/spec/fixtures/emails/dutch.eml b/spec/fixtures/emails/dutch.eml
new file mode 100644
index 00000000000..7be08dc4938
--- /dev/null
+++ b/spec/fixtures/emails/dutch.eml
@@ -0,0 +1,20 @@
+
+Delivered-To: discourse-reply+cd480e301683c9902891f15968bf07a5@discourse.org
+Received: by 10.194.216.104 with SMTP id op8csp80593wjc;
+ Wed, 24 Jul 2013 07:59:14 -0700 (PDT)
+Return-Path: <walter.white@googlemail.com>
+References: <topic/5043@discourse.org> <51efeb9b36c34_66dc2dfce6811866@discourse.mail>
+From: Walter White <walter.white@googlemail.com>
+In-Reply-To: <51efeb9b36c34_66dc2dfce6811866@discourse.mail>
+Mime-Version: 1.0 (1.0)
+Date: Wed, 24 Jul 2013 15:59:10 +0100
+Message-ID: <4597127794206131679@unknownmsgid>
+Subject: Re: [Discourse] new reply to your post in 'Crystal Blue'
+To: walter via Discourse <reply+cd480e301683c9902891f15968bf07a5@appmail.adventuretime.ooo>
+Content-Type: multipart/alternative; boundary=001a11c20edc15a39304e2432790
+
+Dit is een antwoord in het Nederlands.
+
+Op 18 juli 2013 10:23 schreef Sander Datema het volgende:
+
+Dit is de originele post. \ No newline at end of file
diff --git a/spec/fixtures/emails/empty.eml b/spec/fixtures/emails/empty.eml
new file mode 100644
index 00000000000..85bebc66245
--- /dev/null
+++ b/spec/fixtures/emails/empty.eml
@@ -0,0 +1,21 @@
+Return-Path: <jake@adventuretime.ooo>
+Received: from iceking.adventuretime.ooo ([unix socket]) by iceking (Cyrus v2.2.13-Debian-2.2.13-19+squeeze3) with LMTPA; Thu, 13 Jun 2013 17:03:50 -0400
+Received: from mail-ie0-x234.google.com (mail-ie0-x234.google.com [IPv6:2607:f8b0:4001:c03::234]) by iceking.adventuretime.ooo (8.14.3/8.14.3/Debian-9.4) with ESMTP id r5DL3nFJ016967 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for <reply+59d8df8370b7e95c5a49fbf86aeb2c93@discourse.example.com>; Thu, 13 Jun 2013 17:03:50 -0400
+Received: by mail-ie0-f180.google.com with SMTP id f4so21977375iea.25 for <reply+59d8df8370b7e95c5a49fbf86aeb2c93@discourse.example.com>; Thu, 13 Jun 2013 14:03:48 -0700
+Received: by 10.0.0.1 with HTTP; Thu, 13 Jun 2013 14:03:48 -0700
+Date: Thu, 13 Jun 2013 17:03:48 -0400
+From: Jake the Dog <jake@adventuretime.ooo>
+To: reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo
+Message-ID: <CADkmRc+rNGAGGbV2iE5p918UVy4UyJqVcXRO2=otppgzduJSg@mail.gmail.com>
+Subject: re: [Discourse Meta] eviltrout posted in 'Adventure Time Sux'
+Mime-Version: 1.0
+Content-Type: text/plain;
+ charset=ISO-8859-1
+Content-Transfer-Encoding: 7bit
+X-Sieve: CMU Sieve 2.2
+X-Received: by 10.0.0.1 with SMTP id n7mr11234144ipb.85.1371157428600; Thu,
+ 13 Jun 2013 14:03:48 -0700 (PDT)
+X-Scanned-By: MIMEDefang 2.69 on IPv6:2001:470:1d:165::1
+
+
+
diff --git a/spec/fixtures/emails/gmail_web.eml b/spec/fixtures/emails/gmail_web.eml
new file mode 100644
index 00000000000..8bb83835711
--- /dev/null
+++ b/spec/fixtures/emails/gmail_web.eml
@@ -0,0 +1,181 @@
+Delivered-To: reply@discourse.org
+Return-Path: <walter.white@googlemail.com>
+MIME-Version: 1.0
+In-Reply-To: <topic/22638/86406@meta.discourse.org>
+References: <topic/22638@meta.discourse.org>
+ <topic/22638/86406@meta.discourse.org>
+Date: Fri, 28 Nov 2014 12:36:49 -0800
+Subject: Re: [Discourse Meta] [Lounge] Testing default email replies
+From: Walter White <walter.white@googlemail.com>
+To: Discourse Meta <reply@discourse.org>
+Content-Type: multipart/alternative; boundary=001a11c2e04e6544f30508f138ba
+
+--001a11c2e04e6544f30508f138ba
+Content-Type: text/plain; charset=UTF-8
+
+### This is a reply from standard GMail in Google Chrome.
+
+The quick brown fox jumps over the lazy dog. The quick brown fox jumps over
+the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown
+fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog. The quick brown fox jumps over
+the lazy dog. The quick brown fox jumps over the lazy dog.
+
+Here's some **bold** text in Markdown.
+
+Here's a link http://example.com
+
+On Fri, Nov 28, 2014 at 12:35 PM, Arpit Jalan <info@discourse.org> wrote:
+
+> techAPJ <https://meta.discourse.org/users/techapj>
+> November 28
+>
+> Test reply.
+>
+> First paragraph.
+>
+> Second paragraph.
+>
+> To respond, reply to this email or visit
+> https://meta.discourse.org/t/testing-default-email-replies/22638/3 in
+> your browser.
+> ------------------------------
+> Previous Replies codinghorror
+> <https://meta.discourse.org/users/codinghorror>
+> November 28
+>
+> We're testing the latest GitHub email processing library which we are
+> integrating now.
+>
+> https://github.com/github/email_reply_parser
+>
+> Go ahead and reply to this topic and I'll reply from various email clients
+> for testing.
+> ------------------------------
+>
+> To respond, reply to this email or visit
+> https://meta.discourse.org/t/testing-default-email-replies/22638/3 in
+> your browser.
+>
+> To unsubscribe from these emails, visit your user preferences
+> <https://meta.discourse.org/my/preferences>.
+>
+
+--001a11c2e04e6544f30508f138ba
+Content-Type: text/html; charset=UTF-8
+Content-Transfer-Encoding: quoted-printable
+
+<div dir=3D"ltr"><div>### This is a reply from standard GMail in Google Chr=
+ome.</div><div><br></div><div>The quick brown fox jumps over the lazy dog. =
+The quick brown fox jumps over the lazy dog. The quick brown fox jumps over=
+ the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown=
+ fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. =
+The quick brown fox jumps over the lazy dog. The quick brown fox jumps over=
+ the lazy dog.=C2=A0</div><div><br></div><div>Here&#39;s some **bold** text=
+ in Markdown.</div><div><br></div><div>Here&#39;s a link <a href=3D"http://=
+example.com">http://example.com</a></div></div><div class=3D"gmail_extra"><=
+br><div class=3D"gmail_quote">On Fri, Nov 28, 2014 at 12:35 PM, Arpit Jalan=
+ <span dir=3D"ltr">&lt;<a href=3D"mailto:info@discourse.org" target=3D"_bla=
+nk">info@discourse.org</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_=
+quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1=
+ex"><div>
+
+<table style=3D"margin-bottom:25px" cellspacing=3D"0" cellpadding=3D"0" bor=
+der=3D"0">
+ <tbody>
+ <tr>
+ <td style=3D"vertical-align:top;width:55px">
+ <img src=3D"https://meta-discourse.global.ssl.fastly.net/user_avata=
+r/meta.discourse.org/techapj/45/3281.png" title=3D"techAPJ" style=3D"max-wi=
+dth:100%" width=3D"45" height=3D"45">
+ </td>
+ <td>
+ <a href=3D"https://meta.discourse.org/users/techapj" style=3D"text-=
+decoration:none;font-weight:bold;color:#006699;font-size:13px;font-family:&=
+#39;lucida grande&#39;,tahoma,verdana,arial,sans-serif;color:#3b5998;text-d=
+ecoration:none;font-weight:bold" target=3D"_blank">techAPJ</a><br>
+ <span style=3D"text-align:right;color:#999999;padding-right:5px;fon=
+t-family:&#39;lucida grande&#39;,tahoma,verdana,arial,sans-serif;font-size:=
+11px">November 28</span>
+ </td>
+ </tr>
+ <tr>
+ <td style=3D"padding-top:5px" colspan=3D"2">
+<p style=3D"margin-top:0;border:0">Test reply.</p>
+
+<p style=3D"margin-top:0;border:0">First paragraph.</p>
+
+<p style=3D"margin-top:0;border:0">Second paragraph.</p>
+</td>
+ </tr>
+ </tbody>
+</table>
+
+
+ <div style=3D"color:#666">
+ <p>To respond, reply to this email or visit <a href=3D"https://meta.dis=
+course.org/t/testing-default-email-replies/22638/3" style=3D"text-decoratio=
+n:none;font-weight:bold;color:#006699;color:#666" target=3D"_blank">https:/=
+/meta.discourse.org/t/testing-default-email-replies/22638/3</a> in your bro=
+wser.</p>
+ </div>
+ <hr style=3D"background-color:#ddd;min-height:1px;border:1px;background-c=
+olor:#ddd;min-height:1px;border:1px">
+ <h4>Previous Replies</h4>
+
+ <table style=3D"margin-bottom:25px" cellspacing=3D"0" cellpadding=3D"0" b=
+order=3D"0">
+ <tbody>
+ <tr>
+ <td style=3D"vertical-align:top;width:55px">
+ <img src=3D"https://meta-discourse.global.ssl.fastly.net/user_avata=
+r/meta.discourse.org/codinghorror/45/5297.png" title=3D"codinghorror" style=
+=3D"max-width:100%" width=3D"45" height=3D"45">
+ </td>
+ <td>
+ <a href=3D"https://meta.discourse.org/users/codinghorror" style=3D"=
+text-decoration:none;font-weight:bold;color:#006699;font-size:13px;font-fam=
+ily:&#39;lucida grande&#39;,tahoma,verdana,arial,sans-serif;color:#3b5998;t=
+ext-decoration:none;font-weight:bold" target=3D"_blank">codinghorror</a><br=
+>
+ <span style=3D"text-align:right;color:#999999;padding-right:5px;fon=
+t-family:&#39;lucida grande&#39;,tahoma,verdana,arial,sans-serif;font-size:=
+11px">November 28</span>
+ </td>
+ </tr>
+ <tr>
+ <td style=3D"padding-top:5px" colspan=3D"2">
+<p style=3D"margin-top:0;border:0">We&#39;re testing the latest GitHub emai=
+l processing library which we are integrating now.</p>
+
+<p style=3D"margin-top:0;border:0"><a href=3D"https://github.com/github/ema=
+il_reply_parser" style=3D"text-decoration:none;font-weight:bold;color:#0066=
+99" target=3D"_blank">https://github.com/github/email_reply_parser</a></p>
+
+<p style=3D"margin-top:0;border:0">Go ahead and reply to this topic and I&#=
+39;ll reply from various email clients for testing.</p>
+</td>
+ </tr>
+ </tbody>
+</table>
+
+
+<hr style=3D"background-color:#ddd;min-height:1px;border:1px;background-col=
+or:#ddd;min-height:1px;border:1px">
+
+<div style=3D"color:#666">
+<p>To respond, reply to this email or visit <a href=3D"https://meta.discour=
+se.org/t/testing-default-email-replies/22638/3" style=3D"text-decoration:no=
+ne;font-weight:bold;color:#006699;color:#666" target=3D"_blank">https://met=
+a.discourse.org/t/testing-default-email-replies/22638/3</a> in your browser=
+.</p>
+</div>
+<div style=3D"color:#666">
+<p>To unsubscribe from these emails, visit your <a href=3D"https://meta.dis=
+course.org/my/preferences" style=3D"text-decoration:none;font-weight:bold;c=
+olor:#006699;color:#666" target=3D"_blank">user preferences</a>.</p>
+</div>
+</div>
+</blockquote></div><br></div>
+
+--001a11c2e04e6544f30508f138ba--
diff --git a/spec/fixtures/emails/hebrew.eml b/spec/fixtures/emails/hebrew.eml
new file mode 100644
index 00000000000..f4c8f01adc3
--- /dev/null
+++ b/spec/fixtures/emails/hebrew.eml
@@ -0,0 +1,17 @@
+
+Delivered-To: discourse-reply+cd480e301683c9902891f15968bf07a5@discourse.org
+Received: by 10.194.216.104 with SMTP id op8csp80593wjc;
+ Wed, 24 Jul 2013 07:59:14 -0700 (PDT)
+Return-Path: <walter.white@googlemail.com>
+References: <topic/5043@discourse.org> <51efeb9b36c34_66dc2dfce6811866@discourse.mail>
+From: Walter White <walter.white@googlemail.com>
+In-Reply-To: <51efeb9b36c34_66dc2dfce6811866@discourse.mail>
+Mime-Version: 1.0 (1.0)
+Date: Wed, 24 Jul 2013 15:59:10 +0100
+Message-ID: <4597127794206131679@unknownmsgid>
+Subject: Re: [Discourse] new reply to your post in 'Crystal Blue'
+To: walter via Discourse <reply+cd480e301683c9902891f15968bf07a5@appmail.adventuretime.ooo>
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: base64
+
+16nXnNeV150= \ No newline at end of file
diff --git a/spec/fixtures/emails/html_only.eml b/spec/fixtures/emails/html_only.eml
new file mode 100644
index 00000000000..561b8db2c79
--- /dev/null
+++ b/spec/fixtures/emails/html_only.eml
@@ -0,0 +1,93 @@
+
+Delivered-To: walter@breakingbad.com
+Received: by 10.64.13.41 with SMTP id m9csp29769iec;
+ Thu, 20 Jun 2013 08:53:22 -0700 (PDT)
+X-Received: by 10.252.23.9 with SMTP id p9mr4055675lag.4.1371743601980;
+ Thu, 20 Jun 2013 08:53:21 -0700 (PDT)
+Received: from mail-la0-x229.google.com (mail-la0-x229.google.com [2a00:1450:4010:c03::229])
+ by mx.google.com with ESMTPS id u4si430203lae.48.2013.06.20.08.53.20
+ for <walter@breakingbad.com>
+ (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
+ Thu, 20 Jun 2013 08:53:21 -0700 (PDT)
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
+ d=google.com; s=20120113;
+ h=x-forwarded-to:x-forwarded-for:delivered-to:x-return-path
+ :content-type:mime-version:content-transfer-encoding:x-mailer
+ :message-id:date:subject:from:in-reply-to:to:resent-date:resent-from
+ :resent-to:resent-subject:resent-message-id:resent-user-agent
+ :x-scanned-by:x-gm-message-state;
+ bh=9O67r74ofh9WkEaKTRB/frQ3MKOtQlbCac2mz0/MiyY=;
+ b=YVAo2/JDMP53RxDmqDEKNcEMtggtfaVyq2DoseZ6vBAfB7G6NtHC9ZEkRs4oGhk6LU
+ fnyAPe0wnz5d9WINoMAuuTRIhplLxzcqysduSnAJAQ2qqR7mFBnlj9wJeVEKltNwmUME
+ nPwxsf8go20VBzrZCtECPedcLi60wbl32NCXVn0qwt2LvKiy6ktSS5Xgb4zY8i4dfXAP
+ 6Y5gu32boooWIb9DkH1TJkn3C0RrEugNlw/DUnXrnkFefgxWF3pt/zcoW/wYRyikOdx+
+ smBClgR9my6QmsS2KsQrMvWJZUva7fddTiZ6FC22e4hW+8Wha0RaZOZu5O7hjg6G4/1g
+ IEyg==
+X-Received: by 10.112.55.9 with SMTP id n9mr5916187lbp.5.1371743600857;
+ Thu, 20 Jun 2013 08:53:20 -0700 (PDT)
+X-Forwarded-To: walter@breakingbad.com
+X-Forwarded-For: walter@breakingbad.com
+Delivered-To: walter@breakingbad.com
+Content-Type: text/html; charset="us-ascii"
+MIME-Version: 1.0
+Content-Transfer-Encoding: quoted-printable
+X-Mailer: BlackBerry Email (10.1.0.1720)
+Message-ID: <20130619231548.6307981.74194.2379@breakingbad.com>
+Date: Wed, 19 Jun 2013 19:15:48 -0400
+Subject: Re: [Discourse Meta] [PM] re: Regarding your post in "Site
+ Customization not working"
+From: aaron@breakingbad.com
+In-Reply-To: <51c238655a394_5f4e3ce6690667bd@tiefighter2.mail>
+To: reply+20c1b0a8bd1a63c0163cc7e7641ca06b@appmail.adventuretime.ooo
+ReSent-Date: Thu, 20 Jun 2013 11:53:08 -0400 (EDT)
+ReSent-From: Aaron <aaron@breakingbad.com>
+ReSent-Subject: Re: [Discourse Meta] [PM] re: Regarding your post in "Site
+ Customization not working"
+X-Gm-Message-State: ALoCoQl1BtN83rAX7At808XAPv1yCqUK3Du2IvK7eCyY3jsI77u4e5cak28307pYYHAo1JlO/Eu9
+
+<html><head></head><body data-blackberry-caret-color=3D"#00a8df" style=3D"b=
+ackground-color: rgb(255, 255, 255); line-height: initial;"><div id=3D"BB10=
+_response_div" style=3D"width: 100%; font-size: initial; font-family: Calib=
+ri, 'Slate Pro', sans-serif; color: rgb(31, 73, 125); text-align: initial; =
+background-color: rgb(255, 255, 255);">The EC2 instance - I've seen that th=
+ere tends to be odd and unrecommended settings on the Bitnami installs that=
+ I've checked out.</div> =
+ =
+ <div id=3D"response_div_spacer" style=3D"width: 100%; font-size: ini=
+tial; font-family: Calibri, 'Slate Pro', sans-serif; color: rgb(31, 73, 125=
+); text-align: initial; background-color: rgb(255, 255, 255);"><br style=3D=
+"display:initial"></div> =
+ =
+ <div id=3D"_signaturePlaceholder" style=3D"font-size: initial; font-=
+family: Calibri, 'Slate Pro', sans-serif; color: rgb(31, 73, 125); text-ali=
+gn: initial; background-color: rgb(255, 255, 255);"></div> =
+ =
+ =
+ <table width=3D"100%" style=3D"background-color:white;bord=
+er-spacing:0px;"> <tbody><tr><td id=3D"_persistentHeaderContainer" colspan=
+=3D"2" style=3D"font-size: initial; text-align: initial; background-color: =
+rgb(255, 255, 255);"> <div id=
+=3D"_persistentHeader" style=3D"border-style: solid none none; border-top-c=
+olor: rgb(181, 196, 223); border-top-width: 1pt; padding: 3pt 0in 0in; font=
+-family: Tahoma, 'BB Alpha Sans', 'Slate Pro'; font-size: 10pt;"> <div><b>=
+From: </b>Grizzly B via Discourse Meta</div><div><b>Sent: </b>Wednesday, J=
+une 19, 2013 19:02</div><div><b>To: </b>aaron@breakingbad.com</div><div><b>=
+Reply To: </b>Grizzly B via Discourse Meta</div><div><b>Subject: </b>[Disc=
+ourse Meta] [PM] re: Regarding your post in "Site Customization<br> not wor=
+king"</div></div></td></tr></tbody></table><div id=3D"_persistentHeaderEnd"=
+ style=3D"border-style: solid none none; border-top-color: rgb(186, 188, 20=
+9); border-top-width: 1pt; font-size: initial; text-align: initial; backgro=
+und-color: rgb(255, 255, 255);"></div><br><div id=3D"_originalContent" styl=
+e=3D""><p>Grizzly B just sent you a private message</p>
+
+<hr><p>Log in to our EC2 instance -or- log into a new Digital Ocean instanc=
+e?</p>
+
+<hr><p>Please visit this link to respond: <a href=3D"http://meta.discourse.=
+org/t/regarding-your-post-in-site-customization-not-working/7641/5">http://=
+meta.discourse.org/t/regarding-your-post-in-site-customization-not-working/=
+7641/5</a></p>
+
+<p>To unsubscribe from these emails, visit your <a href=3D"http://meta.disc=
+ourse.org/user_preferences">user preferences</a>.</p>
+<br><!--end of _originalContent --></div></body></html>
diff --git a/spec/fixtures/emails/html_paragraphs.eml b/spec/fixtures/emails/html_paragraphs.eml
new file mode 100644
index 00000000000..3fe37fb8b17
--- /dev/null
+++ b/spec/fixtures/emails/html_paragraphs.eml
@@ -0,0 +1,205 @@
+
+MIME-Version: 1.0
+Received: by 10.25.161.144 with HTTP; Tue, 7 Oct 2014 22:17:17 -0700 (PDT)
+X-Originating-IP: [117.207.85.84]
+In-Reply-To: <5434c8b52bb3a_623ff09fec70f049749@discourse-app.mail>
+References: <topic/35@discourse.techapj.com>
+ <5434c8b52bb3a_623ff09fec70f049749@discourse-app.mail>
+Date: Wed, 8 Oct 2014 10:47:17 +0530
+Delivered-To: arpit@techapj.com
+Message-ID: <CAOJeqne=SJ_LwN4sb-0Y95ejc2OpreVhdmcPn0TnmwSvTCYzzQ@mail.gmail.com>
+Subject: Re: [Discourse] [Meta] Welcome to techAPJ's Discourse!
+From: Arpit Jalan <arpit@techapj.com>
+To: Discourse <mail+e1c7f2a380e33840aeb654f075490bad@arpitjalan.com>
+Content-Type: multipart/alternative; boundary=001a114119d8f4e46e0504e26d5b
+
+--001a114119d8f4e46e0504e26d5b
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: quoted-printable
+
+Awesome!
+
+Pleasure to have you here!
+
+:boom:
+
+On Wed, Oct 8, 2014 at 10:46 AM, ajalan <info@unconfigured.discourse.org>
+wrote:
+
+> ajalan
+> <http://mandrillapp.com/track/click/30081177/discourse.techapj.com?p=3Dey=
+JzIjoiVXgxTTZ3eHpuRWF2QXVoZGRJZVN5MWI0WnhrIiwidiI6MSwicCI6IntcInVcIjozMDA4M=
+TE3NyxcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvZGlzY291cnNlLnRlY2hhcGouY29t=
+XFxcL3VzZXJzXFxcL2FqYWxhblwiLFwiaWRcIjpcIjgyNWI5MDYzZWNmMDRkMjk5OTE4Nzk1MmU=
+5YjY2YjE3XCIsXCJ1cmxfaWRzXCI6W1wiNzA3MTNjNTg4MDI3YWQyM2RiM2QwOTVhOGQwYmY4ZT=
+YyMzNjYThiMFwiXX0ifQ>
+> October 8
+>
+> Nice to be here! Thanks! [image: smile]
+>
+> To respond, reply to this email or visit
+> http://discourse.techapj.com/t/welcome-to-techapjs-discourse/35/2
+> <http://mandrillapp.com/track/click/30081177/discourse.techapj.com?p=3Dey=
+JzIjoid1IyWnVqVGRPU2RwLUlFR0Q5QnI1a203eVNjIiwidiI6MSwicCI6IntcInVcIjozMDA4M=
+TE3NyxcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvZGlzY291cnNlLnRlY2hhcGouY29t=
+XFxcL3RcXFwvd2VsY29tZS10by10ZWNoYXBqcy1kaXNjb3Vyc2VcXFwvMzVcXFwvMlwiLFwiaWR=
+cIjpcIjgyNWI5MDYzZWNmMDRkMjk5OTE4Nzk1MmU5YjY2YjE3XCIsXCJ1cmxfaWRzXCI6W1wiY2=
+RkYzFlZjc5OThhNzE1ODA4Yjg0MGFlNzVlZmNiYmYzYmViODk4Y1wiXX0ifQ>
+> in your browser.
+> ------------------------------
+> Previous Replies techAPJ
+> <http://mandrillapp.com/track/click/30081177/discourse.techapj.com?p=3Dey=
+JzIjoia2x3LUxac2RSX25uWEFYYWcwVDVha3pIY3RjIiwidiI6MSwicCI6IntcInVcIjozMDA4M=
+TE3NyxcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvZGlzY291cnNlLnRlY2hhcGouY29t=
+XFxcL3VzZXJzXFxcL3RlY2hhcGpcIixcImlkXCI6XCI4MjViOTA2M2VjZjA0ZDI5OTkxODc5NTJ=
+lOWI2NmIxN1wiLFwidXJsX2lkc1wiOltcIjk2ZjAyMzVhNmM2NzIyNmU1NjhhMzU1NDE1OTAxNz=
+AyYTkxNjM1NzJcIl19In0>
+> October 8
+>
+> Welcome to techAPJ's Discourse!
+> ------------------------------
+>
+> To respond, reply to this email or visit
+> http://discourse.techapj.com/t/welcome-to-techapjs-discourse/35/2
+> <http://mandrillapp.com/track/click/30081177/discourse.techapj.com?p=3Dey=
+JzIjoid1IyWnVqVGRPU2RwLUlFR0Q5QnI1a203eVNjIiwidiI6MSwicCI6IntcInVcIjozMDA4M=
+TE3NyxcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvZGlzY291cnNlLnRlY2hhcGouY29t=
+XFxcL3RcXFwvd2VsY29tZS10by10ZWNoYXBqcy1kaXNjb3Vyc2VcXFwvMzVcXFwvMlwiLFwiaWR=
+cIjpcIjgyNWI5MDYzZWNmMDRkMjk5OTE4Nzk1MmU5YjY2YjE3XCIsXCJ1cmxfaWRzXCI6W1wiY2=
+RkYzFlZjc5OThhNzE1ODA4Yjg0MGFlNzVlZmNiYmYzYmViODk4Y1wiXX0ifQ>
+> in your browser.
+>
+> To unsubscribe from these emails, visit your user preferences
+> <http://mandrillapp.com/track/click/30081177/discourse.techapj.com?p=3Dey=
+JzIjoiVTNudkpobl9lUUl0cmdsVVRrcm5iaHpyN0JZIiwidiI6MSwicCI6IntcInVcIjozMDA4M=
+TE3NyxcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvZGlzY291cnNlLnRlY2hhcGouY29t=
+XFxcL215XFxcL3ByZWZlcmVuY2VzXCIsXCJpZFwiOlwiODI1YjkwNjNlY2YwNGQyOTk5MTg3OTU=
+yZTliNjZiMTdcIixcInVybF9pZHNcIjpbXCI0OTIyMmMyZDgyNzUwMmQyMGZjYzU4MTZkNjhmYT=
+k3NzFkY2YzZDllXCJdfSJ9>
+> .
+>
+
+--001a114119d8f4e46e0504e26d5b
+Content-Type: text/html; charset=UTF-8
+Content-Transfer-Encoding: quoted-printable
+
+<div dir=3D"ltr">Awesome!<div><br></div><div>Pleasure to have you here!</di=
+v><div><br></div><div>:boom:</div></div><div class=3D"gmail_extra"><br><div=
+ class=3D"gmail_quote">On Wed, Oct 8, 2014 at 10:46 AM, ajalan <span dir=3D=
+"ltr">&lt;<a href=3D"mailto:info@unconfigured.discourse.org" target=3D"_bla=
+nk">info@unconfigured.discourse.org</a>&gt;</span> wrote:<br><blockquote cl=
+ass=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;p=
+adding-left:1ex"><div>
+
+<table style=3D"margin-bottom:25px;max-width:761px" cellspacing=3D"0" cellp=
+adding=3D"0" border=3D"0">
+ <tbody>
+ <tr>
+ <td style=3D"vertical-align:top;width:55px">
+ <img src=3D"http://discourse.techapj.com/user_avatar/discourse.tech=
+apj.com/ajalan/45/35.png" title=3D"ajalan" style=3D"max-width:694px" width=
+=3D"45" height=3D"45">
+ </td>
+ <td>
+ <a href=3D"http://mandrillapp.com/track/click/30081177/discourse.te=
+chapj.com?p=3DeyJzIjoiVXgxTTZ3eHpuRWF2QXVoZGRJZVN5MWI0WnhrIiwidiI6MSwicCI6I=
+ntcInVcIjozMDA4MTE3NyxcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvZGlzY291cnNl=
+LnRlY2hhcGouY29tXFxcL3VzZXJzXFxcL2FqYWxhblwiLFwiaWRcIjpcIjgyNWI5MDYzZWNmMDR=
+kMjk5OTE4Nzk1MmU5YjY2YjE3XCIsXCJ1cmxfaWRzXCI6W1wiNzA3MTNjNTg4MDI3YWQyM2RiM2=
+QwOTVhOGQwYmY4ZTYyMzNjYThiMFwiXX0ifQ" style=3D"font-size:13px;font-family:&=
+#39;lucida grande&#39;,tahoma,verdana,arial,sans-serif;color:#3b5998;text-d=
+ecoration:none;font-weight:bold;text-decoration:none;font-weight:bold;color=
+:#006699" target=3D"_blank">ajalan</a><br>
+ <span style=3D"text-align:right;color:#999999;padding-right:5px;fon=
+t-family:&#39;lucida grande&#39;,tahoma,verdana,arial,sans-serif;font-size:=
+11px">October 8</span>
+ </td>
+ </tr>
+ <tr>
+ <td style=3D"padding-top:5px" colspan=3D"2"><p style=3D"margin-top:0;=
+border:0">Nice to be here! Thanks! <img src=3D"http://discourse.techapj.com=
+/plugins/emoji/images/smile.png" title=3D":smile:" alt=3D"smile" width=3D"2=
+0" height=3D"20"></p></td>
+ </tr>
+ </tbody>
+</table>
+
+
+ <div style=3D"color:#666">
+ <p>To respond, reply to this email or visit <a href=3D"http://mandrilla=
+pp.com/track/click/30081177/discourse.techapj.com?p=3DeyJzIjoid1IyWnVqVGRPU=
+2RwLUlFR0Q5QnI1a203eVNjIiwidiI6MSwicCI6IntcInVcIjozMDA4MTE3NyxcInZcIjoxLFwi=
+dXJsXCI6XCJodHRwOlxcXC9cXFwvZGlzY291cnNlLnRlY2hhcGouY29tXFxcL3RcXFwvd2VsY29=
+tZS10by10ZWNoYXBqcy1kaXNjb3Vyc2VcXFwvMzVcXFwvMlwiLFwiaWRcIjpcIjgyNWI5MDYzZW=
+NmMDRkMjk5OTE4Nzk1MmU5YjY2YjE3XCIsXCJ1cmxfaWRzXCI6W1wiY2RkYzFlZjc5OThhNzE1O=
+DA4Yjg0MGFlNzVlZmNiYmYzYmViODk4Y1wiXX0ifQ" style=3D"color:#666;text-decorat=
+ion:none;font-weight:bold;color:#006699" target=3D"_blank">http://discourse=
+.techapj.com/t/welcome-to-techapjs-discourse/35/2</a> in your browser.</p>
+ </div>
+ <hr style=3D"background-color:#ddd;min-height:1px;border:1px;background-c=
+olor:#ddd;min-height:1px;border:1px">
+ <h4>Previous Replies</h4>
+
+ <table style=3D"margin-bottom:25px;max-width:761px" cellspacing=3D"0" cel=
+lpadding=3D"0" border=3D"0">
+ <tbody>
+ <tr>
+ <td style=3D"vertical-align:top;width:55px">
+ <img src=3D"http://discourse.techapj.com/user_avatar/discourse.tech=
+apj.com/techapj/45/34.png" title=3D"techAPJ" style=3D"max-width:694px" widt=
+h=3D"45" height=3D"45">
+ </td>
+ <td>
+ <a href=3D"http://mandrillapp.com/track/click/30081177/discourse.te=
+chapj.com?p=3DeyJzIjoia2x3LUxac2RSX25uWEFYYWcwVDVha3pIY3RjIiwidiI6MSwicCI6I=
+ntcInVcIjozMDA4MTE3NyxcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvZGlzY291cnNl=
+LnRlY2hhcGouY29tXFxcL3VzZXJzXFxcL3RlY2hhcGpcIixcImlkXCI6XCI4MjViOTA2M2VjZjA=
+0ZDI5OTkxODc5NTJlOWI2NmIxN1wiLFwidXJsX2lkc1wiOltcIjk2ZjAyMzVhNmM2NzIyNmU1Nj=
+hhMzU1NDE1OTAxNzAyYTkxNjM1NzJcIl19In0" style=3D"font-size:13px;font-family:=
+&#39;lucida grande&#39;,tahoma,verdana,arial,sans-serif;color:#3b5998;text-=
+decoration:none;font-weight:bold;text-decoration:none;font-weight:bold;colo=
+r:#006699" target=3D"_blank">techAPJ</a><br>
+ <span style=3D"text-align:right;color:#999999;padding-right:5px;fon=
+t-family:&#39;lucida grande&#39;,tahoma,verdana,arial,sans-serif;font-size:=
+11px">October 8</span>
+ </td>
+ </tr>
+ <tr>
+ <td style=3D"padding-top:5px" colspan=3D"2"><p style=3D"margin-top:0;=
+border:0">Welcome to techAPJ&#39;s Discourse!</p></td>
+ </tr>
+ </tbody>
+</table>
+
+
+<hr style=3D"background-color:#ddd;min-height:1px;border:1px;background-col=
+or:#ddd;min-height:1px;border:1px">
+
+<div style=3D"color:#666">
+<p>To respond, reply to this email or visit <a href=3D"http://mandrillapp.c=
+om/track/click/30081177/discourse.techapj.com?p=3DeyJzIjoid1IyWnVqVGRPU2RwL=
+UlFR0Q5QnI1a203eVNjIiwidiI6MSwicCI6IntcInVcIjozMDA4MTE3NyxcInZcIjoxLFwidXJs=
+XCI6XCJodHRwOlxcXC9cXFwvZGlzY291cnNlLnRlY2hhcGouY29tXFxcL3RcXFwvd2VsY29tZS1=
+0by10ZWNoYXBqcy1kaXNjb3Vyc2VcXFwvMzVcXFwvMlwiLFwiaWRcIjpcIjgyNWI5MDYzZWNmMD=
+RkMjk5OTE4Nzk1MmU5YjY2YjE3XCIsXCJ1cmxfaWRzXCI6W1wiY2RkYzFlZjc5OThhNzE1ODA4Y=
+jg0MGFlNzVlZmNiYmYzYmViODk4Y1wiXX0ifQ" style=3D"color:#666;text-decoration:=
+none;font-weight:bold;color:#006699" target=3D"_blank">http://discourse.tec=
+hapj.com/t/welcome-to-techapjs-discourse/35/2</a> in your browser.</p>
+</div><span class=3D"">
+<div style=3D"color:#666">
+<p>To unsubscribe from these emails, visit your <a href=3D"http://mandrilla=
+pp.com/track/click/30081177/discourse.techapj.com?p=3DeyJzIjoiVTNudkpobl9lU=
+Ul0cmdsVVRrcm5iaHpyN0JZIiwidiI6MSwicCI6IntcInVcIjozMDA4MTE3NyxcInZcIjoxLFwi=
+dXJsXCI6XCJodHRwOlxcXC9cXFwvZGlzY291cnNlLnRlY2hhcGouY29tXFxcL215XFxcL3ByZWZ=
+lcmVuY2VzXCIsXCJpZFwiOlwiODI1YjkwNjNlY2YwNGQyOTk5MTg3OTUyZTliNjZiMTdcIixcIn=
+VybF9pZHNcIjpbXCI0OTIyMmMyZDgyNzUwMmQyMGZjYzU4MTZkNjhmYTk3NzFkY2YzZDllXCJdf=
+SJ9" style=3D"color:#666;text-decoration:none;font-weight:bold;color:#00669=
+9" target=3D"_blank">user preferences</a>.</p>
+</div>
+</span></div>
+
+<img src=3D"http://mandrillapp.com/track/open.php?u=3D30081177&amp;id=3D825=
+b9063ecf04d2999187952e9b66b17" height=3D"1" width=3D"1"></blockquote></div>=
+<br></div>
+
+--001a114119d8f4e46e0504e26d5b--
diff --git a/spec/fixtures/emails/inline_reply.eml b/spec/fixtures/emails/inline_reply.eml
new file mode 100644
index 00000000000..39625a225da
--- /dev/null
+++ b/spec/fixtures/emails/inline_reply.eml
@@ -0,0 +1,60 @@
+
+MIME-Version: 1.0
+In-Reply-To: <reply@discourse-app.mail>
+References: <topic/36@discourse.techapj.com>
+ <5434ced4ee0f9_663fb0b5f76070593b@discourse-app.mail>
+Date: Mon, 1 Dec 2014 20:48:40 +0530
+Delivered-To: someone@googlemail.com
+Subject: Re: [Discourse] [Meta] Testing reply via email
+From: Walter White <walter.white@googlemail.com>
+To: Discourse <reply@mail.com>
+Content-Type: multipart/alternative; boundary=20cf30363f8522466905092920a6
+
+--20cf30363f8522466905092920a6
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: quoted-printable
+
+On Wed, Oct 8, 2014 at 11:12 AM, techAPJ <info@unconfigured.discourse.org>
+wrote:
+
+> techAPJ <https://meta.discourse.org/users/techapj>
+> November 28
+>
+> Test reply.
+>
+> First paragraph.
+>
+> Second paragraph.
+>
+> To respond, reply to this email or visit
+> https://meta.discourse.org/t/testing-default-email-replies/22638/3 in
+> your browser.
+> ------------------------------
+> Previous Replies codinghorror
+> <https://meta.discourse.org/users/codinghorror>
+> November 28
+>
+> We're testing the latest GitHub email processing library which we are
+> integrating now.
+>
+> https://github.com/github/email_reply_parser
+>
+> Go ahead and reply to this topic and I'll reply from various email clients
+> for testing.
+> ------------------------------
+>
+> To respond, reply to this email or visit
+> https://meta.discourse.org/t/testing-default-email-replies/22638/3 in
+> your browser.
+>
+> To unsubscribe from these emails, visit your user preferences
+> <https://meta.discourse.org/my/preferences>.
+>
+
+The quick brown fox jumps over the lazy dog. The quick brown fox jumps over
+the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown
+fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog. The quick brown fox jumps over
+the lazy dog. The quick brown fox jumps over the lazy dog.
+
+--20cf30363f8522466905092920a6--
diff --git a/spec/fixtures/emails/ios_default.eml b/spec/fixtures/emails/ios_default.eml
new file mode 100644
index 00000000000..8d4d58feb16
--- /dev/null
+++ b/spec/fixtures/emails/ios_default.eml
@@ -0,0 +1,136 @@
+Delivered-To: reply@discourse.org
+Return-Path: <walter.white@googlemail.com>
+From: Walter White <walter.white@googlemail.com>
+Content-Type: multipart/alternative;
+ boundary=Apple-Mail-B41C7F8E-3639-49B0-A5D5-440E125A7105
+Content-Transfer-Encoding: 7bit
+Mime-Version: 1.0 (1.0)
+Subject: Re: [Discourse Meta] [Lounge] Testing default email replies
+Date: Fri, 28 Nov 2014 12:41:41 -0800
+References: <topic/22638@meta.discourse.org> <topic/22638/86406@meta.discourse.org>
+In-Reply-To: <topic/22638/86406@meta.discourse.org>
+To: Discourse Meta <reply@discourse.org>
+X-Mailer: iPhone Mail (12B436)
+
+
+--Apple-Mail-B41C7F8E-3639-49B0-A5D5-440E125A7105
+Content-Type: text/plain;
+ charset=us-ascii
+Content-Transfer-Encoding: quoted-printable
+
+### this is a reply from iOS default mail
+
+The quick brown fox jumps over the lazy dog. The quick brown fox jumps over t=
+he lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fo=
+x jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The q=
+uick brown fox jumps over the lazy dog. The quick brown fox jumps over the l=
+azy dog.=20
+
+Here's some **bold** markdown text.
+
+Here's a link http://example.com
+
+
+> On Nov 28, 2014, at 12:35 PM, Arpit Jalan <info@discourse.org> wrote:
+>=20
+>=20
+> techAPJ
+> November 28
+> Test reply.
+>=20
+> First paragraph.
+>=20
+> Second paragraph.
+>=20
+> To respond, reply to this email or visit https://meta.discourse.org/t/test=
+ing-default-email-replies/22638/3 in your browser.
+>=20
+> Previous Replies
+>=20
+> codinghorror
+> November 28
+> We're testing the latest GitHub email processing library which we are inte=
+grating now.
+>=20
+> https://github.com/github/email_reply_parser
+>=20
+> Go ahead and reply to this topic and I'll reply from various email clients=
+ for testing.
+>=20
+> To respond, reply to this email or visit https://meta.discourse.org/t/test=
+ing-default-email-replies/22638/3 in your browser.
+>=20
+> To unsubscribe from these emails, visit your user preferences.
+
+--Apple-Mail-B41C7F8E-3639-49B0-A5D5-440E125A7105
+Content-Type: text/html;
+ charset=utf-8
+Content-Transfer-Encoding: 7bit
+
+<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>### this is a reply from iOS default mail</div><div><br></div><div>The quick brown fox jumps over the lazy dog.&nbsp;<span style="background-color: rgba(255, 255, 255, 0);">The quick brown fox jumps over the lazy dog.&nbsp;The quick brown fox jumps over the lazy dog.&nbsp;The quick brown fox jumps over the lazy dog.&nbsp;The quick brown fox jumps over the lazy dog.&nbsp;The quick brown fox jumps over the lazy dog.&nbsp;The quick brown fox jumps over the lazy dog.&nbsp;</span></div><div><br></div><div>Here's some **bold** markdown text.</div><div><br></div><div>Here's a link <a href="http://example.com">http://example.com</a><br><br></div><div><br>On Nov 28, 2014, at 12:35 PM, Arpit Jalan &lt;<a href="mailto:info@discourse.org">info@discourse.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div>
+
+<table style="margin-bottom:25px;" cellspacing="0" cellpadding="0" border="0">
+ <tbody>
+ <tr>
+ <td style="vertical-align:top;width:55px;">
+ <img src="https://meta-discourse.global.ssl.fastly.net/user_avatar/meta.discourse.org/techapj/45/3281.png" title="techAPJ" style="max-width:100%;" width="45" height="45">
+ </td>
+ <td>
+ <a href="https://meta.discourse.org/users/techapj" target="_blank" style="text-decoration: none; font-weight: bold; color: #006699;; font-size:13px;font-family:'lucida grande',tahoma,verdana,arial,sans-serif;color:#3b5998;text-decoration:none;font-weight:bold">techAPJ</a><br>
+ <span style="text-align:right;color:#999999;padding-right:5px;font-family:'lucida grande',tahoma,verdana,arial,sans-serif;font-size:11px">November 28</span>
+ </td>
+ </tr>
+ <tr>
+ <td style="padding-top:5px;" colspan="2">
+<p style="margin-top:0; border: 0;">Test reply.</p>
+
+<p style="margin-top:0; border: 0;">First paragraph.</p>
+
+<p style="margin-top:0; border: 0;">Second paragraph.</p>
+</td>
+ </tr>
+ </tbody>
+</table>
+
+
+ <div style="color:#666;">
+ <p>To respond, reply to this email or visit <a href="https://meta.discourse.org/t/testing-default-email-replies/22638/3" style="text-decoration: none; font-weight: bold; color: #006699;; color:#666;">https://meta.discourse.org/t/testing-default-email-replies/22638/3</a> in your browser.</p>
+ </div>
+ <hr style="background-color: #ddd; height: 1px; border: 1px;; background-color: #ddd; height: 1px; border: 1px;">
+ <h4>Previous Replies</h4>
+
+ <table style="margin-bottom:25px;" cellspacing="0" cellpadding="0" border="0">
+ <tbody>
+ <tr>
+ <td style="vertical-align:top;width:55px;">
+ <img src="https://meta-discourse.global.ssl.fastly.net/user_avatar/meta.discourse.org/codinghorror/45/5297.png" title="codinghorror" style="max-width:100%;" width="45" height="45">
+ </td>
+ <td>
+ <a href="https://meta.discourse.org/users/codinghorror" target="_blank" style="text-decoration: none; font-weight: bold; color: #006699;; font-size:13px;font-family:'lucida grande',tahoma,verdana,arial,sans-serif;color:#3b5998;text-decoration:none;font-weight:bold">codinghorror</a><br>
+ <span style="text-align:right;color:#999999;padding-right:5px;font-family:'lucida grande',tahoma,verdana,arial,sans-serif;font-size:11px">November 28</span>
+ </td>
+ </tr>
+ <tr>
+ <td style="padding-top:5px;" colspan="2">
+<p style="margin-top:0; border: 0;">We're testing the latest GitHub email processing library which we are integrating now.</p>
+
+<p style="margin-top:0; border: 0;"><a href="https://github.com/github/email_reply_parser" target="_blank" style="text-decoration: none; font-weight: bold; color: #006699;">https://github.com/github/email_reply_parser</a></p>
+
+<p style="margin-top:0; border: 0;">Go ahead and reply to this topic and I'll reply from various email clients for testing.</p>
+</td>
+ </tr>
+ </tbody>
+</table>
+
+
+<hr style="background-color: #ddd; height: 1px; border: 1px;; background-color: #ddd; height: 1px; border: 1px;">
+
+<div style="color:#666;">
+<p>To respond, reply to this email or visit <a href="https://meta.discourse.org/t/testing-default-email-replies/22638/3" style="text-decoration: none; font-weight: bold; color: #006699;; color:#666;">https://meta.discourse.org/t/testing-default-email-replies/22638/3</a> in your browser.</p>
+</div>
+<div style="color:#666;">
+<p>To unsubscribe from these emails, visit your <a href="https://meta.discourse.org/my/preferences" style="text-decoration: none; font-weight: bold; color: #006699;; color:#666;">user preferences</a>.</p>
+</div>
+</div>
+</div></blockquote></body></html>
+--Apple-Mail-B41C7F8E-3639-49B0-A5D5-440E125A7105--
diff --git a/spec/fixtures/emails/iphone_signature.eml b/spec/fixtures/emails/iphone_signature.eml
new file mode 100644
index 00000000000..d314ad1f1ea
--- /dev/null
+++ b/spec/fixtures/emails/iphone_signature.eml
@@ -0,0 +1,29 @@
+Delivered-To: test@mail.com
+Return-Path: <walter.white@googlemail.com>
+From: Walter White <walter.white@googlemail.com>
+Content-Type: multipart/alternative;
+ boundary=Apple-Mail-8E182EEF-9DBC-41DE-A593-DF2E5EBD3975
+Content-Transfer-Encoding: 7bit
+Mime-Version: 1.0 (1.0)
+Subject: Re: Signature in email replies!
+Date: Thu, 23 Oct 2014 14:43:49 +0530
+References: <1234@mail.gmail.com>
+In-Reply-To: <1234@mail.gmail.com>
+To: Arpit Jalan <test@mail.com>
+X-Mailer: iPhone Mail (12A405)
+
+
+--Apple-Mail-8E182EEF-9DBC-41DE-A593-DF2E5EBD3975
+Content-Type: text/plain;
+ charset=us-ascii
+Content-Transfer-Encoding: 7bit
+
+This post should not include signature.
+
+Sent from my iPhone
+
+> On 23-Oct-2014, at 9:45 am, Arpit Jalan <test@mail.com> wrote:
+>
+> Signature in email replies!
+
+--Apple-Mail-8E182EEF-9DBC-41DE-A593-DF2E5EBD3975
diff --git a/spec/fixtures/emails/multiple_destinations.eml b/spec/fixtures/emails/multiple_destinations.eml
new file mode 100644
index 00000000000..6d31bbf1974
--- /dev/null
+++ b/spec/fixtures/emails/multiple_destinations.eml
@@ -0,0 +1,40 @@
+Return-Path: <jake@adventuretime.ooo>
+Received: from iceking.adventuretime.ooo ([unix socket]) by iceking (Cyrus v2.2.13-Debian-2.2.13-19+squeeze3) with LMTPA; Thu, 13 Jun 2013 17:03:50 -0400
+Received: from mail-ie0-x234.google.com (mail-ie0-x234.google.com [IPv6:2607:f8b0:4001:c03::234]) by iceking.adventuretime.ooo (8.14.3/8.14.3/Debian-9.4) with ESMTP id r5DL3nFJ016967 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for <reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo>; Thu, 13 Jun 2013 17:03:50 -0400
+Received: by mail-ie0-f180.google.com with SMTP id f4so21977375iea.25 for <reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo>; Thu, 13 Jun 2013 14:03:48 -0700
+Received: by 10.0.0.1 with HTTP; Thu, 13 Jun 2013 14:03:48 -0700
+Date: Thu, 13 Jun 2013 17:03:48 -0400
+From: Jake the Dog <jake@adventuretime.ooo>
+To: finn@adventuretime.ooo, reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo
+Message-ID: <CADkmRc+rNGAGGbV2iE5p918UVy4UyJqVcXRO2=otppgzduJSg@mail.gmail.com>
+Subject: re: [Discourse Meta] eviltrout posted in 'Adventure Time Sux'
+Mime-Version: 1.0
+Content-Type: text/plain;
+ charset=ISO-8859-1
+Content-Transfer-Encoding: 7bit
+X-Sieve: CMU Sieve 2.2
+X-Received: by 10.0.0.1 with SMTP id n7mr11234144ipb.85.1371157428600; Thu,
+ 13 Jun 2013 14:03:48 -0700 (PDT)
+X-Scanned-By: MIMEDefang 2.69 on IPv6:2001:470:1d:165::1
+
+I could not disagree more. I am obviously biased but adventure time is the
+greatest show ever created. Everyone should watch it.
+
+- Jake out
+
+
+On Sun, Jun 9, 2013 at 1:39 PM, eviltrout via Discourse Meta
+<reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo> wrote:
+>
+>
+>
+> eviltrout posted in 'Adventure Time Sux' on Discourse Meta:
+>
+> ---
+> hey guys everyone knows adventure time sucks!
+>
+> ---
+> Please visit this link to respond: http://localhost:3000/t/adventure-time-sux/1234/3
+>
+> To unsubscribe from these emails, visit your [user preferences](http://localhost:3000/user_preferences).
+> \ No newline at end of file
diff --git a/spec/fixtures/emails/newlines.eml b/spec/fixtures/emails/newlines.eml
new file mode 100644
index 00000000000..cf03b9d18bc
--- /dev/null
+++ b/spec/fixtures/emails/newlines.eml
@@ -0,0 +1,84 @@
+In-Reply-To: <test@discourse-app.mail>
+Date: Wed, 8 Oct 2014 10:36:19 +0530
+Delivered-To: walter.white@googlemail.com
+Subject: Re: [Discourse] Welcome to Discourse
+From: Walter White <walter.white@googlemail.com>
+To: Discourse <mail@arpitjalan.com>
+Content-Type: multipart/alternative; boundary=bcaec554078cc3d0c10504e24661
+
+--bcaec554078cc3d0c10504e24661
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: quoted-printable
+
+This is my reply.
+It is my best reply.
+It will also be my *only* reply.
+
+On Wed, Oct 8, 2014 at 10:33 AM, ajalan <info@unconfigured.discourse.org>
+wrote:
+
+> ajalan
+> <http://mandrillapp.com/track/click/30081177/discourse.techapj.com?p=3Dey=
+JzIjoiMGM3a1pGT250VG5sb242RVNTdFdjS1FUSHdzIiwidiI6MSwicCI6IntcInVcIjozMDA4M=
+TE3NyxcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvZGlzY291cnNlLnRlY2hhcGouY29t=
+XFxcL3VzZXJzXFxcL2FqYWxhblwiLFwiaWRcIjpcImQxOWYxYjQ5NTdkODRkMGNhZWY1NDEzZGN=
+hODA4YTRhXCIsXCJ1cmxfaWRzXCI6W1wiNzA3MTNjNTg4MDI3YWQyM2RiM2QwOTVhOGQwYmY4ZT=
+YyMzNjYThiMFwiXX0ifQ>
+> October 8
+>
+> Awesome! Thank You! [image: +1]
+>
+> To respond, reply to this email or visit
+> http://discourse.techapj.com/t/welcome-to-discourse/8/2
+> <http://mandrillapp.com/track/click/30081177/discourse.techapj.com?p=3Dey=
+JzIjoibzNWaXFDRDdxSFNCbVRkUmdONlRJVW1ENU8wIiwidiI6MSwicCI6IntcInVcIjozMDA4M=
+TE3NyxcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvZGlzY291cnNlLnRlY2hhcGouY29t=
+XFxcL3RcXFwvd2VsY29tZS10by1kaXNjb3Vyc2VcXFwvOFxcXC8yXCIsXCJpZFwiOlwiZDE5ZjF=
+iNDk1N2Q4NGQwY2FlZjU0MTNkY2E4MDhhNGFcIixcInVybF9pZHNcIjpbXCIwYmFkNjE2NDJkNm=
+M2NzJhNGU0ZjYzMGU2ZDA5M2I3MzU3NzQ4MzYxXCJdfSJ9>
+> in your browser.
+> ------------------------------
+> Previous Replies system
+> <http://mandrillapp.com/track/click/30081177/discourse.techapj.com?p=3Dey=
+JzIjoicjFZQm8ySTJjUEtNclpvekZ5ZmFqYmdpTVFNIiwidiI6MSwicCI6IntcInVcIjozMDA4M=
+TE3NyxcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvZGlzY291cnNlLnRlY2hhcGouY29t=
+XFxcL3VzZXJzXFxcL3N5c3RlbVwiLFwiaWRcIjpcImQxOWYxYjQ5NTdkODRkMGNhZWY1NDEzZGN=
+hODA4YTRhXCIsXCJ1cmxfaWRzXCI6W1wiMTcxNWU2OTE1M2UzMjk4YmM2Y2NhMWEyM2E5N2ViMW=
+U5N2IwMWYyNFwiXX0ifQ>
+> October 8
+>
+> The first paragraph of this pinned topic will be visible as a welcome
+> message to all new visitors on your homepage. It's important!
+>
+> *Edit this* into a brief description of your community:
+>
+> - Who is it for?
+> - What can they find here?
+> - Why should they come here?
+> - Where can they read more (links, resources, etc)?
+>
+> You may want to close this topic via the wrench icon at the upper right,
+> so that replies don't pile up on an announcement.
+> ------------------------------
+>
+> To respond, reply to this email or visit
+> http://discourse.techapj.com/t/welcome-to-discourse/8/2
+> <http://mandrillapp.com/track/click/30081177/discourse.techapj.com?p=3Dey=
+JzIjoibzNWaXFDRDdxSFNCbVRkUmdONlRJVW1ENU8wIiwidiI6MSwicCI6IntcInVcIjozMDA4M=
+TE3NyxcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvZGlzY291cnNlLnRlY2hhcGouY29t=
+XFxcL3RcXFwvd2VsY29tZS10by1kaXNjb3Vyc2VcXFwvOFxcXC8yXCIsXCJpZFwiOlwiZDE5ZjF=
+iNDk1N2Q4NGQwY2FlZjU0MTNkY2E4MDhhNGFcIixcInVybF9pZHNcIjpbXCIwYmFkNjE2NDJkNm=
+M2NzJhNGU0ZjYzMGU2ZDA5M2I3MzU3NzQ4MzYxXCJdfSJ9>
+> in your browser.
+>
+> To unsubscribe from these emails, visit your user preferences
+> <http://mandrillapp.com/track/click/30081177/discourse.techapj.com?p=3Dey=
+JzIjoiaFdWSWtiRGIybjJOeWc0VHRrenAzbnhraU93IiwidiI6MSwicCI6IntcInVcIjozMDA4M=
+TE3NyxcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvZGlzY291cnNlLnRlY2hhcGouY29t=
+XFxcL215XFxcL3ByZWZlcmVuY2VzXCIsXCJpZFwiOlwiZDE5ZjFiNDk1N2Q4NGQwY2FlZjU0MTN=
+kY2E4MDhhNGFcIixcInVybF9pZHNcIjpbXCI0OTIyMmMyZDgyNzUwMmQyMGZjYzU4MTZkNjhmYT=
+k3NzFkY2YzZDllXCJdfSJ9>
+> .
+>
+
+--bcaec554078cc3d0c10504e24661
diff --git a/spec/fixtures/emails/no_content_reply.eml b/spec/fixtures/emails/no_content_reply.eml
new file mode 100644
index 00000000000..95eb2055ce6
--- /dev/null
+++ b/spec/fixtures/emails/no_content_reply.eml
@@ -0,0 +1,34 @@
+Return-Path: <jake@adventuretime.ooo>
+Received: from iceking.adventuretime.ooo ([unix socket]) by iceking (Cyrus v2.2.13-Debian-2.2.13-19+squeeze3) with LMTPA; Thu, 13 Jun 2013 17:03:50 -0400
+Received: from mail-ie0-x234.google.com (mail-ie0-x234.google.com [IPv6:2607:f8b0:4001:c03::234]) by iceking.adventuretime.ooo (8.14.3/8.14.3/Debian-9.4) with ESMTP id r5DL3nFJ016967 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for <reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo>; Thu, 13 Jun 2013 17:03:50 -0400
+Received: by mail-ie0-f180.google.com with SMTP id f4so21977375iea.25 for <reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo>; Thu, 13 Jun 2013 14:03:48 -0700
+Received: by 10.0.0.1 with HTTP; Thu, 13 Jun 2013 14:03:48 -0700
+Date: Thu, 13 Jun 2013 17:03:48 -0400
+From: Jake the Dog <jake@adventuretime.ooo>
+To: reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo
+Message-ID: <CADkmRc+rNGAGGbV2iE5p918UVy4UyJqVcXRO2=otppgzduJSg@mail.gmail.com>
+Subject: re: [Discourse Meta] eviltrout posted in 'Adventure Time Sux'
+Mime-Version: 1.0
+Content-Type: text/plain;
+ charset=ISO-8859-1
+Content-Transfer-Encoding: 7bit
+X-Sieve: CMU Sieve 2.2
+X-Received: by 10.0.0.1 with SMTP id n7mr11234144ipb.85.1371157428600; Thu,
+ 13 Jun 2013 14:03:48 -0700 (PDT)
+X-Scanned-By: MIMEDefang 2.69 on IPv6:2001:470:1d:165::1
+
+On Sun, Jun 9, 2013 at 1:39 PM, eviltrout via Discourse Meta
+<reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo> wrote:
+>
+>
+>
+> eviltrout posted in 'Adventure Time Sux' on Discourse Meta:
+>
+> ---
+> hey guys everyone knows adventure time sucks!
+>
+> ---
+> Please visit this link to respond: http://localhost:3000/t/adventure-time-sux/1234/3
+>
+> To unsubscribe from these emails, visit your [user preferences](http://localhost:3000/user_preferences).
+> \ No newline at end of file
diff --git a/spec/fixtures/emails/on_wrote.eml b/spec/fixtures/emails/on_wrote.eml
new file mode 100644
index 00000000000..feb59bd27bb
--- /dev/null
+++ b/spec/fixtures/emails/on_wrote.eml
@@ -0,0 +1,277 @@
+
+MIME-Version: 1.0
+Received: by 10.107.9.17 with HTTP; Tue, 9 Sep 2014 16:18:19 -0700 (PDT)
+In-Reply-To: <540f16d4c08d9_4a3f9ff6d61890391c@tiefighter4-meta.mail>
+References: <topic/18058@meta.discourse.org>
+ <540f16d4c08d9_4a3f9ff6d61890391c@tiefighter4-meta.mail>
+Date: Tue, 9 Sep 2014 16:18:19 -0700
+Delivered-To: kanepyork@gmail.com
+Message-ID: <CABeNrKXxfb8YJUWxO5L_oPTGrFsiZfQOpWudk+44Mh=yuUEHNQ@mail.gmail.com>
+Subject: Re: [Discourse Meta] Badge icons - where to find them?
+From: Kane York <jake@adventuretime.ooo>
+To: Discourse Meta <reply+8305e3604ae4d1485dc12b6af6a8446c@appmail.adventuretime.ooo>
+Content-Type: multipart/alternative; boundary=001a11c34c389e728f0502aa26a0
+
+--001a11c34c389e728f0502aa26a0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: quoted-printable
+
+Sure, all you need to do is frobnicate the foobar and you'll be all set!
+
+On Tue, Sep 9, 2014 at 8:03 AM, gordon_ryan <info@discourse.org> wrote:
+
+> gordon_ryan <https://meta.discourse.org/users/gordon_ryan>
+> September 9
+>
+> @riking <https://meta.discourse.org/users/riking>- willing to step by
+> step of the custom icon method for an admittedly ignorant admin? Seriousl=
+y
+> confused.
+>
+> Or anyone else who knows how to do this [image: smiley]
+>
+> To respond, reply to this email or visit
+> https://meta.discourse.org/t/badge-icons-where-to-find-them/18058/9 in
+> your browser.
+> ------------------------------
+> Previous Replies riking <https://meta.discourse.org/users/riking>
+> July 25
+>
+> Check out the "HTML Head" section in the "Content" tab of the admin panel=
+.
+> meglio <https://meta.discourse.org/users/meglio>
+> July 25
+>
+> How will it load the related custom font?
+> riking <https://meta.discourse.org/users/riking>
+> July 25
+>
+> Here's an example of the styles that FA applies. I'll use <i class=3D"fa
+> fa-heart"></i> as the example.
+>
+> .fa {
+> display: inline-block;
+> font-family: FontAwesome;
+> font-style: normal;
+> font-weight: normal;
+> line-height: 1;
+> -webkit-font-smoothing: antialiased;
+> -moz-osx-font-smoothing: grayscale;
+> }
+> .fa-heart:before {
+> content: "\f004";
+> }
+>
+> So you could do this in your site stylesheet:
+>
+> .fa-custom-burger:before {
+> content: "\01f354";
+> font-family: inherit;
+> }
+>
+> And get =F0=9F=8D=94 as your badge icon when you enter custom-burger.
+> ------------------------------
+>
+> To respond, reply to this email or visit
+> https://meta.discourse.org/t/badge-icons-where-to-find-them/18058/9 in
+> your browser.
+>
+> To unsubscribe from these emails, visit your user preferences
+> <https://meta.discourse.org/my/preferences>.
+>
+
+--001a11c34c389e728f0502aa26a0
+Content-Type: text/html; charset=UTF-8
+Content-Transfer-Encoding: quoted-printable
+
+<div dir=3D"ltr"><span style=3D"font-family:arial,sans-serif;font-size:13px=
+">Sure, all you need to do is frobnicate the foobar and you&#39;ll be all s=
+et!</span><br><div class=3D"gmail_extra"><br clear=3D"all"><div><br>=
+<br><div class=3D"gmail_quote">On Tue, Sep 9, 2014 at 8:03 AM, gordon_ryan =
+<span dir=3D"ltr">&lt;<a href=3D"mailto:info@discourse.org" target=3D"_blan=
+k">info@discourse.org</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_q=
+uote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1e=
+x"><div>
+
+
+<table style=3D"margin-bottom:25px;max-width:761px" cellspacing=3D"0" cellp=
+adding=3D"0" border=3D"0">
+ <tbody>
+ <tr>
+ <td style=3D"vertical-align:top;width:55px">
+ <img src=3D"https://meta-discourse.global.ssl.fastly.net/user_avata=
+r/meta.discourse.org/gordon_ryan/45/34017.png" title=3D"gordon_ryan" style=
+=3D"max-width:694px" width=3D"45" height=3D"45">
+ </td>
+ <td>
+ <a href=3D"https://meta.discourse.org/users/gordon_ryan" style=3D"f=
+ont-size:13px;font-family:&#39;lucida grande&#39;,tahoma,verdana,arial,sans=
+-serif;color:#3b5998;text-decoration:none;font-weight:bold;text-decoration:=
+none;font-weight:bold;color:#006699" target=3D"_blank">gordon_ryan</a><br>
+ <span style=3D"text-align:right;color:#999999;padding-right:5px;fon=
+t-family:&#39;lucida grande&#39;,tahoma,verdana,arial,sans-serif;font-size:=
+11px">September 9</span>
+ </td>
+ </tr>
+ <tr>
+ <td style=3D"padding-top:5px" colspan=3D"2">
+<p style=3D"margin-top:0;border:0"><a href=3D"https://meta.discourse.org/us=
+ers/riking" style=3D"text-decoration:none;font-weight:bold;color:#006699" t=
+arget=3D"_blank">@riking</a>- willing to step by step of the custom icon me=
+thod for an admittedly ignorant admin? Seriously confused.</p>
+
+<p style=3D"margin-top:0;border:0">Or anyone else who knows how to do this =
+<img src=3D"https://meta-discourse.global.ssl.fastly.net/plugins/emoji/imag=
+es/smiley.png" title=3D":smiley:" alt=3D"smiley" width=3D"20" height=3D"20"=
+></p>
+</td>
+ </tr>
+ </tbody>
+</table>
+
+
+ <div style=3D"color:#666">
+ <p>To respond, reply to this email or visit <a href=3D"https://meta.dis=
+course.org/t/badge-icons-where-to-find-them/18058/9" style=3D"color:#666;te=
+xt-decoration:none;font-weight:bold;color:#006699" target=3D"_blank">https:=
+//meta.discourse.org/t/badge-icons-where-to-find-them/18058/9</a> in your b=
+rowser.</p>
+ </div>
+ <hr style=3D"background-color:#ddd;min-height:1px;border:1px;background-c=
+olor:#ddd;min-height:1px;border:1px">
+ <h4>Previous Replies</h4>
+
+ <table style=3D"margin-bottom:25px;max-width:761px" cellspacing=3D"0" cel=
+lpadding=3D"0" border=3D"0">
+ <tbody>
+ <tr>
+ <td style=3D"vertical-align:top;width:55px">
+ <img src=3D"https://meta-discourse.global.ssl.fastly.net/user_avata=
+r/meta.discourse.org/riking/45/9779.png" title=3D"riking" style=3D"max-widt=
+h:694px" width=3D"45" height=3D"45">
+ </td>
+ <td>
+ <a href=3D"https://meta.discourse.org/users/riking" style=3D"font-s=
+ize:13px;font-family:&#39;lucida grande&#39;,tahoma,verdana,arial,sans-seri=
+f;color:#3b5998;text-decoration:none;font-weight:bold;text-decoration:none;=
+font-weight:bold;color:#006699" target=3D"_blank">riking</a><br>
+ <span style=3D"text-align:right;color:#999999;padding-right:5px;fon=
+t-family:&#39;lucida grande&#39;,tahoma,verdana,arial,sans-serif;font-size:=
+11px">July 25</span>
+ </td>
+ </tr>
+ <tr>
+ <td style=3D"padding-top:5px" colspan=3D"2"><p style=3D"margin-top:0;=
+border:0">Check out the &quot;HTML Head&quot; section in the &quot;Content&=
+quot; tab of the admin panel.</p></td>
+ </tr>
+ </tbody>
+</table>
+
+ <table style=3D"margin-bottom:25px;max-width:761px" cellspacing=3D"0" cel=
+lpadding=3D"0" border=3D"0">
+ <tbody>
+ <tr>
+ <td style=3D"vertical-align:top;width:55px">
+ <img src=3D"https://meta-discourse.global.ssl.fastly.net/user_avata=
+r/meta.discourse.org/meglio/45/33480.png" title=3D"meglio" style=3D"max-wid=
+th:694px" width=3D"45" height=3D"45">
+ </td>
+ <td>
+ <a href=3D"https://meta.discourse.org/users/meglio" style=3D"font-s=
+ize:13px;font-family:&#39;lucida grande&#39;,tahoma,verdana,arial,sans-seri=
+f;color:#3b5998;text-decoration:none;font-weight:bold;text-decoration:none;=
+font-weight:bold;color:#006699" target=3D"_blank">meglio</a><br>
+ <span style=3D"text-align:right;color:#999999;padding-right:5px;fon=
+t-family:&#39;lucida grande&#39;,tahoma,verdana,arial,sans-serif;font-size:=
+11px">July 25</span>
+ </td>
+ </tr>
+ <tr>
+ <td style=3D"padding-top:5px" colspan=3D"2"><p style=3D"margin-top:0;=
+border:0">How will it load the related custom font?</p></td>
+ </tr>
+ </tbody>
+</table>
+
+ <table style=3D"margin-bottom:25px;max-width:761px" cellspacing=3D"0" cel=
+lpadding=3D"0" border=3D"0">
+ <tbody>
+ <tr>
+ <td style=3D"vertical-align:top;width:55px">
+ <img src=3D"https://meta-discourse.global.ssl.fastly.net/user_avata=
+r/meta.discourse.org/riking/45/9779.png" title=3D"riking" style=3D"max-widt=
+h:694px" width=3D"45" height=3D"45">
+ </td>
+ <td>
+ <a href=3D"https://meta.discourse.org/users/riking" style=3D"font-s=
+ize:13px;font-family:&#39;lucida grande&#39;,tahoma,verdana,arial,sans-seri=
+f;color:#3b5998;text-decoration:none;font-weight:bold;text-decoration:none;=
+font-weight:bold;color:#006699" target=3D"_blank">riking</a><br>
+ <span style=3D"text-align:right;color:#999999;padding-right:5px;fon=
+t-family:&#39;lucida grande&#39;,tahoma,verdana,arial,sans-serif;font-size:=
+11px">July 25</span>
+ </td>
+ </tr>
+ <tr>
+ <td style=3D"padding-top:5px" colspan=3D"2">
+<p style=3D"margin-top:0;border:0">Here&#39;s an example of the styles that=
+ FA applies. I&#39;ll use <code style=3D"background-color:#f1f1ff;padding:2=
+px 5px">&lt;i class=3D&quot;fa fa-heart&quot;&gt;&lt;/i&gt;</code> as the e=
+xample.</p>
+
+<p style=3D"margin-top:0;border:0"></p>
+<pre style=3D"word-wrap:break-word;max-width:694px"><code style=3D"backgrou=
+nd-color:#f1f1ff;padding:2px 5px;display:block;background-color:#f1f1ff;pad=
+ding:5px">.fa {
+ display: inline-block;
+ font-family: FontAwesome;
+ font-style: normal;
+ font-weight: normal;
+ line-height: 1;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+}
+.fa-heart:before {
+ content: &quot;\f004&quot;;
+}</code></pre>
+
+<p style=3D"margin-top:0;border:0">So you could do this in your site styles=
+heet:</p>
+
+<p style=3D"margin-top:0;border:0"></p>
+<pre style=3D"word-wrap:break-word;max-width:694px"><code style=3D"backgrou=
+nd-color:#f1f1ff;padding:2px 5px;display:block;background-color:#f1f1ff;pad=
+ding:5px">.fa-custom-burger:before {
+ content: &quot;\01f354&quot;;
+ font-family: inherit;
+}</code></pre>
+
+<p style=3D"margin-top:0;border:0">And get =F0=9F=8D=94 as your badge icon =
+when you enter <code style=3D"background-color:#f1f1ff;padding:2px 5px">cus=
+tom-burger</code>.</p>
+</td>
+ </tr>
+ </tbody>
+</table>
+
+
+<hr style=3D"background-color:#ddd;min-height:1px;border:1px;background-col=
+or:#ddd;min-height:1px;border:1px">
+
+<div style=3D"color:#666">
+<p>To respond, reply to this email or visit <a href=3D"https://meta.discour=
+se.org/t/badge-icons-where-to-find-them/18058/9" style=3D"color:#666;text-d=
+ecoration:none;font-weight:bold;color:#006699" target=3D"_blank">https://me=
+ta.discourse.org/t/badge-icons-where-to-find-them/18058/9</a> in your brows=
+er.</p>
+</div>
+<div style=3D"color:#666">
+<p>To unsubscribe from these emails, visit your <a href=3D"https://meta.dis=
+course.org/my/preferences" style=3D"color:#666;text-decoration:none;font-we=
+ight:bold;color:#006699" target=3D"_blank">user preferences</a>.</p>
+</div>
+</div>
+</blockquote></div><br></div></div>
+
+--001a11c34c389e728f0502aa26a0-- \ No newline at end of file
diff --git a/spec/fixtures/emails/outlook.eml b/spec/fixtures/emails/outlook.eml
new file mode 100644
index 00000000000..fb1f590a30e
--- /dev/null
+++ b/spec/fixtures/emails/outlook.eml
@@ -0,0 +1,188 @@
+
+MIME-Version: 1.0
+Received: by 10.25.161.144 with HTTP; Tue, 7 Oct 2014 22:17:17 -0700 (PDT)
+X-Originating-IP: [117.207.85.84]
+In-Reply-To: <5434c8b52bb3a_623ff09fec70f049749@discourse-app.mail>
+References: <topic/35@discourse.techapj.com>
+ <5434c8b52bb3a_623ff09fec70f049749@discourse-app.mail>
+Date: Wed, 8 Oct 2014 10:47:17 +0530
+Delivered-To: arpit@techapj.com
+Message-ID: <CAOJeqne=SJ_LwN4sb-0Y95ejc2OpreVhdmcPn0TnmwSvTCYzzQ@mail.gmail.com>
+Subject: Re: [Discourse] [Meta] Welcome to techAPJ's Discourse!
+From: Arpit Jalan <arpit@techapj.com>
+To: Discourse <mail+e1c7f2a380e33840aeb654f075490bad@arpitjalan.com>Accept-Language: en-US
+Content-Language: en-US
+X-MS-Has-Attach:
+X-MS-TNEF-Correlator:
+x-originating-ip: [134.68.31.227]
+Content-Type: multipart/alternative;
+ boundary="_000_B0DFE1BEB3739743BC9B639D0E6BC8FF217A6341IUMSSGMBX104ads_"
+MIME-Version: 1.0
+
+--_000_B0DFE1BEB3739743BC9B639D0E6BC8FF217A6341IUMSSGMBX104ads_
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: base64
+
+TWljcm9zb2Z0IE91dGxvb2sgMjAxMA0KDQpGcm9tOiBtaWNoYWVsIFttYWlsdG86dGFsa0BvcGVu
+bXJzLm9yZ10NClNlbnQ6IE1vbmRheSwgT2N0b2JlciAxMywgMjAxNCA5OjM4IEFNDQpUbzogUG93
+ZXIsIENocmlzDQpTdWJqZWN0OiBbUE1dIFlvdXIgcG9zdCBpbiAiQnVyZ2VyaGF1czogTmV3IHJl
+c3RhdXJhbnQgLyBsdW5jaCB2ZW51ZSINCg0KDQptaWNoYWVsPGh0dHA6Ly9jbC5vcGVubXJzLm9y
+Zy90cmFjay9jbGljay8zMDAzOTkwNS90YWxrLm9wZW5tcnMub3JnP3A9ZXlKeklqb2liR2xaYTFW
+MGVYaENZMDFNUlRGc1VESm1ZelZRTTBabGVqRTRJaXdpZGlJNk1Td2ljQ0k2SW50Y0luVmNJam96
+TURBek9Ua3dOU3hjSW5aY0lqb3hMRndpZFhKc1hDSTZYQ0pvZEhSd2N6cGNYRnd2WEZ4Y0wzUmhi
+R3N1YjNCbGJtMXljeTV2Y21kY1hGd3ZkWE5sY25OY1hGd3ZiV2xqYUdGbGJGd2lMRndpYVdSY0lq
+cGNJbVExWW1Nd04yTmtORFJqWkRRNE1HTTRZVGcyTXpsalpXSTFOemd6WW1ZMlhDSXNYQ0oxY214
+ZmFXUnpYQ0k2VzF3aVlqaGtPRGcxTWprNU56ZG1aalkxWldZeU5URTNPV1JpTkdZeU1XSTNOekZq
+TnpoalpqaGtPRndpWFgwaWZRPg0KT2N0b2JlciAxMw0KDQpodHRwczovL3RhbGsub3Blbm1ycy5v
+cmcvdC9idXJnZXJoYXVzLW5ldy1yZXN0YXVyY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3ZjSEpsWm1WeVpXNWpaWE5jSWl4Y0ltbGtYQ0k2WENKa05X
+SmpNRGRqWkRRMFkyUTBPREJqT0dFNE5qTTVZMlZpTlRjNE0ySm1ObHdpTEZ3aWRYSnNYMmxrYzF3
+aU9sdGNJbUk0TVdVd1pqQTFORFk1TkRNME56Z3lNMkZtTWpBMk5qRmpaamMzWkdOaU4yTmhZemRt
+TWpKY0lsMTlJbjAiPg0KPGI+PHNwYW4gc3R5bGU9ImNvbG9yOiMwMDY2OTk7dGV4dC1kZWNvcmF0
+aW9uOm5vbmUiPnVzZXIgcHJlZmVyZW5jZXM8L3NwYW4+PC9iPjwvYT4uPG86cD48L286cD48L3Nw
+YW4+PC9wPg0KPC9kaXY+DQo8L2Rpdj4NCjxwIGNsYXNzPSJNc29Ob3JtYWwiPjxpbWcgYm9yZGVy
+PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBpZD0iX3gwMDAwX2kxMDI2IiBzcmM9Imh0dHA6Ly9j
+bC5vcGVubXJzLm9yZy90cmFjay9vcGVuLnBocD91PTMwMDM5OTA1JmFtcDtpZD1kNWJjMDdjZDQ0
+Y2Q0ODBjOGE4NjM5Y2ViNTc4M2JmNiI+PG86cD48L286cD48L3A+DQo8L2Rpdj4NCjwvYm9keT4N
+CjwvaHRtbD4NCg==
+
+--_000_B0DFE1BEB3739743BC9B639D0E6BC8FF217A6341IUMSSGMBX104ads_--
diff --git a/spec/fixtures/emails/paragraphs.cooked b/spec/fixtures/emails/paragraphs.cooked
new file mode 100644
index 00000000000..da83260e09c
--- /dev/null
+++ b/spec/fixtures/emails/paragraphs.cooked
@@ -0,0 +1,7 @@
+<p>Is there any reason the <em>old</em> candy can't be be kept in silos while the new candy
+is imported into <em>new</em> silos?</p>
+
+<p>The thing about candy is it stays delicious for a long time -- we can just keep
+it there without worrying about it too much, imo.</p>
+
+<p>Thanks for listening.</p> \ No newline at end of file
diff --git a/spec/fixtures/emails/paragraphs.eml b/spec/fixtures/emails/paragraphs.eml
new file mode 100644
index 00000000000..2d5b5283f7e
--- /dev/null
+++ b/spec/fixtures/emails/paragraphs.eml
@@ -0,0 +1,42 @@
+Return-Path: <jake@adventuretime.ooo>
+Received: from iceking.adventuretime.ooo ([unix socket]) by iceking (Cyrus v2.2.13-Debian-2.2.13-19+squeeze3) with LMTPA; Thu, 13 Jun 2013 17:03:50 -0400
+Received: from mail-ie0-x234.google.com (mail-ie0-x234.google.com [IPv6:2607:f8b0:4001:c03::234]) by iceking.adventuretime.ooo (8.14.3/8.14.3/Debian-9.4) with ESMTP id r5DL3nFJ016967 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for <reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo>; Thu, 13 Jun 2013 17:03:50 -0400
+Received: by mail-ie0-f180.google.com with SMTP id f4so21977375iea.25 for <reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo>; Thu, 13 Jun 2013 14:03:48 -0700
+Received: by 10.0.0.1 with HTTP; Thu, 13 Jun 2013 14:03:48 -0700
+Date: Thu, 13 Jun 2013 17:03:48 -0400
+From: Jake the Dog <jake@adventuretime.ooo>
+To: reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo
+Message-ID: <CADkmRc+rNGAGGbV2iE5p918UVy4UyJqVcXRO2=otppgzduJSg@mail.gmail.com>
+Subject: re: [Discourse Meta] eviltrout posted in 'Adventure Time Sux'
+Mime-Version: 1.0
+Content-Type: text/plain;
+ charset=ISO-8859-1
+Content-Transfer-Encoding: 7bit
+X-Sieve: CMU Sieve 2.2
+X-Received: by 10.0.0.1 with SMTP id n7mr11234144ipb.85.1371157428600; Thu,
+ 13 Jun 2013 14:03:48 -0700 (PDT)
+X-Scanned-By: MIMEDefang 2.69 on IPv6:2001:470:1d:165::1
+
+Is there any reason the *old* candy can't be be kept in silos while the new candy
+is imported into *new* silos?
+
+The thing about candy is it stays delicious for a long time -- we can just keep
+it there without worrying about it too much, imo.
+
+Thanks for listening.
+
+On Sun, Jun 9, 2013 at 1:39 PM, eviltrout via Discourse Meta
+<reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo> wrote:
+>
+>
+>
+> eviltrout posted in 'Adventure Time Sux' on Discourse Meta:
+>
+> ---
+> hey guys everyone knows adventure time sucks!
+>
+> ---
+> Please visit this link to respond: http://localhost:3000/t/adventure-time-sux/1234/3
+>
+> To unsubscribe from these emails, visit your [user preferences](http://localhost:3000/user_preferences).
+>
diff --git a/spec/fixtures/emails/previous.eml b/spec/fixtures/emails/previous.eml
new file mode 100644
index 00000000000..24ac5a63deb
--- /dev/null
+++ b/spec/fixtures/emails/previous.eml
@@ -0,0 +1,38 @@
+
+Delivered-To: discourse-reply+cd480e301683c9902891f15968bf07a5@discourse.org
+Received: by 10.194.216.104 with SMTP id op8csp80593wjc;
+ Wed, 24 Jul 2013 07:59:14 -0700 (PDT)
+Return-Path: <walter.white@googlemail.com>
+References: <topic/5043@discourse.org> <51efeb9b36c34_66dc2dfce6811866@discourse.mail>
+From: Walter White <walter.white@googlemail.com>
+In-Reply-To: <51efeb9b36c34_66dc2dfce6811866@discourse.mail>
+Mime-Version: 1.0 (1.0)
+Date: Wed, 24 Jul 2013 15:59:10 +0100
+Message-ID: <4597127794206131679@unknownmsgid>
+Subject: Re: [Discourse] new reply to your post in 'Crystal Blue'
+To: walter via Discourse <reply+cd480e301683c9902891f15968bf07a5@appmail.adventuretime.ooo>
+Content-Type: multipart/alternative; boundary=001a11c20edc15a39304e2432790
+
+This will not include the previous discussion that is present in this email.
+ ------------------------------
+Previous discussion
+skylerwhite<http://discourse.org/users/skylerwhite> July 24
+
+This is a reply.
+ fring <http://discourse.org/users/fring> July 24
+
+This is an older reply.
+ hank_schrader <http://discourse.org/users/hank_schrader> July 24
+
+Of course another reply here.
+ walterwhite <http://discourse.org/users/walterwhite> July 24
+
+ ------------------------------
+
+To respond, reply to this email or visit
+http://discourse.org/t/crystal-blue/5043/10in
+your browser.
+
+To unsubscribe from these emails, visit your user
+preferences<http://discourse.org/user_preferences>
+.
diff --git a/spec/fixtures/emails/previous_replies.eml b/spec/fixtures/emails/previous_replies.eml
new file mode 100644
index 00000000000..3fd74482c07
--- /dev/null
+++ b/spec/fixtures/emails/previous_replies.eml
@@ -0,0 +1,180 @@
+Delivered-To: reply@discourse.org
+MIME-Version: 1.0
+In-Reply-To: <topic/22638/86406@meta.discourse.org>
+References: <topic/22638@meta.discourse.org>
+ <topic/22638/86406@meta.discourse.org>
+Date: Fri, 28 Nov 2014 12:55:32 -0800
+Subject: Re: [Discourse Meta] [Lounge] Testing default email replies
+From: Walter White <walter.white@googlemail.com>
+To: Discourse Meta <reply@discourse.org>
+Content-Type: multipart/alternative; boundary=001a1137c9285318bb0508f17bc5
+
+--001a1137c9285318bb0508f17bc5
+Content-Type: text/plain; charset=UTF-8
+
+### this is a reply from iOS Gmail app
+
+The quick brown fox jumps over the lazy dog. The quick brown fox jumps over
+the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown
+fox jumps over the lazy dog. The quick brown fox jumps over the lazy
+dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps
+over the lazy dog.
+
+This is **bold** text in Markdown.
+
+This is a link to http://example.com
+
+On Friday, November 28, 2014, Arpit Jalan <info@discourse.org> wrote:
+
+> techAPJ <https://meta.discourse.org/users/techapj>
+> November 28
+>
+> Test reply.
+>
+> First paragraph.
+>
+> Second paragraph.
+>
+> To respond, reply to this email or visit
+> https://meta.discourse.org/t/testing-default-email-replies/22638/3 in
+> your browser.
+> ------------------------------
+> Previous Replies codinghorror
+> <https://meta.discourse.org/users/codinghorror>
+> November 28
+>
+> We're testing the latest GitHub email processing library which we are
+> integrating now.
+>
+> https://github.com/github/email_reply_parser
+>
+> Go ahead and reply to this topic and I'll reply from various email clients
+> for testing.
+> ------------------------------
+>
+> To respond, reply to this email or visit
+> https://meta.discourse.org/t/testing-default-email-replies/22638/3 in
+> your browser.
+>
+> To unsubscribe from these emails, visit your user preferences
+> <https://meta.discourse.org/my/preferences>.
+>
+
+--001a1137c9285318bb0508f17bc5
+Content-Type: text/html; charset=UTF-8
+Content-Transfer-Encoding: quoted-printable
+
+### this is a reply from iOS Gmail app<div><br></div><div>The quick brown f=
+ox jumps over the lazy dog.=C2=A0<font><span style=3D"background-color:rgba=
+(255,255,255,0)">The quick brown fox jumps over the lazy dog.=C2=A0The quic=
+k brown fox jumps over the lazy dog.=C2=A0The quick brown fox jumps over th=
+e lazy dog.=C2=A0The quick brown fox jumps over the lazy dog.=C2=A0The quic=
+k brown fox jumps over the lazy dog.=C2=A0The quick brown fox jumps over th=
+e lazy dog.=C2=A0</span></font></div><div><font><span style><br></span></fo=
+nt></div><div><font><span style>This is **bold** text in Markdown.</span></=
+font></div><div><font><span style><br></span></font></div><div><font><span =
+style>This is a link to <a href=3D"http://example.com">http://example.com</=
+a><br></span></font><br>On Friday, November 28, 2014, Arpit Jalan &lt;<a hr=
+ef=3D"mailto:info@discourse.org">info@discourse.org</a>&gt; wrote:<br><bloc=
+kquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #cc=
+c solid;padding-left:1ex"><div>
+
+<table style=3D"margin-bottom:25px" cellspacing=3D"0" cellpadding=3D"0" bor=
+der=3D"0">
+ <tbody>
+ <tr>
+ <td style=3D"vertical-align:top;width:55px">
+ <img src=3D"https://meta-discourse.global.ssl.fastly.net/user_avata=
+r/meta.discourse.org/techapj/45/3281.png" title=3D"techAPJ" style=3D"max-wi=
+dth:100%" width=3D"45" height=3D"45">
+ </td>
+ <td>
+ <a href=3D"https://meta.discourse.org/users/techapj" style=3D"text-=
+decoration:none;font-weight:bold;color:#006699;font-size:13px;font-family:&=
+#39;lucida grande&#39;,tahoma,verdana,arial,sans-serif;color:#3b5998;text-d=
+ecoration:none;font-weight:bold" target=3D"_blank">techAPJ</a><br>
+ <span style=3D"text-align:right;color:#999999;padding-right:5px;fon=
+t-family:&#39;lucida grande&#39;,tahoma,verdana,arial,sans-serif;font-size:=
+11px">November 28</span>
+ </td>
+ </tr>
+ <tr>
+ <td style=3D"padding-top:5px" colspan=3D"2">
+<p style=3D"margin-top:0;border:0">Test reply.</p>
+
+<p style=3D"margin-top:0;border:0">First paragraph.</p>
+
+<p style=3D"margin-top:0;border:0">Second paragraph.</p>
+</td>
+ </tr>
+ </tbody>
+</table>
+
+
+ <div style=3D"color:#666">
+ <p>To respond, reply to this email or visit <a href=3D"https://meta.dis=
+course.org/t/testing-default-email-replies/22638/3" style=3D"text-decoratio=
+n:none;font-weight:bold;color:#006699;color:#666" target=3D"_blank">https:/=
+/meta.discourse.org/t/testing-default-email-replies/22638/3</a> in your bro=
+wser.</p>
+ </div>
+ <hr style=3D"background-color:#ddd;min-height:1px;border:1px;background-c=
+olor:#ddd;min-height:1px;border:1px">
+ <h4>Previous Replies</h4>
+
+ <table style=3D"margin-bottom:25px" cellspacing=3D"0" cellpadding=3D"0" b=
+order=3D"0">
+ <tbody>
+ <tr>
+ <td style=3D"vertical-align:top;width:55px">
+ <img src=3D"https://meta-discourse.global.ssl.fastly.net/user_avata=
+r/meta.discourse.org/codinghorror/45/5297.png" title=3D"codinghorror" style=
+=3D"max-width:100%" width=3D"45" height=3D"45">
+ </td>
+ <td>
+ <a href=3D"https://meta.discourse.org/users/codinghorror" style=3D"=
+text-decoration:none;font-weight:bold;color:#006699;font-size:13px;font-fam=
+ily:&#39;lucida grande&#39;,tahoma,verdana,arial,sans-serif;color:#3b5998;t=
+ext-decoration:none;font-weight:bold" target=3D"_blank">codinghorror</a><br=
+>
+ <span style=3D"text-align:right;color:#999999;padding-right:5px;fon=
+t-family:&#39;lucida grande&#39;,tahoma,verdana,arial,sans-serif;font-size:=
+11px">November 28</span>
+ </td>
+ </tr>
+ <tr>
+ <td style=3D"padding-top:5px" colspan=3D"2">
+<p style=3D"margin-top:0;border:0">We&#39;re testing the latest GitHub emai=
+l processing library which we are integrating now.</p>
+
+<p style=3D"margin-top:0;border:0"><a href=3D"https://github.com/github/ema=
+il_reply_parser" style=3D"text-decoration:none;font-weight:bold;color:#0066=
+99" target=3D"_blank">https://github.com/github/email_reply_parser</a></p>
+
+<p style=3D"margin-top:0;border:0">Go ahead and reply to this topic and I&#=
+39;ll reply from various email clients for testing.</p>
+</td>
+ </tr>
+ </tbody>
+</table>
+
+
+<hr style=3D"background-color:#ddd;min-height:1px;border:1px;background-col=
+or:#ddd;min-height:1px;border:1px">
+
+<div style=3D"color:#666">
+<p>To respond, reply to this email or visit <a href=3D"https://meta.discour=
+se.org/t/testing-default-email-replies/22638/3" style=3D"text-decoration:no=
+ne;font-weight:bold;color:#006699;color:#666" target=3D"_blank">https://met=
+a.discourse.org/t/testing-default-email-replies/22638/3</a> in your browser=
+.</p>
+</div>
+<div style=3D"color:#666">
+<p>To unsubscribe from these emails, visit your <a href=3D"https://meta.dis=
+course.org/my/preferences" style=3D"text-decoration:none;font-weight:bold;c=
+olor:#006699;color:#666" target=3D"_blank">user preferences</a>.</p>
+</div>
+</div>
+</blockquote></div>
+
+--001a1137c9285318bb0508f17bc5--
diff --git a/spec/fixtures/emails/too_many_mentions.eml b/spec/fixtures/emails/too_many_mentions.eml
new file mode 100644
index 00000000000..9cc7b75c94f
--- /dev/null
+++ b/spec/fixtures/emails/too_many_mentions.eml
@@ -0,0 +1,31 @@
+Return-Path: <jake@adventuretime.ooo>
+Received: from iceking.adventuretime.ooo ([unix socket]) by iceking (Cyrus v2.2.13-Debian-2.2.13-19+squeeze3) with LMTPA; Thu, 13 Jun 2013 17:03:50 -0400
+Received: from mail-ie0-x234.google.com (mail-ie0-x234.google.com [IPv6:2607:f8b0:4001:c03::234]) by iceking.adventuretime.ooo (8.14.3/8.14.3/Debian-9.4) with ESMTP id r5DL3nFJ016967 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for <reply+59d8df8370b7e95c5a49fbf86aeb2c93@discourse.example.com>; Thu, 13 Jun 2013 17:03:50 -0400
+Received: by mail-ie0-f180.google.com with SMTP id f4so21977375iea.25 for <reply+59d8df8370b7e95c5a49fbf86aeb2c93@discourse.example.com>; Thu, 13 Jun 2013 14:03:48 -0700
+Received: by 10.0.0.1 with HTTP; Thu, 13 Jun 2013 14:03:48 -0700
+Date: Thu, 13 Jun 2013 17:03:48 -0400
+From: Jake the Dog <jake@adventuretime.ooo>
+To: reply+636ca428858779856c226bb145ef4fad@appmail.adventuretime.ooo
+Message-ID: <CADkmRc+rNGAGGbV2iE5p918UVy4UyJqVcXRO2=otppgzduJSg@mail.gmail.com>
+Subject: re: [Discourse Meta] eviltrout posted in 'Adventure Time Sux'
+Mime-Version: 1.0
+Content-Type: text/plain;
+ charset=ISO-8859-1
+Content-Transfer-Encoding: 7bit
+X-Sieve: CMU Sieve 2.2
+X-Received: by 10.0.0.1 with SMTP id n7mr11234144ipb.85.1371157428600; Thu,
+ 13 Jun 2013 14:03:48 -0700 (PDT)
+X-Scanned-By: MIMEDefang 2.69 on IPv6:2001:470:1d:165::1
+
+
+@user1
+@user2
+@user3
+@user4
+@user5
+@user6
+@user7
+@user8
+@user9
+@user10
+@user11 \ No newline at end of file
diff --git a/spec/fixtures/emails/too_short.eml b/spec/fixtures/emails/too_short.eml
new file mode 100644
index 00000000000..54fed0f98c5
--- /dev/null
+++ b/spec/fixtures/emails/too_short.eml
@@ -0,0 +1,21 @@
+Return-Path: <jake@adventuretime.ooo>
+Received: from iceking.adventuretime.ooo ([unix socket]) by iceking (Cyrus v2.2.13-Debian-2.2.13-19+squeeze3) with LMTPA; Thu, 13 Jun 2013 17:03:50 -0400
+Received: from mail-ie0-x234.google.com (mail-ie0-x234.google.com [IPv6:2607:f8b0:4001:c03::234]) by iceking.adventuretime.ooo (8.14.3/8.14.3/Debian-9.4) with ESMTP id r5DL3nFJ016967 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for <reply+59d8df8370b7e95c5a49fbf86aeb2c93@discourse.example.com>; Thu, 13 Jun 2013 17:03:50 -0400
+Received: by mail-ie0-f180.google.com with SMTP id f4so21977375iea.25 for <reply+59d8df8370b7e95c5a49fbf86aeb2c93@discourse.example.com>; Thu, 13 Jun 2013 14:03:48 -0700
+Received: by 10.0.0.1 with HTTP; Thu, 13 Jun 2013 14:03:48 -0700
+Date: Thu, 13 Jun 2013 17:03:48 -0400
+From: Jake the Dog <FROM>
+To: TO
+Message-ID: <CADkmRc+rNGAGGbV2iE5p918UVy4UyJqVcXRO2=otppgzduJSg@mail.gmail.com>
+Subject: SUBJECT
+Mime-Version: 1.0
+Content-Type: text/plain;
+ charset=ISO-8859-1
+Content-Transfer-Encoding: 7bit
+X-Sieve: CMU Sieve 2.2
+X-Received: by 10.0.0.1 with SMTP id n7mr11234144ipb.85.1371157428600; Thu,
+ 13 Jun 2013 14:03:48 -0700 (PDT)
+X-Scanned-By: MIMEDefang 2.69 on IPv6:2001:470:1d:165::1
+
+
++1 \ No newline at end of file
diff --git a/spec/fixtures/emails/valid_incoming.cooked b/spec/fixtures/emails/valid_incoming.cooked
new file mode 100644
index 00000000000..2bf35825373
--- /dev/null
+++ b/spec/fixtures/emails/valid_incoming.cooked
@@ -0,0 +1,5 @@
+<p>Hey folks,</p>
+
+<p>I was thinking. Wouldn't it be great if we could post topics via email? Yes it would!</p>
+
+<p>Jakie</p>
diff --git a/spec/fixtures/emails/valid_incoming.eml b/spec/fixtures/emails/valid_incoming.eml
new file mode 100644
index 00000000000..5e8db53319e
--- /dev/null
+++ b/spec/fixtures/emails/valid_incoming.eml
@@ -0,0 +1,25 @@
+Return-Path: <FROM>
+Received: from iceking.adventuretime.ooo ([unix socket]) by iceking (Cyrus v2.2.13-Debian-2.2.13-19+squeeze3) with LMTPA; Thu, 13 Jun 2013 17:03:50 -0400
+Received: from mail-ie0-x234.google.com (mail-ie0-x234.google.com [IPv6:2607:f8b0:4001:c03::234]) by iceking.adventuretime.ooo (8.14.3/8.14.3/Debian-9.4) with ESMTP id r5DL3nFJ016967 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for <TO>; Thu, 13 Jun 2013 17:03:50 -0400
+Received: by mail-ie0-f180.google.com with SMTP id f4so21977375iea.25 for <TO>; Thu, 13 Jun 2013 14:03:48 -0700
+Received: by 10.0.0.1 with HTTP; Thu, 13 Jun 2013 14:03:48 -0700
+Date: Thu, 13 Jun 2013 17:03:48 -0400
+From: Jake the Dog <FROM>
+To: <TO>
+Message-ID: <CADkmRc+rNGAGGbV2iE5p918UVy4UyJqVcXRO2=otppgzduJSg@mail.gmail.com>
+Subject: We should have a post-by-email-feature.
+Mime-Version: 1.0
+Content-Type: text/plain;
+ charset=ISO-8859-1
+Content-Transfer-Encoding: 7bit
+X-Sieve: CMU Sieve 2.2
+X-Received: by 10.0.0.1 with SMTP id n7mr11234144ipb.85.1371157428600; Thu,
+ 13 Jun 2013 14:03:48 -0700 (PDT)
+X-Scanned-By: MIMEDefang 2.69 on IPv6:2001:470:1d:165::1
+
+Hey folks,
+
+I was thinking. Wouldn't it be great if we could post topics via email? Yes it would!
+
+Jakie
+
diff --git a/spec/fixtures/emails/valid_reply.cooked b/spec/fixtures/emails/valid_reply.cooked
new file mode 100644
index 00000000000..4bce79ad12a
--- /dev/null
+++ b/spec/fixtures/emails/valid_reply.cooked
@@ -0,0 +1,4 @@
+<p>I could not disagree more. I am obviously biased but adventure time is the
+greatest show ever created. Everyone should watch it.</p>
+
+<ul><li>Jake out</li></ul>
diff --git a/spec/fixtures/emails/valid_reply.eml b/spec/fixtures/emails/valid_reply.eml
new file mode 100644
index 00000000000..1e696389954
--- /dev/null
+++ b/spec/fixtures/emails/valid_reply.eml
@@ -0,0 +1,40 @@
+Return-Path: <jake@adventuretime.ooo>
+Received: from iceking.adventuretime.ooo ([unix socket]) by iceking (Cyrus v2.2.13-Debian-2.2.13-19+squeeze3) with LMTPA; Thu, 13 Jun 2013 17:03:50 -0400
+Received: from mail-ie0-x234.google.com (mail-ie0-x234.google.com [IPv6:2607:f8b0:4001:c03::234]) by iceking.adventuretime.ooo (8.14.3/8.14.3/Debian-9.4) with ESMTP id r5DL3nFJ016967 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for <reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo>; Thu, 13 Jun 2013 17:03:50 -0400
+Received: by mail-ie0-f180.google.com with SMTP id f4so21977375iea.25 for <reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo>; Thu, 13 Jun 2013 14:03:48 -0700
+Received: by 10.0.0.1 with HTTP; Thu, 13 Jun 2013 14:03:48 -0700
+Date: Thu, 13 Jun 2013 17:03:48 -0400
+From: Jake the Dog <jake@adventuretime.ooo>
+To: reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo
+Message-ID: <CADkmRc+rNGAGGbV2iE5p918UVy4UyJqVcXRO2=otppgzduJSg@mail.gmail.com>
+Subject: re: [Discourse Meta] eviltrout posted in 'Adventure Time Sux'
+Mime-Version: 1.0
+Content-Type: text/plain;
+ charset=ISO-8859-1
+Content-Transfer-Encoding: 7bit
+X-Sieve: CMU Sieve 2.2
+X-Received: by 10.0.0.1 with SMTP id n7mr11234144ipb.85.1371157428600; Thu,
+ 13 Jun 2013 14:03:48 -0700 (PDT)
+X-Scanned-By: MIMEDefang 2.69 on IPv6:2001:470:1d:165::1
+
+I could not disagree more. I am obviously biased but adventure time is the
+greatest show ever created. Everyone should watch it.
+
+- Jake out
+
+
+On Sun, Jun 9, 2013 at 1:39 PM, eviltrout via Discourse Meta
+<reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo> wrote:
+>
+>
+>
+> eviltrout posted in 'Adventure Time Sux' on Discourse Meta:
+>
+> ---
+> hey guys everyone knows adventure time sucks!
+>
+> ---
+> Please visit this link to respond: http://localhost:3000/t/adventure-time-sux/1234/3
+>
+> To unsubscribe from these emails, visit your [user preferences](http://localhost:3000/user_preferences).
+> \ No newline at end of file
diff --git a/spec/fixtures/emails/via_line.eml b/spec/fixtures/emails/via_line.eml
new file mode 100644
index 00000000000..0b2947ff954
--- /dev/null
+++ b/spec/fixtures/emails/via_line.eml
@@ -0,0 +1,25 @@
+
+Delivered-To: discourse-reply+cd480e301683c9902891f15968bf07a5@discourse.org
+Received: by 10.194.216.104 with SMTP id op8csp80593wjc;
+ Wed, 24 Jul 2013 07:59:14 -0700 (PDT)
+Return-Path: <walter.white@googlemail.com>
+References: <topic/5043@discourse.org> <51efeb9b36c34_66dc2dfce6811866@discourse.mail>
+From: Walter White <walter.white@googlemail.com>
+In-Reply-To: <51efeb9b36c34_66dc2dfce6811866@discourse.mail>
+Mime-Version: 1.0 (1.0)
+Date: Wed, 24 Jul 2013 15:59:10 +0100
+Message-ID: <4597127794206131679@unknownmsgid>
+Subject: Re: [Discourse] new reply to your post in 'Crystal Blue'
+To: walter via Discourse <reply+cd480e301683c9902891f15968bf07a5@appmail.adventuretime.ooo>
+Content-Type: multipart/alternative; boundary=001a11c20edc15a39304e2432790
+
+Hello this email has content!
+
+codinghorror via Discourse wrote:
+> [codinghorror] codinghorror
+> <http://meta.discourse.org/users/codinghorror>
+> August 7
+>
+> It wouldn't be great at the moment for 100% email, since there's no
+> way to be notified of new topics via email. (you can get notified of
+> new replies to your posts and topics via email, and reply to them.)
diff --git a/spec/fixtures/emails/windows_8_metro.eml b/spec/fixtures/emails/windows_8_metro.eml
new file mode 100644
index 00000000000..67d204af562
--- /dev/null
+++ b/spec/fixtures/emails/windows_8_metro.eml
@@ -0,0 +1,173 @@
+Delivered-To: reply@discourse.org
+Return-Path: <walter.white@googlemail.com>
+MIME-Version: 1.0
+From: <walter.white@googlemail.com>
+To:
+ =?utf-8?Q?Discourse_Meta?=
+ <reply@discourse.org>
+Subject:
+ =?utf-8?Q?Re:_[Discourse_Meta]_[Lounge]_Testing_default_email_replies?=
+Importance: Normal
+Date: Fri, 28 Nov 2014 21:29:10 +0000
+In-Reply-To: <topic/22638/86406@meta.discourse.org>
+References:
+ <topic/22638@meta.discourse.org>,<topic/22638/86406@meta.discourse.org>
+Content-Type: multipart/alternative;
+ boundary="_866E2678-BB4F-4DD8-BE18-81B04AD8D1BC_"
+
+--_866E2678-BB4F-4DD8-BE18-81B04AD8D1BC_
+Content-Transfer-Encoding: base64
+Content-Type: text/plain; charset="utf-8"
+
+IyMjIHJlcGx5IGZyb20gZGVmYXVsdCBtYWlsIGNsaWVudCBpbiBXaW5kb3dzIDguMSBNZXRybw0K
+DQoNClRoZSBxdWljayBicm93biBmb3gganVtcHMgb3ZlciB0aGUgbGF6eSBkb2cuIFRoZSBxdWlj
+ayBicm93biBmb3gganVtcHMgb3ZlciB0aGUgbGF6eSBkb2cuIFRoZSBxdWljayBicm93biBmb3gg
+anVtcHMgb3ZlciB0aGUgbGF6eSBkb2cuIFRoZSBxdWljayBicm93biBmb3gganVtcHMgb3ZlciB0
+aGUgbGF6eSBkb2cuIFRoZSBxdWljayBicm93biBmb3gganVtcHMgb3ZlciB0aGUgbGF6eSBkb2cu
+IFRoZSBxdWljayBicm93biBmb3gganVtcHMgb3ZlciB0aGUgbGF6eSBkb2cuIFRoZSBxdWljayBi
+cm93biBmb3gganVtcHMgb3ZlciB0aGUgbGF6eSBkb2cuIFRoZSBxdWljayBicm93biBmb3gganVt
+cHMgb3ZlciB0aGUgbGF6eSBkb2cuIFRoZSBxdWljayBicm93biBmb3gganVtcHMgb3ZlciB0aGUg
+bGF6eSBkb2cuDQoNCg0KVGhpcyBpcyBhICoqYm9sZCoqIHdvcmQgaW4gTWFya2Rvd24NCg0KDQpU
+aGlzIGlzIGEgbGluayBodHRwOi8vZXhhbXBsZS5jb20NCiANCg0KDQoNCg0KDQpGcm9tOiBBcnBp
+dCBKYWxhbg0KU2VudDog4oCORnJpZGF54oCOLCDigI5Ob3ZlbWJlcuKAjiDigI4yOOKAjiwg4oCO
+MjAxNCDigI4xMuKAjjrigI4zNeKAjiDigI5QTQ0KVG86IGplZmYgYXR3b29kDQoNCg0KDQoNCg0K
+DQogdGVjaEF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SBzdHlsZT0iY29sb3I6IHJnYigxMDIsIDEwMiwgMTAyKTsgZm9udC13ZWlnaHQ6
+IGJvbGQ7IHRleHQtZGVjb3JhdGlvbjogbm9uZTsiIGhyZWY9Imh0dHBzOi8vbWV0YS5kaXNjb3Vy
+c2Uub3JnL3QvdGVzdGluZy1kZWZhdWx0LWVtYWlsLXJlcGxpZXMvMjI2MzgvMyIgdGFyZ2V0PSJf
+cGFyZW50Ij5odHRwczovL21ldGEuZGlzY291cnNlLm9yZy90L3Rlc3RpbmctZGVmYXVsdC1lbWFp
+bC1yZXBsaWVzLzIyNjM4LzM8L2E+IGluIHlvdXIgYnJvd3Nlci48L3A+CjwvZGl2Pgo8ZGl2IHN0
+eWxlPSJjb2xvcjogcmdiKDEwMiwgMTAyLCAxMDIpOyI+CjxwPlRvIHVuc3Vic2NyaWJlIGZyb20g
+dGhlc2UgZW1haWxzLCB2aXNpdCB5b3VyIDxhIHN0eWxlPSJjb2xvcjogcmdiKDEwMiwgMTAyLCAx
+MDIpOyBmb250LXdlaWdodDogYm9sZDsgdGV4dC1kZWNvcmF0aW9uOiBub25lOyIgaHJlZj0iaHR0
+cHM6Ly9tZXRhLmRpc2NvdXJzZS5vcmcvbXkvcHJlZmVyZW5jZXMiIHRhcmdldD0iX3BhcmVudCI+
+dXNlciBwcmVmZXJlbmNlczwvYT4uPC9wPgo8L2Rpdj4KPC9kaXY+CjwvZGl2PjxkaXYgc3R5bGU9
+ImZvbnQtc2l6ZTogMTRwdDsiPjxicj48L2Rpdj48L2Rpdj4KPC9ib2R5Pgo8L2h0bWw+Cg==
+
+--_866E2678-BB4F-4DD8-BE18-81B04AD8D1BC_--
diff --git a/spec/fixtures/emails/wrong_reply_key.eml b/spec/fixtures/emails/wrong_reply_key.eml
new file mode 100644
index 00000000000..491e078fb5b
--- /dev/null
+++ b/spec/fixtures/emails/wrong_reply_key.eml
@@ -0,0 +1,40 @@
+Return-Path: <jake@adventuretime.ooo>
+Received: from iceking.adventuretime.ooo ([unix socket]) by iceking (Cyrus v2.2.13-Debian-2.2.13-19+squeeze3) with LMTPA; Thu, 13 Jun 2013 17:03:50 -0400
+Received: from mail-ie0-x234.google.com (mail-ie0-x234.google.com [IPv6:2607:f8b0:4001:c03::234]) by iceking.adventuretime.ooo (8.14.3/8.14.3/Debian-9.4) with ESMTP id r5DL3nFJ016967 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for <reply+59d8df8370b7e95c5a49fbf86aeb2c93@discourse.example.com>; Thu, 13 Jun 2013 17:03:50 -0400
+Received: by mail-ie0-f180.google.com with SMTP id f4so21977375iea.25 for <reply+59d8df8370b7e95c5a49fbf86aeb2c93@discourse.example.com>; Thu, 13 Jun 2013 14:03:48 -0700
+Received: by 10.0.0.1 with HTTP; Thu, 13 Jun 2013 14:03:48 -0700
+Date: Thu, 13 Jun 2013 17:03:48 -0400
+From: Jake the Dog <jake@adventuretime.ooo>
+To: reply+QQd8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo
+Message-ID: <CADkmRc+rNGAGGbV2iE5p918UVy4UyJqVcXRO2=otppgzduJSg@mail.gmail.com>
+Subject: re: [Discourse Meta] eviltrout posted in 'Adventure Time Sux'
+Mime-Version: 1.0
+Content-Type: text/plain;
+ charset=ISO-8859-1
+Content-Transfer-Encoding: 7bit
+X-Sieve: CMU Sieve 2.2
+X-Received: by 10.0.0.1 with SMTP id n7mr11234144ipb.85.1371157428600; Thu,
+ 13 Jun 2013 14:03:48 -0700 (PDT)
+X-Scanned-By: MIMEDefang 2.69 on IPv6:2001:470:1d:165::1
+
+I could not disagree more. I am obviously biased but adventure time is the
+greatest show ever created. Everyone should watch it.
+
+- Jake out
+
+
+On Sun, Jun 9, 2013 at 1:39 PM, eviltrout via Discourse Meta
+<reply+59d8df8370b7e95c5a49fbf86aeb2c93@discourse.example.com> wrote:
+>
+>
+>
+> eviltrout posted in 'Adventure Time Sux' on Discourse Meta:
+>
+> ---
+> hey guys everyone knows adventure time sucks!
+>
+> ---
+> Please visit this link to respond: http://localhost:3000/t/adventure-time-sux/1234/3
+>
+> To unsubscribe from these emails, visit your [user preferences](http://localhost:3000/user_preferences).
+> \ No newline at end of file
diff --git a/spec/lib/gitlab/email_receiver_spec.rb b/spec/lib/gitlab/email_receiver_spec.rb
new file mode 100644
index 00000000000..d6302eac13a
--- /dev/null
+++ b/spec/lib/gitlab/email_receiver_spec.rb
@@ -0,0 +1,481 @@
+require "spec_helper"
+
+# Inspired in great part by Discourse's Email::Receiver
+describe Gitlab::EmailReceiver do
+ def fixture_file(filename)
+ return '' if filename.blank?
+ file_path = File.expand_path(Rails.root + 'spec/fixtures/' + filename)
+ File.read(file_path)
+ end
+
+ before do
+ allow(Gitlab.config.reply_by_email).to receive(:enabled).and_return(true)
+ allow(Gitlab.config.reply_by_email).to receive(:address).and_return("reply+%{reply_key}@appmail.adventuretime.ooo")
+ end
+
+ describe 'parse_body' do
+ def test_parse_body(mail_string)
+ Gitlab::EmailReceiver.new(nil).parse_body(Mail::Message.new(mail_string))
+ end
+
+ it "raises EmptyEmailError if the message is blank" do
+ expect { test_parse_body("") }.to raise_error(Gitlab::EmailReceiver::EmptyEmailError)
+ end
+
+ it "raises EmptyEmailError if the message is not an email" do
+ expect { test_parse_body("asdf" * 30) }.to raise_error(Gitlab::EmailReceiver::EmptyEmailError)
+ end
+
+ it "raises EmptyEmailError if there is no reply content" do
+ expect { test_parse_body(fixture_file("emails/no_content_reply.eml")) }.to raise_error(Gitlab::EmailReceiver::EmptyEmailError)
+ end
+
+ it "can parse the html section" do
+ expect(test_parse_body(fixture_file("emails/html_only.eml"))).to eq("The EC2 instance - I've seen that there tends to be odd and " +
+ "unrecommended settings on the Bitnami installs that I've checked out.")
+ end
+
+ it "supports a Dutch reply" do
+ expect(test_parse_body(fixture_file("emails/dutch.eml"))).to eq("Dit is een antwoord in het Nederlands.")
+ end
+
+ it "removes an 'on date wrote' quoting line" do
+ expect(test_parse_body(fixture_file("emails/on_wrote.eml"))).to eq("Sure, all you need to do is frobnicate the foobar and you'll be all set!")
+ end
+
+ it "handles multiple paragraphs" do
+ expect(test_parse_body(fixture_file("emails/paragraphs.eml"))).
+ to eq(
+"Is there any reason the *old* candy can't be be kept in silos while the new candy
+is imported into *new* silos?
+
+The thing about candy is it stays delicious for a long time -- we can just keep
+it there without worrying about it too much, imo.
+
+Thanks for listening."
+ )
+ end
+
+ it "handles multiple paragraphs when parsing html" do
+ expect(test_parse_body(fixture_file("emails/html_paragraphs.eml"))).
+ to eq(
+"Awesome!
+
+Pleasure to have you here!
+
+:boom:"
+ )
+ end
+
+ it "handles newlines" do
+ expect(test_parse_body(fixture_file("emails/newlines.eml"))).
+ to eq(
+"This is my reply.
+It is my best reply.
+It will also be my *only* reply."
+ )
+ end
+
+ it "handles inline reply" do
+ expect(test_parse_body(fixture_file("emails/inline_reply.eml"))).
+ to eq(
+"On Wed, Oct 8, 2014 at 11:12 AM, techAPJ <info@unconfigured.discourse.org> wrote:
+
+> techAPJ <https://meta.discourse.org/users/techapj>
+> November 28
+>
+> Test reply.
+>
+> First paragraph.
+>
+> Second paragraph.
+>
+> To respond, reply to this email or visit
+> https://meta.discourse.org/t/testing-default-email-replies/22638/3 in
+> your browser.
+> ------------------------------
+> Previous Replies codinghorror
+> <https://meta.discourse.org/users/codinghorror>
+> November 28
+>
+> We're testing the latest GitHub email processing library which we are
+> integrating now.
+>
+> https://github.com/github/email_reply_parser
+>
+> Go ahead and reply to this topic and I'll reply from various email clients
+> for testing.
+> ------------------------------
+>
+> To respond, reply to this email or visit
+> https://meta.discourse.org/t/testing-default-email-replies/22638/3 in
+> your browser.
+>
+> To unsubscribe from these emails, visit your user preferences
+> <https://meta.discourse.org/my/preferences>.
+>
+
+The quick brown fox jumps over the lazy dog. The quick brown fox jumps over
+the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown
+fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog. The quick brown fox jumps over
+the lazy dog. The quick brown fox jumps over the lazy dog."
+ )
+ end
+
+ it "strips iPhone signature" do
+ expect(test_parse_body(fixture_file("emails/iphone_signature.eml"))).not_to match /Sent from my iPhone/
+ end
+
+ it "properly renders email reply from gmail web client" do
+ expect(test_parse_body(fixture_file("emails/gmail_web.eml"))).
+ to eq(
+"### This is a reply from standard GMail in Google Chrome.
+
+The quick brown fox jumps over the lazy dog. The quick brown fox jumps over
+the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown
+fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog. The quick brown fox jumps over
+the lazy dog. The quick brown fox jumps over the lazy dog.
+
+Here's some **bold** text in Markdown.
+
+Here's a link http://example.com"
+ )
+ end
+
+ it "properly renders email reply from iOS default mail client" do
+ expect(test_parse_body(fixture_file("emails/ios_default.eml"))).
+ to eq(
+"### this is a reply from iOS default mail
+
+The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
+
+Here's some **bold** markdown text.
+
+Here's a link http://example.com"
+ )
+ end
+
+ it "properly renders email reply from Android 5 gmail client" do
+ expect(test_parse_body(fixture_file("emails/android_gmail.eml"))).
+ to eq(
+"### this is a reply from Android 5 gmail
+
+The quick brown fox jumps over the lazy dog. The quick brown fox jumps over
+the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown
+fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
+The quick brown fox jumps over the lazy dog.
+
+This is **bold** in Markdown.
+
+This is a link to http://example.com"
+ )
+ end
+
+ it "properly renders email reply from Windows 8.1 Metro default mail client" do
+ expect(test_parse_body(fixture_file("emails/windows_8_metro.eml"))).
+ to eq(
+"### reply from default mail client in Windows 8.1 Metro
+
+
+The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
+
+
+This is a **bold** word in Markdown
+
+
+This is a link http://example.com"
+ )
+ end
+
+ it "properly renders email reply from MS Outlook client" do
+ expect(test_parse_body(fixture_file("emails/outlook.eml"))).to eq("Microsoft Outlook 2010")
+ end
+ end
+
+# describe "posting replies" do
+# let(:reply_key) { raise "Override this in a lower describe block" }
+# let(:email_raw) { raise "Override this in a lower describe block" }
+# # ----
+# let(:receiver) { Gitlab::EmailReceiver.new(email_raw) }
+# let(:post) { create_post }
+# let(:topic) { post.topic }
+# let(:posting_user) { post.user }
+# let(:replying_user_email) { 'jake@adventuretime.ooo' }
+# let(:replying_user) { Fabricate(:user, email: replying_user_email, trust_level: 2)}
+# let(:email_log) { EmailLog.new(reply_key: reply_key,
+# post: post,
+# post_id: post.id,
+# topic_id: post.topic_id,
+# email_type: 'user_posted',
+# user: replying_user,
+# user_id: replying_user.id,
+# to_address: replying_user_email
+# ) }
+
+# before do
+# email_log.save
+# end
+
+# # === Success Posting ===
+
+# describe "valid_reply.eml" do
+# let!(:reply_key) { '59d8df8370b7e95c5a49fbf86aeb2c93' }
+# let!(:email_raw) { fixture_file("emails/valid_reply.eml") }
+
+# it "creates a post with the correct content" do
+# start_count = topic.posts.count
+
+# receiver.process
+
+# expect(topic.posts.count).to eq(start_count + 1)
+# created_post = topic.posts.last
+# expect(created_post.via_email).to eq(true)
+# expect(created_post.raw_email).to eq(fixture_file("emails/valid_reply.eml"))
+# expect(created_post.cooked.strip).to eq(fixture_file("emails/valid_reply.cooked").strip)
+# end
+# end
+
+# describe "paragraphs.eml" do
+# let!(:reply_key) { '59d8df8370b7e95c5a49fbf86aeb2c93' }
+# let!(:email_raw) { fixture_file("emails/paragraphs.eml") }
+
+# it "cooks multiple paragraphs with traditional Markdown linebreaks" do
+# start_count = topic.posts.count
+
+# receiver.process
+
+# expect(topic.posts.count).to eq(start_count + 1)
+# expect(topic.posts.last.cooked.strip).to eq(fixture_file("emails/paragraphs.cooked").strip)
+# expect(topic.posts.last.cooked).not_to match /<br/
+# end
+# end
+
+# describe "attachment.eml" do
+# let!(:reply_key) { '636ca428858779856c226bb145ef4fad' }
+# let!(:email_raw) {
+# fixture_file("emails/attachment.eml")
+# .gsub("TO", "reply+#{reply_key}@appmail.adventuretime.ooo")
+# .gsub("FROM", replying_user_email)
+# }
+
+# let(:upload_sha) { '04df605be528d03876685c52166d4b063aabb78a' }
+
+# it "creates a post with an attachment" do
+# Upload.stubs(:fix_image_orientation)
+# ImageOptim.any_instance.stubs(:optimize_image!)
+
+# start_count = topic.posts.count
+# Upload.find_by(sha1: upload_sha).try(:destroy)
+
+# receiver.process
+
+# expect(topic.posts.count).to eq(start_count + 1)
+# expect(topic.posts.last.cooked).to match /<img src=['"](\/uploads\/default\/original\/.+\.png)['"] width=['"]289['"] height=['"]126['"]>/
+# expect(Upload.find_by(sha1: upload_sha)).not_to eq(nil)
+# end
+
+# end
+
+# # === Failure Conditions ===
+
+# describe "too_short.eml" do
+# let!(:reply_key) { '636ca428858779856c226bb145ef4fad' }
+# let!(:email_raw) {
+# fixture_file("emails/too_short.eml")
+# .gsub("TO", "reply+#{reply_key}@appmail.adventuretime.ooo")
+# .gsub("FROM", replying_user_email)
+# .gsub("SUBJECT", "re: [Discourse Meta] eviltrout posted in 'Adventure Time Sux'")
+# }
+
+# it "raises an InvalidPost error" do
+# SiteSetting.min_post_length = 5
+# expect { receiver.process }.to raise_error(Gitlab::EmailReceiver::InvalidPost)
+# end
+# end
+
+# describe "too_many_mentions.eml" do
+# let!(:reply_key) { '636ca428858779856c226bb145ef4fad' }
+# let!(:email_raw) { fixture_file("emails/too_many_mentions.eml") }
+
+# it "raises an InvalidPost error" do
+# SiteSetting.max_mentions_per_post = 10
+# (1..11).each do |i|
+# Fabricate(:user, username: "user#{i}").save
+# end
+
+# expect { receiver.process }.to raise_error(Gitlab::EmailReceiver::InvalidPost)
+# end
+# end
+
+# describe "auto response email replies should not be accepted" do
+# let!(:reply_key) { '636ca428858779856c226bb145ef4fad' }
+# let!(:email_raw) { fixture_file("emails/auto_reply.eml") }
+# it "raises a AutoGeneratedEmailError" do
+# expect { receiver.process }.to raise_error(Gitlab::EmailReceiver::AutoGeneratedEmailError)
+# end
+# end
+
+# end
+
+# describe "posting reply to a closed topic" do
+# let(:reply_key) { raise "Override this in a lower describe block" }
+# let(:email_raw) { raise "Override this in a lower describe block" }
+# let(:receiver) { Gitlab::EmailReceiver.new(email_raw) }
+# let(:topic) { Fabricate(:topic, closed: true) }
+# let(:post) { Fabricate(:post, topic: topic, post_number: 1) }
+# let(:replying_user_email) { 'jake@adventuretime.ooo' }
+# let(:replying_user) { Fabricate(:user, email: replying_user_email, trust_level: 2) }
+# let(:email_log) { EmailLog.new(reply_key: reply_key,
+# post: post,
+# post_id: post.id,
+# topic_id: topic.id,
+# email_type: 'user_posted',
+# user: replying_user,
+# user_id: replying_user.id,
+# to_address: replying_user_email
+# ) }
+
+# before do
+# email_log.save
+# end
+
+# describe "should not create post" do
+# let!(:reply_key) { '59d8df8370b7e95c5a49fbf86aeb2c93' }
+# let!(:email_raw) { fixture_file("emails/valid_reply.eml") }
+# it "raises a TopicClosedError" do
+# expect { receiver.process }.to raise_error(Gitlab::EmailReceiver::TopicClosedError)
+# end
+# end
+# end
+
+# describe "posting reply to a deleted topic" do
+# let(:reply_key) { raise "Override this in a lower describe block" }
+# let(:email_raw) { raise "Override this in a lower describe block" }
+# let(:receiver) { Gitlab::EmailReceiver.new(email_raw) }
+# let(:deleted_topic) { Fabricate(:deleted_topic) }
+# let(:post) { Fabricate(:post, topic: deleted_topic, post_number: 1) }
+# let(:replying_user_email) { 'jake@adventuretime.ooo' }
+# let(:replying_user) { Fabricate(:user, email: replying_user_email, trust_level: 2) }
+# let(:email_log) { EmailLog.new(reply_key: reply_key,
+# post: post,
+# post_id: post.id,
+# topic_id: deleted_topic.id,
+# email_type: 'user_posted',
+# user: replying_user,
+# user_id: replying_user.id,
+# to_address: replying_user_email
+# ) }
+
+# before do
+# email_log.save
+# end
+
+# describe "should not create post" do
+# let!(:reply_key) { '59d8df8370b7e95c5a49fbf86aeb2c93' }
+# let!(:email_raw) { fixture_file("emails/valid_reply.eml") }
+# it "raises a TopicNotFoundError" do
+# expect { receiver.process }.to raise_error(Gitlab::EmailReceiver::TopicNotFoundError)
+# end
+# end
+# end
+
+# describe "posting a new topic" do
+# let(:category_destination) { raise "Override this in a lower describe block" }
+# let(:email_raw) { raise "Override this in a lower describe block" }
+# let(:allow_strangers) { false }
+# # ----
+# let(:receiver) { Gitlab::EmailReceiver.new(email_raw) }
+# let(:user_email) { 'jake@adventuretime.ooo' }
+# let(:user) { Fabricate(:user, email: user_email, trust_level: 2)}
+# let(:category) { Fabricate(:category, email_in: category_destination, email_in_allow_strangers: allow_strangers) }
+
+# before do
+# SiteSetting.email_in = true
+# user.save
+# category.save
+# end
+
+# describe "too_short.eml" do
+# let!(:category_destination) { 'incoming+amazing@appmail.adventuretime.ooo' }
+# let(:email_raw) {
+# fixture_file("emails/too_short.eml")
+# .gsub("TO", category_destination)
+# .gsub("FROM", user_email)
+# .gsub("SUBJECT", "A long subject that passes the checks")
+# }
+
+# it "does not create a topic if the post fails" do
+# before_topic_count = Topic.count
+
+# expect { receiver.process }.to raise_error(Gitlab::EmailReceiver::InvalidPost)
+
+# expect(Topic.count).to eq(before_topic_count)
+# end
+
+# end
+
+# end
+
+# def fill_email(mail, from, to, body = nil, subject = nil)
+# result = mail.gsub("FROM", from).gsub("TO", to)
+# if body
+# result.gsub!(/Hey.*/m, body)
+# end
+# if subject
+# result.sub!(/We .*/, subject)
+# end
+# result
+# end
+
+# def process_email(opts)
+# incoming_email = fixture_file("emails/valid_incoming.eml")
+# email = fill_email(incoming_email, opts[:from], opts[:to], opts[:body], opts[:subject])
+# Gitlab::EmailReceiver.new(email).process
+# end
+
+# describe "with a valid email" do
+# let(:reply_key) { "59d8df8370b7e95c5a49fbf86aeb2c93" }
+# let(:to) { SiteSetting.reply_by_email_address.gsub("%{reply_key}", reply_key) }
+
+# let(:valid_reply) {
+# reply = fixture_file("emails/valid_reply.eml")
+# to = SiteSetting.reply_by_email_address.gsub("%{reply_key}", reply_key)
+# fill_email(reply, "test@test.com", to)
+# }
+
+# let(:receiver) { Gitlab::EmailReceiver.new(valid_reply) }
+# let(:post) { create_post }
+# let(:user) { post.user }
+# let(:email_log) { EmailLog.new(reply_key: reply_key,
+# post_id: post.id,
+# topic_id: post.topic_id,
+# user_id: post.user_id,
+# post: post,
+# user: user,
+# email_type: 'test',
+# to_address: 'test@test.com'
+# ) }
+# let(:reply_body) {
+# "I could not disagree more. I am obviously biased but adventure time is the
+# greatest show ever created. Everyone should watch it.
+
+# - Jake out" }
+
+# describe "with an email log" do
+
+# it "extracts data" do
+# expect{ receiver.process }.to raise_error(Gitlab::EmailReceiver::EmailLogNotFound)
+
+# email_log.save!
+# receiver.process
+
+# expect(receiver.body).to eq(reply_body)
+# expect(receiver.email_log).to eq(email_log)
+# end
+
+# end
+
+# end
+end