Skip to content

Latest commit

 

History

History
47 lines (40 loc) · 1014 Bytes

attachments.md

File metadata and controls

47 lines (40 loc) · 1014 Bytes

Attachments

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

From file path

$mg->messages()->send('example.com', [
  'from'    => '[email protected]', 
  'to'      => '[email protected]', 
  '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->messages()->send('example.com', [
  'from'    => '[email protected]', 
  'to'      => '[email protected]', 
  'subject' => 'Test memory attachments', 
  'text'    => 'Test',
  'attachment' => [
    ['fileContent'=>$binaryFile, 'filename'=>'test.jpg']
  ]
]);

Inline attachments

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