Skip to content

Commit

Permalink
feat: attach file content (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrstroz authored Feb 4, 2021
1 parent 3fed72c commit 3a592f5
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,23 @@ public function attach($fileName, array $options = [])

/**
* @inheritdoc
* @deprecated Attaching content is not supported by Mailgun.
*/
public function attachContent($content, array $options = [])
{
throw new NotSupportedException('Attaching content is not supported');
$attachmentName = !empty($options['fileName']) ? $options['fileName'] : null;
$message = $this->getMessageBuilder()->getMessage();

if (!isset($message['attachment'])) {
$message['attachment'] = [];
}

$message['attachment'][] = [
'fileContent' => $content,
'filename' => $attachmentName,
];
$this->getMessageBuilder()->setMessage($message);

return $this;
}

/**
Expand Down

0 comments on commit 3a592f5

Please sign in to comment.