API: Mail/send
The original link
An overview of
Mail /send is the mail API for SUBMAIL. The Mail/Send API not only provides powerful mail sending functions, but also integrates address book sending functions into the API. You can set some parameters to determine which mode the API will be sent in.
The Mail/Send API can use variables to dynamically control the content of each message. Learn how to use text variables and hyperlink variables.
URL
< the > https://api.mysubmail.com/mail/send
< for > https://api.submail.cn/mail/send
Supported formats
format | URL |
---|---|
json |
https://api.mysubmail.com/mail/send.json (the default) |
xml |
https://api.mysubmail.com/mail/send.xml |
HTTP Request Mode
Request way | Set the content-type |
---|---|
http post |
multipart/form-data ,x-www-form-urlencoded ,application/json |
Whether authorization is required
is
Refer to theAPI authorization and authentication mechanisms
Request parameters
parameter | type | Required/optional | The default | describe |
---|---|---|---|---|
appid |
string |
necessary |
There is no | The mail application ID created in the SUBMAIL application integration |
to |
string |
optional | There is no | Recipient address (Separate multiple contacts with commas (,) : "Leo < Leo >, <retro>, [email protected]", the number of mailboxes submitted in a single request is limited to 100, SUBMAIL supports full RFC 822 recipient standard, please ensure that your email address is valid. See Wikipedia EMAIL ADDRESS RFC822 document) |
from |
e-mail |
necessary |
There is no | Sender address, standard Sender [email protected] |
from_name |
string |
optional | There is no | Submail (50 characters or less) |
reply |
e-mail |
optional | There is no | The return address(Standard reply email address: [email protected]) |
cc |
string |
optional | There is no | Cc address(Please use ", "to distinguish multiple cc addresses, and limit the number of cc contacts to 5.) . |
bcc |
string |
optional | There is no | Close to send the address(For more than one BCC address, please use ", "_ half Angle with __ _ or distinguish, please limit the number of BCC contacts to less than 5) . |
subject |
string |
necessary |
There is no | Message title (200 characters or less) |
text |
string |
optional | There is no | Plain text message body (5000 characters or less) |
html |
string |
optional | There is no | HTML Message body (less than 60 KB) |
vars |
json string |
optional | There is no | Using text variables to dynamically control text in a message, seeKnow how to create and use text variables |
links |
json string |
optional | There is no | Using hyperlink variables to dynamically control hyperlinks in messages, seeKnow how to create and use hyperlink variables |
attachments |
file | optional | There is no | Attachment (the number of files is not more than 10, the total size of the file should be less than 5 MB, this parameter is not involved in encryption calculation) |
atta |
json array |
optional | There is no | Attachment base64 format file attachments, eg: atta = [{” name “:” test. Zip “, “data” : “base64″}, {” name “:” 2 “, “data” : “base64 file”},… (Atta parameter can be used for attachment transmission in Base64 format, which is in Jason array format. Each group of data should contain name and data parameters. Name is the file name and data is the base64 data of the attachment. The number of files is not more than 10, and the total file size should be less than 5 MB. This parameter is not used in encryption calculation.) |
headers |
json string |
optional | There is no | Headers is a standard JSON string. The headers parameter allows developers to insert a custom directive (up to 500 characters long) into the header of an EMAIL. Such as: {"X-Accept-Language": "zh-cn", "X-Priority":"3","X-Mailer": "My Application"} |
asynchronous |
string |
optional | false | Asynchronous option, enable asynchronous sending mode when this value is set to true |
tag |
string |
optional | There is no | Custom tag functionality that can be used for SUBHOOK tracing (up to 32 characters) |
timestamp |
A UNIX timestamp | optional | There is no | Refer to theAPI authorization and authentication mechanism > Timestamp A UNIX timestamp |
sign_type |
string |
optional | normal |
API Authorization Mode (md5 or sha1 or normal )Refer to theAPI authorization and authentication mechanism> Authorization and authentication modes |
sign_version |
string |
optional | There is no | Signature encryption calculation method (Text, HTML, Vars, links, attachments parameters do not participate in the encryption calculation when sign_version is transmitted 2) |
signature |
string |
necessary | There is no | Apply key _ or _ digital signature |
Submail Retain the X-submail-SMTP-API directive. Do not use this directive in the EMAIL headers directive. The user-defined EMAIL headers directive usually starts with the letter X-. Apply this specification to your directives vars, links and headers parameters that require strict JSON format, JSON strings must be enclosed in double quotation marks. JSON strings must be UTF8 encoded and cannot contain extra commas, for example: [1,2,] json strings must start and end with braces {}. PS: most languages have their own json parsers (ENCODING and DECODEING methods). $var[' key ']=value; $var[' key ']=value;Copy the code
Code sample
Send a test email
POST URL
https://api.mysubmail.com/mail/send.json
Copy the code
POST DATA
appid=your_app_id & to=leo <leo> & subject=testing_Subject & text=testing_text_body & [email protected] & signature=your_app_keyCopy the code
return
{
"status":"success",
"return": [
{
"send_id": "HstDN4",
"to": "[email protected]"
}
]
}
Copy the code
Send a test email to multiple recipients
POST URL
https://api.mysubmail.com/mail/send.json
Copy the code
POST DATA
appid=your_app_id & to=leo <leo>,[email protected] & subject=testing_Subject & text=testing_text_body & [email protected] & signature=your_app_keyCopy the code
return
{
"status":"success",
"return": [
{
"send_id": "HstDN4",
"to": "[email protected]"
}
]
}
Copy the code
Send a test email using the address book
POST URL
https://api.mysubmail.com/mail/send.json
Copy the code
POST DATA
appid=your_app_id & addressbook=subscribe & subject=testing_Subject & text=testing_text_body & [email protected] & signature=your_app_keyCopy the code
return
{
"status":"success",
"return": [
{
"send_id": "HstDN4",
"to": "[email protected]"
}
]
}
Copy the code
Send a test email with an attachment
POST URL
https://api.mysubmail.com/mail/send.json
Copy the code
POST DATA
appid=your_app_id & to=leo <leo>,[email protected] & subject=testing_Subject & text=testing_text_body & [email protected] & attachments[]=/path/to/file1.txt & signature=your_app_keyCopy the code
return
{
"status":"success",
"return": [
{
"send_id": "HstDN4",
"to": "[email protected]"
}
]
}
Copy the code
useCURL
Send a test email
Send the CURL
curl -d 'appid=your_app_id& to=leo<leo> & subject=testing Subject& text=testing text body& [email protected]& signature=your_app_key' https://api.mysubmail.com/mail/send.jsonCopy the code
return
{
"status":"success",
"return": [
{
"send_id": "HstDN4",
"to": "[email protected]"
}
]
}
Copy the code
useCURL
Send a test email to multiple recipients
Send the CURL
curl -d 'appid=your_app_id& to=leo<leo> ,[email protected]& subject=testing Subject& text=testing text body& [email protected]& signature=your_app_key' https://api.mysubmail.com/mail/send.jsonCopy the code
return
{
"status":"success",
"return": [
{
"send_id": "HstDN4",
"to": "[email protected]"
}
]
}
Copy the code
useCURL
Send a test email using the addressbook recipients
Send the CURL
curl -d 'appid=your_app_id& addressbook=subscribe& subject=testing Subject& text=testing text body& [email protected]& signature=your_app_key' https://api.mysubmail.com/mail/send.jsonCopy the code
return
{
"status":"success",
"return": [
{
"send_id": "HstDN4",
"to": "[email protected]"
}
]
}
Copy the code
useCURL
Send a test email with an attachment
Send the CURL
curl https://api.mysubmail.com/mail/send.json \ -F appid=your_app_id \ -F to=leo\<leo> \ -F subject="testing subject" \ -F text="testing text body" \ --form-string html="<strong>testing html body</strong>" \ -F [email protected] \ -F from_name=SUBMAIL \ -F attachments[]=@/path/to/file1.txt \ -F attachments[]=@/path/to/file2.txt \ -F signature=your_app_key \Copy the code
return
{
"status":"success",
"return": [
{
"send_id": "HstDN4",
"to": "[email protected]"
}
]
}
Copy the code
The return value
The request is successful
{
"status":"success",
"return": [
{
"send_id": "HstDN4",
"to": "[email protected]"
}
]
}
Copy the code
The request failed
{
"status":"error",
"code":"1xx",
"msg":"error message"
}
Copy the code
The error code