|
|
|
|
@ -216,6 +216,53 @@ class EmailRecordController extends BaseController
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @OA\Post(
|
|
|
|
|
* path="/api/admin/email-record/send-example",
|
|
|
|
|
* tags={"邮件发送配置"},
|
|
|
|
|
* summary="发送测试邮件",
|
|
|
|
|
* description="",
|
|
|
|
|
* @OA\Parameter(name="email_template_id", in="query", @OA\Schema(type="integer", format="int64"), required=true, description="模版id"),
|
|
|
|
|
* @OA\Parameter(name="subject", in="query", @OA\Schema(type="string", format="date"), required=false, description="标题"),
|
|
|
|
|
* @OA\Parameter(name="email", in="query", @OA\Schema(type="string", format="date"), required=false, description="邮箱地址"),
|
|
|
|
|
* @OA\Parameter(name="var_data", in="query", @OA\Schema(type="string", format="mediumtext"), required=false, description="数组,var_data自定义数据"),
|
|
|
|
|
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="认证token"),
|
|
|
|
|
* @OA\Response(
|
|
|
|
|
* response="200",
|
|
|
|
|
* description="操作成功"
|
|
|
|
|
* )
|
|
|
|
|
* )
|
|
|
|
|
*/
|
|
|
|
|
public function sendExample()
|
|
|
|
|
{
|
|
|
|
|
$all = \request()->all();
|
|
|
|
|
$validator = Validator::make($all, [
|
|
|
|
|
'email_template_id' => 'required',
|
|
|
|
|
'subject' => 'required',
|
|
|
|
|
'email' => 'required',
|
|
|
|
|
'var_data' => 'required',
|
|
|
|
|
]);
|
|
|
|
|
if ($validator->fails()) {
|
|
|
|
|
return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
$emailTemplate = EmailTemplate::find($all['email_template_id']);
|
|
|
|
|
// 替换后的标题
|
|
|
|
|
$title = EmailRecordUser::template($all['subject'], $all['var_data']);
|
|
|
|
|
// 替换后的内容
|
|
|
|
|
$template = EmailRecordUser::template($emailTemplate->content, $all['var_data']);
|
|
|
|
|
try {
|
|
|
|
|
// 发送邮件
|
|
|
|
|
EmailRecordUser::email($title, $template, $all['email']);
|
|
|
|
|
return $this->success("发送成功");
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
return $this->fail([ResponseCode::ERROR_BUSINESS, $e->getMessage()]);
|
|
|
|
|
}
|
|
|
|
|
} catch (\Exception $exception) {
|
|
|
|
|
return $this->fail([$exception->getCode(), $exception->getMessage()]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @OA\Get(
|
|
|
|
|
* path="/api/admin/email-record/destroy",
|
|
|
|
|
|