# MailSlurp\AttachmentControllerApi

All URIs are relative to https://api.mailslurp.com

Method HTTP request Description
uploadAttachment POST /attachments Upload an attachment for sending using base64 file encoding. Returns an array whose first element is the ID of the uploaded attachment.
uploadAttachmentBytes POST /attachments/bytes Upload an attachment for sending using file byte stream input octet stream. Returns an array whose first element is the ID of the uploaded attachment.
uploadMultipartForm POST /attachments/multipart Upload an attachment for sending using a Multipart Form request. Returns an array whose first element is the ID of the uploaded attachment.

# uploadAttachment

string[] uploadAttachment($upload_options)

Upload an attachment for sending using base64 file encoding. Returns an array whose first element is the ID of the uploaded attachment.

Email attachments are essentially files with meta data. Files are byte arrays and the meta data is a content type and a filename. These properties allow email clients to display the filename and icon etc. When sending emails with attachments first upload each attachment with an upload endpoint. Record the returned attachment ID and use it with subsequent email sending. For legacy reasons the ID is returned as the first element in an array. Only a single ID is ever returned. To send the attachments pass a list of attachment IDs with SendEmailOptions when sending an email. Using the upload endpoints prior to sending mean attachments can easily be reused.

# Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure API key authorization: API_KEY
$config = MailSlurp\Configuration::getDefaultConfiguration()->setApiKey('x-api-key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = MailSlurp\Configuration::getDefaultConfiguration()->setApiKeyPrefix('x-api-key', 'Bearer');
$apiInstance = new MailSlurp\Api\AttachmentControllerApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$upload_options = new \MailSlurp\Models\UploadAttachmentOptions(); // \MailSlurp\Models\UploadAttachmentOptions | uploadOptions
try {
    $result = $apiInstance->uploadAttachment($upload_options);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling AttachmentControllerApi->uploadAttachment: ', $e->getMessage(), PHP_EOL;
}
?>

# Parameters

Name Type Description Notes
upload_options \MailSlurp\Models\UploadAttachmentOptions uploadOptions

# Return type

string[]

# Authorization

API_KEY

# HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

# uploadAttachmentBytes

string[] uploadAttachmentBytes($string, $filename, $byte_array)

Upload an attachment for sending using file byte stream input octet stream. Returns an array whose first element is the ID of the uploaded attachment.

Email attachments are essentially files with meta data. Files are byte arrays and the meta data is a content type and a filename. These properties allow email clients to display the filename and icon etc. When sending emails with attachments first upload each attachment with an upload endpoint. Record the returned attachment ID and use it with subsequent email sending. For legacy reasons the ID is returned as the first element in an array. Only a single ID is ever returned. To send the attachments pass a list of attachment IDs with SendEmailOptions when sending an email. Using the upload endpoints prior to sending mean attachments can easily be reused.

# Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure API key authorization: API_KEY
$config = MailSlurp\Configuration::getDefaultConfiguration()->setApiKey('x-api-key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = MailSlurp\Configuration::getDefaultConfiguration()->setApiKeyPrefix('x-api-key', 'Bearer');
$apiInstance = new MailSlurp\Api\AttachmentControllerApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$string = 'string_example'; // string | Optional contentType for file. For instance `application/pdf`
$filename = 'filename_example'; // string | Optional filename to save upload with
$byte_array = 'byte_array_example'; // string | Byte array request body
try {
    $result = $apiInstance->uploadAttachmentBytes($string, $filename, $byte_array);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling AttachmentControllerApi->uploadAttachmentBytes: ', $e->getMessage(), PHP_EOL;
}
?>

# Parameters

Name Type Description Notes
string string Optional contentType for file. For instance `application/pdf` [optional]
filename string Optional filename to save upload with [optional]
byte_array string Byte array request body [optional]

# Return type

string[]

# Authorization

API_KEY

# HTTP request headers

  • Content-Type: application/octet-stream
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

# uploadMultipartForm

string[] uploadMultipartForm($file, $content_type, $filename, $x_filename)

Upload an attachment for sending using a Multipart Form request. Returns an array whose first element is the ID of the uploaded attachment.

Email attachments are essentially files with meta data. Files are byte arrays and the meta data is a content type and a filename. These properties allow email clients to display the filename and icon etc. When sending emails with attachments first upload each attachment with an upload endpoint. Record the returned attachment ID and use it with subsequent email sending. For legacy reasons the ID is returned as the first element in an array. Only a single ID is ever returned. To send the attachments pass a list of attachment IDs with SendEmailOptions when sending an email. Using the upload endpoints prior to sending mean attachments can easily be reused.

# Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure API key authorization: API_KEY
$config = MailSlurp\Configuration::getDefaultConfiguration()->setApiKey('x-api-key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = MailSlurp\Configuration::getDefaultConfiguration()->setApiKeyPrefix('x-api-key', 'Bearer');
$apiInstance = new MailSlurp\Api\AttachmentControllerApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$file = "/path/to/file.txt"; // \SplFileObject | file
$content_type = 'content_type_example'; // string | Optional content type of attachment
$filename = 'filename_example'; // string | Optional name of file
$x_filename = 'x_filename_example'; // string | Optional content type header of attachment
try {
    $result = $apiInstance->uploadMultipartForm($file, $content_type, $filename, $x_filename);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling AttachmentControllerApi->uploadMultipartForm: ', $e->getMessage(), PHP_EOL;
}
?>

# Parameters

Name Type Description Notes
file \SplFileObject**\SplFileObject** file
content_type string Optional content type of attachment [optional]
filename string Optional name of file [optional]
x_filename string Optional content type header of attachment [optional]

# Return type

string[]

# Authorization

API_KEY

# HTTP request headers

  • Content-Type: multipart/form-data
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]