# 代码示例
以下为各种语言使用 API V2 发送邮件的示例.
# Python
# Java
依赖 WEBAPI_4.2代码示例需要依赖如下jar包 httpclient4.2
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.2</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20140107</version>
</dependency>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
WEBAPI_4.4代码示例需要依赖如下jar包 httpclient4.4
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.4</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.4</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20140107</version>
</dependency>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
httpclient (opens new window) httpmime (opens new window) org.json (opens new window)
# PHP
# Ruby
依赖 代码需要安装rest-client
gem install 'rest-client'
1
# Perl
依赖 模板发送需要依赖json包
从CPAN下载安装
https://metacpan.org/pod/JSON
1
2
2
# CSharp
# Go
# Nodejs
package.json
{
"name": "1.node-demo",
"version": "1.0.0",
"description": "",
"main": "1.sendEmail.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^1.1.3",
"form-data": "^4.0.0",
"nodemailer": "^6.8.0"
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17