mailgun-php/doc/attachments.md
Tobias Nyholm af98ed3307 Added documentation for the API classes (#328)
* Added documentation for the API classes

* Added more docs

* Added domain

* Typo

* Minor fixes
2017-04-08 10:45:25 +02:00

1011 B

Attachments

You may attach a file from memory or by a file path.

From file path

$mg->message()->send('example.com', [
  'from'    => 'bob@example.com', 
  'to'      => 'sally@example.com', 
  'subject' => 'Test file path attachments', 
  'text'    => 'Test',
  'attachment' => [
    ['filePath'=>'/tmp/foo.jpg', 'filename'=>'test.jpg']
  ]
]);

From memory

// Some how load the file to memory
$binaryFile = '[Binary data]';

$mg->message()->send('example.com', [
  'from'    => 'bob@example.com', 
  'to'      => 'sally@example.com', 
  'subject' => 'Test memory attachments', 
  'text'    => 'Test',
  'attachment' => [
    ['fileContent'=>$binaryFile, 'filename'=>'test.jpg']
  ]
]);

Inline attachments

$mg->message()->send('example.com', [
  'from'    => 'bob@example.com', 
  'to'      => 'sally@example.com', 
  'subject' => 'Test inline attachments', 
  'text'    => 'Test',
  'inline' => [
    ['filePath'=>'/tmp/foo.jpg', 'filename'=>'test.jpg']
  ]
]);