2017-04-08 11:45:25 +03:00
|
|
|
# Attachments
|
|
|
|
|
|
|
|
You may attach a file from memory or by a file path.
|
|
|
|
|
|
|
|
## From file path
|
|
|
|
|
|
|
|
```php
|
2018-11-29 11:37:44 +03:00
|
|
|
$mg->messages()->send('example.com', [
|
2017-04-08 11:45:25 +03:00
|
|
|
'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
|
|
|
|
|
|
|
|
```php
|
|
|
|
// Some how load the file to memory
|
|
|
|
$binaryFile = '[Binary data]';
|
|
|
|
|
2018-11-29 11:37:44 +03:00
|
|
|
$mg->messages()->send('example.com', [
|
2017-04-08 11:45:25 +03:00
|
|
|
'from' => 'bob@example.com',
|
|
|
|
'to' => 'sally@example.com',
|
|
|
|
'subject' => 'Test memory attachments',
|
|
|
|
'text' => 'Test',
|
|
|
|
'attachment' => [
|
|
|
|
['fileContent'=>$binaryFile, 'filename'=>'test.jpg']
|
|
|
|
]
|
|
|
|
]);
|
|
|
|
```
|
|
|
|
|
|
|
|
## Inline attachments
|
|
|
|
|
|
|
|
```php
|
2018-11-29 11:37:44 +03:00
|
|
|
$mg->messages()->send('example.com', [
|
2017-04-08 11:45:25 +03:00
|
|
|
'from' => 'bob@example.com',
|
|
|
|
'to' => 'sally@example.com',
|
|
|
|
'subject' => 'Test inline attachments',
|
|
|
|
'text' => 'Test',
|
|
|
|
'inline' => [
|
|
|
|
['filePath'=>'/tmp/foo.jpg', 'filename'=>'test.jpg']
|
|
|
|
]
|
|
|
|
]);
|
|
|
|
```
|