Skip to content

Commit 1c2aec1

Browse files
committed
wip
1 parent 712b32e commit 1c2aec1

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525
"zbateson/mail-mime-parser": "^1.1"
2626
},
2727
"require-dev": {
28-
"phpunit/phpunit": "^7.0",
28+
"mockery/mockery": "^1.2",
2929
"orchestra/testbench": "3.7.*",
30+
"phpunit/phpunit": "^7.0",
3031
"zendframework/zend-mail": "^2.10"
3132
},
3233
"autoload": {

src/InboundEmail.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ public function forward($recipients)
131131
{
132132
return Mail::send([], [], function ($message) use ($recipients) {
133133
$message->to($recipients)
134-
->setBody($this->body());
134+
->subject($this->subject())
135+
->setBody($this->body(), $this->message()->getContentType());
135136
});
136137
}
137138

tests/InboundEmailTest.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,46 @@ public function it_stores_inbound_emails()
3030
$this->assertSame(2, InboundEmail::query()->count());
3131
}
3232

33+
/** @test */
34+
public function it_does_not_store_inbound_emails_if_configured()
35+
{
36+
$this->app['config']['mailbox.store_incoming_emails_for_days'] = 0;
37+
38+
Mailbox::from('[email protected]', function($email) {
39+
});
40+
41+
Mail::to('[email protected]')->send(new TestMail);
42+
Mail::to('[email protected]')->send(new TestMail);
43+
44+
$this->assertSame(0, InboundEmail::query()->count());
45+
}
46+
47+
/** @test */
48+
public function it_can_reply_to_mails()
49+
{
50+
51+
Mailbox::from('[email protected]', function(InboundEmail $email) {
52+
Mail::fake();
53+
54+
$email->reply(new ReplyMail);
55+
});
56+
57+
Mail::to('[email protected]')->send(new TestMail);
58+
59+
Mail::assertSent(ReplyMail::class);
60+
}
61+
62+
/** @test */
63+
public function it_can_forward_mails()
64+
{
65+
66+
Mailbox::from('[email protected]', function(InboundEmail $email) {
67+
$email->forward('[email protected]');
68+
});
69+
70+
Mail::to('[email protected]')->send(new TestMail);
71+
}
72+
3373
}
3474

3575
class TestMail extends Mailable
@@ -40,4 +80,14 @@ public function build()
4080
->subject('This is a subject')
4181
->html('<html>Example email content</html>');
4282
}
83+
}
84+
85+
class ReplyMail extends Mailable
86+
{
87+
public function build()
88+
{
89+
$this->from('[email protected]')
90+
->subject('This is my reply')
91+
->html('Hi!');
92+
}
4393
}

0 commit comments

Comments
 (0)