Skip to navigation

Send

View as Markdown

🇬🇧 English

Authentication required. All requests must include a valid JWT access token obtained from POST /api/1.0/auth/token.


Send Mail

POST /api/1.0/mail/store

Send a transactional email. Supports plain text, HTML content, and file attachments.

Headers

KeyValueRequired
AuthorizationBearer✅
Content-Typemultipart/form-data✅

Body (multipart/form-data)

FieldTypeRequiredDescription
fromstring✅Sender email address. Must be a valid email. Max 255 characters
from_namestring✅Sender display name. Max 255 characters
subjectstring✅Email subject
tostring or string[]✅Recipient email address. Accepts a single email string or an array (to[])
ccstring or string[]❌CC email address(es). Accepts a single email string or an array (cc[])
bccstring or string[]❌BCC email address(es). Accepts a single email string or an array (bcc[])
textstring✅ *Plain text content. Required if html is not provided
htmlstring✅ *HTML content. Required if text is not provided
reply_tostring❌Reply-To email address
attachments / attachments[]file❌File attachment(s). Total size must not exceed 20MB

* At least one of text or html must be provided.

Example Request (JSON-style reference)

POST /api/1.0/mail/store
Authorization: Bearer <access_token>
Content-Type: multipart/form-data
from = info@example.com
from_name = My Company
subject = Account Activation
to[] = user@example.com
text = Your account has been activated.
html = <p class=&#x27;preserveHtml&#x27; class=&#x27;preserveHtml&#x27;>Your account has been activated.</p>
attachments[] = [file]

PHP (Guzzle) Example

