mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2024-11-30 00:46:04 +03:00
af98ed3307
* Added documentation for the API classes * Added more docs * Added domain * Typo * Minor fixes
48 lines
1011 B
Markdown
48 lines
1011 B
Markdown
# Attachments
|
|
|
|
You may attach a file from memory or by a file path.
|
|
|
|
## From file path
|
|
|
|
```php
|
|
$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
|
|
|
|
```php
|
|
// 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
|
|
|
|
```php
|
|
$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']
|
|
]
|
|
]);
|
|
```
|