Skip to content

Commit

Permalink
Added a better error message for non HTML/text mail sending
Browse files Browse the repository at this point in the history
  • Loading branch information
tfountain committed May 18, 2017
1 parent c2d0fc2 commit 6c3ed2e
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/MessageManagement/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,16 @@ public function toApiParams()

} elseif ($body instanceof MimeMessage) {
$parts = $body->getParts();
if (count($parts) > 2) {
throw new RuntimeException(
'Currently, only text/plain and text/html MIME parts
are supported'
);
}

foreach ($parts as $part) {
if ($part->type == 'text/plain') {
$params['bodytext'] = $part->getRawContent();
} elseif ($part->type == 'text/html') {
$params['bodyhtml'] = $part->getRawContent();
} else {
throw new RuntimeException(
'Currently, only text/plain and text/html MIME parts
are supported'
);
}
}
}
Expand Down

0 comments on commit 6c3ed2e

Please sign in to comment.