$client = new Client();
$response = $client->post('https://smtp-api.bizfly.vn/api/1.0/mail/store', [
'headers' => [
&#x27;Authorization&#x27; => &#x27;Bearer <access_token>&#x27;,
],
'multipart' => [
['name' => 'from', 'contents' => 'info@example.com'],
['name' => 'from_name', 'contents' => 'My Company'],
['name' => 'subject', 'contents' => 'Account Activation'],
['name' => 'to[]', 'contents' => 'user@example.com'],
['name' => 'text', 'contents' => 'Your account has been activated.'],
[&#x27;name&#x27; => &#x27;html&#x27;, &#x27;contents&#x27; => &#x27;<p class=&#x27;preserveHtml&#x27; class=&#x27;preserveHtml&#x27;>Your account has been activated.</p>&#x27;],
[
'name' => 'attachments[]',
'contents' => Utils::tryFopen('/path/to/file.pdf', 'r'),
'filename' => 'file.pdf',
],
],
]);

Responses

200 OK — Success

{
"code": 200,
"status": "Save mail success",
"message_id": "550e8400-e29b-41d4-a716-446655440000@bizfly.vn"
}
FieldTypeDescription
codeintegerHTTP status code
statusstringResult message
message_idstringUnique ID of the queued email

400 Bad Request — Validation error

{
"errors": [
{
"msg": "Người gửi phải là email",
"param": "from",
"location": "body"
}
]
}

400 Bad Request — Attachment too large

{
"errors": [
{
"msg": "Tổng dung lượng file upload tối đa là 20Mb",
"param": "attachments",
"location": "files"
}
]
}

401 Unauthorized — Missing or invalid token

{
"success": false,
"message": "Missing or invalid Authorization header"
}

401 Unauthorized — Token expired

{
"success": false,
"message": "Access token expired"
}

500 Internal Server Error

{
"success": false,
"message": "Internal server error"
}


🇻🇳 Tiếng Việt

Yêu cầu xác thực. Tất cả request phải kèm JWT access token hợp lệ lấy từ POST /api/1.0/auth/token.


Gửi Mail

POST /api/1.0/mail/store

Gửi email giao dịch. Hỗ trợ nội dung text thuần, HTML và file đính kèm.

Headers

KeyValueBắt buộc
AuthorizationBearer✅
Content-Typemultipart/form-data✅

Body (multipart/form-data)

Tham sốKiểuBắt buộcMô tả
fromstring✅Email người gửi. Phải là email hợp lệ. Tối đa 255 ký tự
from_namestring✅Tên hiển thị người gửi. Tối đa 255 ký tự
subjectstring✅Tiêu đề email
tostring hoặc string[]✅Email người nhận. Có thể là 1 email string hoặc mảng (to[])
ccstring hoặc string[]❌Email CC. Có thể là 1 email string hoặc mảng (cc[])
bccstring hoặc string[]❌Email BCC. Có thể là 1 email string hoặc mảng (bcc[])
textstring✅ *Nội dung dạng text thuần. Bắt buộc nếu không có html
htmlstring✅ *Nội dung dạng HTML. Bắt buộc nếu không có text
reply_tostring❌Địa chỉ email Reply-To
attachments / attachments[]file❌File đính kèm. Tổng dung lượng không vượt quá 20MB

* Phải có ít nhất một trong text hoặc html.

Ví dụ Request (dạng tham chiếu)

POST /api/1.0/mail/store
Authorization: Bearer <access_token>
Content-Type: multipart/form-data
from = info@example.com
from_name = Công ty của tôi
subject = Kích hoạt tài khoản
to[] = user@example.com
text = Tài khoản của bạn đã được kích hoạt thành công.
html = <p class=&#x27;preserveHtml&#x27; class=&#x27;preserveHtml&#x27;>Tài khoản của bạn đã được kích hoạt thành công.</p>
attachments[] = [file]

Ví dụ PHP (Guzzle)

$client = new Client();
$response = $client->post('https://smtp-api.bizfly.vn/api/1.0/mail/store', [
'headers' => [
&#x27;Authorization&#x27; => &#x27;Bearer <access_token>&#x27;,
],
'multipart' => [
['name' => 'from', 'contents' => 'info@example.com'],
['name' => 'from_name', 'contents' => 'Công ty của tôi'],
['name' => 'subject', 'contents' => 'Kích hoạt tài khoản'],
['name' => 'to[]', 'contents' => 'user@example.com'],
['name' => 'text', 'contents' => 'Tài khoản của bạn đã được kích hoạt thành công.'],
[&#x27;name&#x27; => &#x27;html&#x27;, &#x27;contents&#x27; => &#x27;<p class=&#x27;preserveHtml&#x27; class=&#x27;preserveHtml&#x27;>Tài khoản của bạn đã được kích hoạt thành công.</p>&#x27;],
[
'name' => 'attachments[]',
'contents' => Utils::tryFopen('/path/to/file.pdf', 'r'),
'filename' => 'file.pdf',
],
],
]);

Responses

200 OK — Thành công

{
"code": 200,
"status": "Save mail success",
"message_id": "550e8400-e29b-41d4-a716-446655440000@bizfly.vn"
}
TrườngKiểuMô tả
codeintegerHTTP status code
statusstringThông báo kết quả
message_idstringID duy nhất của email đã được đưa vào hàng đợi gửi

400 Bad Request — Lỗi validation

{
"errors": [
{
"msg": "Người gửi phải là email",
"param": "from",
"location": "body"
}
]
}

400 Bad Request — File đính kèm quá lớn

{
"errors": [
{
"msg": "Tổng dung lượng file upload tối đa là 20Mb",
"param": "attachments",
"location": "files"
}
]
}

401 Unauthorized — Thiếu hoặc sai token

{
"success": false,
"message": "Missing or invalid Authorization header"
}

401 Unauthorized — Token hết hạn

{
"success": false,
"message": "Access token expired"
}

500 Internal Server Error

{
"success": false,
"message": "Internal server error"
}

Request

This endpoint expects a multipart form containing a file.
fromstringRequired
from_namestringRequired
subjectstringRequired
to[]stringRequired
textstringRequired
htmlstringRequired
attachments[]fileRequired

Response headers

x-powered-bystringOptional
etagstringOptional
front-end-httpsstringOptional
strict-transport-securitystringOptional

Response

OK
codeinteger
statusstring
message_idstringformat: "email"

Errors

400
Bad Request Error