Skip to content

发送邮件API

开始之前你需要准备以下数据

  1. 邮箱的授权码
  2. 邮箱的用户名
  3. 邮箱的密码

接口详情

调用方式:GET,POST

接口地址

http://api.zlovey.cn/email

接口参数

参数名称类型是否必填说明
smtp_serverstring邮箱服务器,比如QQ邮箱为 smtp.qq.com
smtp_portstring邮箱的端口,587或者465
smtp_pwdstring邮箱的授权码
sender_emailstring发件人邮箱
recipient_emailstring收件人邮箱
subjectstring邮箱主题
messagestring邮件内容

调用示例

直接调用
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": "邮件发送成功"
}