Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@ public function send($view, array $data = [], $callback = null)
protected function applyDebugHeaders(Mailable $mailable)
{
$mailable->withSwiftMessage(function (\Swift_Message $swiftMessage) use ($mailable) {
$viewFile = $view = $viewContent = $viewData = null;

$viewFile = $this->getMailableViewFile($mailable);
$view = $this->getMailableView($viewFile);
$viewContent = $this->getMailableViewContent($view);

$viewData = $this->getMailableViewData($mailable);
if (! is_null($viewFile)) {
$view = $this->getMailableView($viewFile);
$viewContent = $this->getMailableViewContent($view);
$viewData = $this->getMailableViewData($mailable);
}


/**
* We need to base64 encode the data, as the SMTP header mime encoding could add unwanted
Expand Down
12 changes: 10 additions & 2 deletions src/TestMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@

class TestMail extends Mailable
{
protected $plainText;

public function __construct($plainText = false)
{
$this->plainText = $plainText;
}

public function build()
{
return $this->subject("Test from HELO")
->markdown('helo::email');
$this->subject("Test from HELO");

return $this->plainText ? $this->text('helo::email') : $this->markdown('helo::email');
}
}
10 changes: 10 additions & 0 deletions tests/HeloTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ public function test_the_mail_commands_sends_the_mailable()
Mail::assertSent(TestMail::class);
}

/** @test */
public function test_plain_text_mails_work_correctly()
{
Mail::fake();

Mail::to('test@usehelo.com')->send(new TestMail(true));

Mail::assertSent(TestMail::class);
}

/** @test */
public function test_the_correct_mailer_is_binded()
{
Expand Down