切换导航条
此项目
正在载入...
登录
周海龙
/
mail-serve
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
邓超
2 years ago
提交
1eb6de51a5f0ed337b2c99746fc56c3091354523
1 个父辈
5838edb0
1
隐藏空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
131 行增加
和
52 行删除
controller/Base.php
controller/Folder.php
controller/Home.php
lib/Mail/MailFun.php
route.php
controller/Base.php
查看文件 @
1eb6de5
...
...
@@ -3,6 +3,8 @@
namespace
Controller
;
use
Model\emailSql
;
/**
* 基础控制器,根据需求 可以不继承此类
* @author:dc
...
...
@@ -12,7 +14,25 @@ namespace Controller;
*/
abstract
class
Base
{
/**
* 当前登录的邮箱
* @var array[]
*/
protected
$login_email
;
/**
* 构造
* Home constructor.
*/
public
function
__construct
()
{
// 获取 当前请求的 邮箱
$this
->
login_email
=
db
()
->
first
(
emailSql
::
firstByToken
(
token
()));
if
(
!
$this
->
login_email
){
app
()
->
e
(
'token_verify_notfound'
);
}
}
...
...
controller/Folder.php
0 → 100644
查看文件 @
1eb6de5
<?php
namespace
Controller
;
/**
* 文件夹管理
* @author:dc
* @time 2023/2/18 17:58
* Class Folder
* @package Controller
*/
class
Folder
extends
Base
{
/**
* 邮箱文件夹
* @author:dc
* @time 2023/2/18 10:58
*/
public
function
lists
(){
// 查询
$folders
=
db
()
->
all
(
\Model\folderSql
::
all
(
$this
->
login_email
[
'id'
],
'`id`,`folder`,`pid`'
)
);
// 转tree
$folders
=
list_to_tree
(
$folders
);
app
()
->
_json
(
$folders
);
}
/**
* 创建 目录
* @author:dc
* @time 2023/2/18 17:56
*/
public
function
create
(){
}
}
...
...
controller/Home.php
查看文件 @
1eb6de5
...
...
@@ -2,6 +2,7 @@
namespace
Controller
;
use
Lib\Mail\MailFun
;
use
Model\emailSql
;
use
Model\listsSql
;
...
...
@@ -11,27 +12,8 @@ use Model\listsSql;
* Class Home
* @package Controller
*/
class
Home
{
class
Home
extends
Base
{
/**
* 当前登录的邮箱
* @var array[]
*/
private
$login_email
;
/**
* 构造
* Home constructor.
*/
public
function
__construct
()
{
// 获取 当前请求的 邮箱
$this
->
login_email
=
db
()
->
first
(
emailSql
::
firstByToken
(
token
()));
if
(
!
$this
->
login_email
){
app
()
->
e
(
'token_verify_notfound'
);
}
}
/**
* 邮件列表
...
...
@@ -51,29 +33,21 @@ class Home {
}
/**
*
邮箱文件夹
*
发送邮件
* @author:dc
* @time 2023/2/18 1
0:58
* @time 2023/2/18 1
7:32
*/
public
function
folder
(){
// 查询
$folders
=
db
()
->
all
(
\Model\folderSql
::
all
(
$this
->
login_email
[
'id'
],
'`id`,`folder`,`pid`'
)
);
// 转tree
$folders
=
list_to_tree
(
$folders
);
app
()
->
_json
(
$folders
);
}
public
function
send_mail
(){
$ret
=
MailFun
::
sendEmail
();
if
(
$ret
[
0
]
===
true
)
{
app
()
->
_json
([
'messageId'
=>
$ret
[
1
]]);
}
else
{
app
()
->
e
(
$ret
[
1
]);
}
}
...
...
lib/Mail/MailFun.php
查看文件 @
1eb6de5
...
...
@@ -121,6 +121,7 @@ class MailFun {
/**
* 发送邮件
* @param string $smtp smtp服务器地址
* @param string $username 发件人
* @param string $password 发件人密码
...
...
@@ -131,17 +132,17 @@ class MailFun {
* @param array $files 文件 ['origin_name'=>'','path'=>'']
* @param false $receipt 是否回执
* @param int $priority 是否紧急 1紧急 3正常 5慢
* @return
bool
* @return
array
* @throws \PHPMailer\PHPMailer\Exception
* @author:dc
* @time 202
2/11/11 14:26
* @time 202
3/2/18 17:45
*/
public
static
function
sendEmail
(
string
$smtp
,
string
$username
,
string
$password
,
string
$nickname
,
$to_email
,
string
$subject
,
string
$body
,
$files
=
[],
$receipt
=
false
,
$priority
=
3
){
public
static
function
sendEmail
(
string
$smtp
,
string
$username
,
string
$password
,
string
$nickname
,
string
|
array
$to_email
,
string
$subject
,
string
$body
,
$files
=
[],
$receipt
=
false
,
$priority
=
3
){
// 邮件对象
$mail
=
new
PHPMailer
(
true
);
$mail
=
new
PHPMailer
();
//Server settings
$mail
->
SMTPDebug
=
SMTP
::
DEBUG_
CLIENT
;
//调试输出 SMTP::DEBUG_SERVER; //Enable verbose debug output
$mail
->
SMTPDebug
=
SMTP
::
DEBUG_
OFF
;
//调试输出 SMTP::DEBUG_SERVER; //Enable verbose debug output
$mail
->
isSMTP
();
//Send using SMTP
$mail
->
Host
=
$smtp
;
//Set the SMTP server to send through
$mail
->
SMTPAuth
=
true
;
//Enable SMTP authentication
...
...
@@ -193,10 +194,10 @@ class MailFun {
// 发送
if
(
$mail
->
send
()){
return
true
;
return
[
true
,
$mail
->
getLastMessageID
()]
;
}
throw
new
\Exception
(
$mail
->
ErrorInfo
,
500
)
;
return
[
false
,
$mail
->
ErrorInfo
]
;
}
...
...
route.php
查看文件 @
1eb6de5
...
...
@@ -14,7 +14,7 @@ return [
* @param string imap imap服务器地址
* @param string smtp smtp服务器地址
*/
'login'
=>
[
\Controller\Login
::
class
,
'login'
],
'login'
=>
[
\Controller\Login
::
class
,
'login'
],
/**
* 邮件列表
...
...
@@ -22,13 +22,30 @@ return [
* @param string _token_ token登录凭证
* @param int page 当前页数
*/
'mail/list'
=>
[
\Controller\Home
::
class
,
'lists'
],
'mail/list'
=>
[
\Controller\Home
::
class
,
'lists'
],
/**
* 邮件文件夹
* @see \Controller\
Home::folder
()
* @see \Controller\
Folder::lists
()
* @param string _token_ token登录凭证
*/
'mail/folder'
=>
[
\Controller\Home
::
class
,
'folder'
],
'mail/folder'
=>
[
\Controller\Folder
::
class
,
'lists'
],
/**
* 邮件/创建文件夹
* @see \Controller\Folder::create()
* @param string _token_ token登录凭证
*/
'mail/folder/create'
=>
[
\Controller\Folder
::
class
,
'create'
],
/**
* 发送邮件
* @see \Controller\Home::send_mail()
* @param string _token_ token登录凭证
*/
'mail/send'
=>
[
\Controller\Home
::
class
,
'send_mail'
],
];
];
\ No newline at end of file
...
...
请
注册
或
登录
后发表评论