发送邮件API
开始之前你需要准备以下数据
- 邮箱的授权码
- 邮箱的用户名
- 邮箱的密码
接口详情
调用方式:GET,POST
接口地址
http://api.zlovey.cn/email
接口参数
参数名称 | 类型 | 是否必填 | 说明 |
---|---|---|---|
smtp_server | string | 是 | 邮箱服务器,比如QQ邮箱为 smtp.qq.com |
smtp_port | string | 是 | 邮箱的端口,587或者465 |
smtp_pwd | string | 是 | 邮箱的授权码 |
sender_email | string | 是 | 发件人邮箱 |
recipient_email | string | 是 | 收件人邮箱 |
subject | string | 是 | 邮箱主题 |
message | string | 是 | 邮件内容 |
调用示例
直接调用
shell
http://api.zlovey.cn/email?smtp_server=smtp.qq.com&smtp_port=587&smtp_pwd=邮箱授权码&sender_email=收信人邮箱&recipient_email=收信人邮箱&subject=邮箱主题&message=邮箱内容
python调用
python
import requests
url = "http://api.zlovey.cn/email"
querystring = {"smtp_server":"smtp.qq.com","smtp_port":"587","smtp_pwd":"邮箱授权码","sender_email":"发信人邮箱","recipient_email":"收信人邮箱","subject":"主题","message":"测试邮件"}
response = requests.request("GET", url, data=payload)
print(response.text)
php调用
php
<?php
$client = new http\Client;
$request = new http\Client\Request;
$body = new http\Message\Body;
$body->addForm([
'smtp_server' => 'smtp.qq.com',
'smtp_port' => '587',
'smtp_pwd' => '邮箱授权码',
'sender_email' => '发信人邮箱',
'recipient_email' => '收信人邮箱',
'subject' => '1223',
'message' => '5646'
], null);
$request->setRequestUrl('http://api.zlovey.cn/email');
$request->setRequestMethod('GET');
$request->setBody($body);
$request->setQuery(new http\QueryString([
'smtp_server' => 'smtp.qq.com',
'smtp_port' => '587',
'smtp_pwd' => '邮箱授权码',
'sender_email' => '发信人邮箱',
'recipient_email' => '收信人邮箱',
'subject' => '主题',
'message' => '测试邮件'
]));
$request->setHeaders([
'smtp_server' => 'smtp.qq.com'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
返回示例
json
{
"code": 200,
"msg": "邮件发送成功"
}