Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
L
laravelzh
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
冯超鹏
laravelzh
Commits
18d7a190
Commit
18d7a190
authored
Oct 10, 2020
by
冯超鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
邮箱验证码操作
parent
b8daf0ca
Pipeline
#149
failed with stages
Changes
7
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
6883 additions
and
22 deletions
+6883
-22
UinappHomeController.php
app/Http/Controllers/UinappHomeController.php
+53
-16
Exception.php
app/Http/Controllers/src/Exception.php
+39
-0
OAuth.php
app/Http/Controllers/src/OAuth.php
+138
-0
PHPMailer.php
app/Http/Controllers/src/PHPMailer.php
+4834
-0
POP3.php
app/Http/Controllers/src/POP3.php
+421
-0
SMTP.php
app/Http/Controllers/src/SMTP.php
+1392
-0
mail.php
config/mail.php
+6
-6
No files found.
app/Http/Controllers/UinappHomeController.php
View file @
18d7a190
...
@@ -16,7 +16,8 @@ use Illuminate\Support\Facades\Auth;
...
@@ -16,7 +16,8 @@ use Illuminate\Support\Facades\Auth;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\Hash
;
use
Illuminate\Support\Facades\Hash
;
use
Illuminate\Support\Facades\Redis
;
use
Illuminate\Support\Facades\Redis
;
use
Mail
;
use
App\Http\Controllers\src\PHPMailer
;
use
App\Http\Controllers\src\Exception
;
use
Validator
;
use
Validator
;
class
UinappHomeController
extends
Controller
class
UinappHomeController
extends
Controller
...
@@ -113,36 +114,39 @@ class UinappHomeController extends Controller
...
@@ -113,36 +114,39 @@ class UinappHomeController extends Controller
public
function
isemail
(
Request
$request
)
public
function
isemail
(
Request
$request
)
{
{
$isemail
=
$request
->
input
(
'email'
);
$isemail
=
$request
->
input
(
'email'
);
$data
=
DB
::
table
(
'users'
)
->
where
(
'email'
,
'='
,
$isemail
)
->
first
();
$data
=
DB
::
table
(
'users'
)
->
where
(
'email'
,
'='
,
$isemail
)
->
first
();
if
(
$data
)
{
if
(
$data
)
{
return
$this
->
jsonSuccessData
(
1
);
return
$this
->
jsonSuccessData
(
1
);
}
else
{
}
else
{
return
$this
->
jsonSuccessData
(
2
);
return
$this
->
jsonSuccessData
(
2
);
}
}
}
}
public
function
ispassword
(
Request
$request
){
public
function
ispassword
(
Request
$request
)
{
$password
=
$request
->
input
(
'password'
);
$password
=
$request
->
input
(
'password'
);
$isemail
=
$request
->
input
(
'email'
);
$isemail
=
$request
->
input
(
'email'
);
$data
=
DB
::
table
(
'users'
)
->
where
(
'email'
,
'='
,
$isemail
)
->
update
([
'password'
=>
Hash
::
make
(
$password
)]);
$data
=
DB
::
table
(
'users'
)
->
where
(
'email'
,
'='
,
$isemail
)
->
update
([
'password'
=>
Hash
::
make
(
$password
)]);
if
(
$data
!==
false
)
{
if
(
$data
!==
false
)
{
return
$this
->
jsonSuccessData
(
1
);
return
$this
->
jsonSuccessData
(
1
);
}
else
{
}
else
{
return
$this
->
jsonSuccessData
(
2
);
return
$this
->
jsonSuccessData
(
2
);
}
}
}
}
// 发送邮箱验证
// 发送邮箱验证
public
function
mails
(
Request
$request
){
public
function
mails
(
Request
$request
)
{
$isemail
=
$request
->
input
(
'email'
);
$isemail
=
$request
->
input
(
'email'
);
Mail
::
raw
(
'你好,我是PHP程序!'
,
function
(
$message
)
{
$num
=
str_pad
(
mt_rand
(
0
,
999999
),
6
,
"0"
,
STR_PAD_BOTH
);
$to
=
'1431670879@qq.com'
;
if
(
$isemail
!=
''
){
$message
->
to
(
$to
)
->
subject
(
'纯文本信息邮件测试'
);
$send
=
$this
->
PHPMailer
(
$isemail
,
$num
);
});
if
(
$send
==
200
){
// vwhmtzucgpcjbfha
return
$this
->
jsonSuccessData
(
$num
);
// sahaqcyksulsbaie
}
}
}
}
//监测是否是汉子
//监测是否是汉子
private
function
isKanji
(
$str
)
private
function
isKanji
(
$str
)
{
{
...
@@ -152,6 +156,39 @@ class UinappHomeController extends Controller
...
@@ -152,6 +156,39 @@ class UinappHomeController extends Controller
return
false
;
return
false
;
}
}
}
}
/*
* $name 发件人
* $num 随机字符串 验证码
* */
private
function
PHPMailer
(
$name
,
$num
)
{
include_once
app_path
()
.
'/Http/Controllers/src/PHPMailer.php'
;
include_once
app_path
()
.
'/Http/Controllers/src/SMTP.php'
;
$mail
=
new
PHPMailer
(
true
);
try
{
//服务器配置
$mail
->
CharSet
=
"UTF-8"
;
//设定邮件编码
$mail
->
SMTPDebug
=
0
;
// 调试模式输出
$mail
->
isSMTP
();
// 使用SMTP
$mail
->
Host
=
'smtp.qq.com'
;
// SMTP服务器
$mail
->
SMTPAuth
=
true
;
// 允许 SMTP 认证
$mail
->
Username
=
'2758505256@qq.com'
;
// SMTP 用户名 即邮箱的用户名
$mail
->
Password
=
'qekjtybbeswsdhec'
;
// SMTP 密码 部分邮箱是授权码(例如163邮箱)
$mail
->
SMTPSecure
=
'ssl'
;
// 允许 TLS 或者ssl协议
$mail
->
Port
=
465
;
$mail
->
setFrom
(
'2758505256@qq.com'
,
'河北泽宏科技股份有限公司'
);
//发件人
$mail
->
addAddress
(
$name
);
// 可添加多个收件人
$mail
->
isHTML
(
true
);
// 是否以HTML文档格式发送 发送后客户端可直接显示对应HTML内容
$mail
->
Subject
=
'找回密码操作'
;
$mail
->
Body
=
"<h3>您的验证码是:</h3><h1>
$num
</h1>"
.
date
(
'Y-m-d H:i:s'
);
$mail
->
AltBody
=
'如果邮件客户端不支持HTML则显示此内容'
;
$mail
->
send
();
return
200
;
}
catch
(
Exception
$e
)
{
return
105
.
$mail
->
ErrorInfo
;
}
}
//主页home的
//主页home的
}
}
\ No newline at end of file
app/Http/Controllers/src/Exception.php
0 → 100644
View file @
18d7a190
<?php
/**
* PHPMailer Exception class.
* PHP Version 5.5.
*
* @see https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
*
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2012 - 2017 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
* @note This program is distributed in the hope that it will be useful - WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*/
namespace
App\Http\Controllers\src
;
/**
* PHPMailer exception handler.
*
* @author Marcus Bointon <phpmailer@synchromedia.co.uk>
*/
class
Exception
extends
\Exception
{
/**
* Prettify error message output.
*
* @return string
*/
public
function
errorMessage
()
{
return
'<strong>'
.
htmlspecialchars
(
$this
->
getMessage
())
.
"</strong><br />
\n
"
;
}
}
app/Http/Controllers/src/OAuth.php
0 → 100644
View file @
18d7a190
<?php
/**
* PHPMailer - PHP email creation and transport class.
* PHP Version 5.5.
*
* @see https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
*
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2012 - 2015 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
* @note This program is distributed in the hope that it will be useful - WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*/
namespace
App\Http\Controllers\src
;
use
League\OAuth2\Client\Grant\RefreshToken
;
use
League\OAuth2\Client\Provider\AbstractProvider
;
use
League\OAuth2\Client\Token\AccessToken
;
/**
* OAuth - OAuth2 authentication wrapper class.
* Uses the oauth2-client package from the League of Extraordinary Packages.
*
* @see http://oauth2-client.thephpleague.com
*
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
*/
class
OAuth
{
/**
* An instance of the League OAuth Client Provider.
*
* @var AbstractProvider
*/
protected
$provider
;
/**
* The current OAuth access token.
*
* @var AccessToken
*/
protected
$oauthToken
;
/**
* The user's email address, usually used as the login ID
* and also the from address when sending email.
*
* @var string
*/
protected
$oauthUserEmail
=
''
;
/**
* The client secret, generated in the app definition of the service you're connecting to.
*
* @var string
*/
protected
$oauthClientSecret
=
''
;
/**
* The client ID, generated in the app definition of the service you're connecting to.
*
* @var string
*/
protected
$oauthClientId
=
''
;
/**
* The refresh token, used to obtain new AccessTokens.
*
* @var string
*/
protected
$oauthRefreshToken
=
''
;
/**
* OAuth constructor.
*
* @param array $options Associative array containing
* `provider`, `userName`, `clientSecret`, `clientId` and `refreshToken` elements
*/
public
function
__construct
(
$options
)
{
$this
->
provider
=
$options
[
'provider'
];
$this
->
oauthUserEmail
=
$options
[
'userName'
];
$this
->
oauthClientSecret
=
$options
[
'clientSecret'
];
$this
->
oauthClientId
=
$options
[
'clientId'
];
$this
->
oauthRefreshToken
=
$options
[
'refreshToken'
];
}
/**
* Get a new RefreshToken.
*
* @return RefreshToken
*/
protected
function
getGrant
()
{
return
new
RefreshToken
();
}
/**
* Get a new AccessToken.
*
* @return AccessToken
*/
protected
function
getToken
()
{
return
$this
->
provider
->
getAccessToken
(
$this
->
getGrant
(),
[
'refresh_token'
=>
$this
->
oauthRefreshToken
]
);
}
/**
* Generate a base64-encoded OAuth token.
*
* @return string
*/
public
function
getOauth64
()
{
// Get a new token if it's not available or has expired
if
(
null
===
$this
->
oauthToken
||
$this
->
oauthToken
->
hasExpired
())
{
$this
->
oauthToken
=
$this
->
getToken
();
}
return
base64_encode
(
'user='
.
$this
->
oauthUserEmail
.
"
\001
auth=Bearer "
.
$this
->
oauthToken
.
"
\001\001
"
);
}
}
app/Http/Controllers/src/PHPMailer.php
0 → 100644
View file @
18d7a190
This diff is collapsed.
Click to expand it.
app/Http/Controllers/src/POP3.php
0 → 100644
View file @
18d7a190
This diff is collapsed.
Click to expand it.
app/Http/Controllers/src/SMTP.php
0 → 100644
View file @
18d7a190
This diff is collapsed.
Click to expand it.
config/mail.php
View file @
18d7a190
...
@@ -29,7 +29,7 @@ return [
...
@@ -29,7 +29,7 @@ return [
|
|
*/
*/
'host'
=>
env
(
'MAIL_HOST'
,
'smtp.
163
.com'
),
'host'
=>
env
(
'MAIL_HOST'
,
'smtp.
qq
.com'
),
/*
/*
|--------------------------------------------------------------------------
|--------------------------------------------------------------------------
...
@@ -42,7 +42,7 @@ return [
...
@@ -42,7 +42,7 @@ return [
|
|
*/
*/
'port'
=>
env
(
'MAIL_PORT'
),
'port'
=>
env
(
'MAIL_PORT'
,
'465'
),
/*
/*
|--------------------------------------------------------------------------
|--------------------------------------------------------------------------
...
@@ -56,7 +56,7 @@ return [
...
@@ -56,7 +56,7 @@ return [
*/
*/
'from'
=>
[
'from'
=>
[
'address'
=>
env
(
'MAIL_FROM_ADDRESS'
,
'
16631150870@163
.com'
),
'address'
=>
env
(
'MAIL_FROM_ADDRESS'
,
'
2758505256@qq
.com'
),
'name'
=>
env
(
'MAIL_FROM_NAME'
,
'邮件发送'
),
'name'
=>
env
(
'MAIL_FROM_NAME'
,
'邮件发送'
),
],
],
...
@@ -71,7 +71,7 @@ return [
...
@@ -71,7 +71,7 @@ return [
|
|
*/
*/
'encryption'
=>
env
(
'MAIL_ENCRYPTION'
,
'
SSL
'
),
'encryption'
=>
env
(
'MAIL_ENCRYPTION'
,
'
ssl
'
),
/*
/*
|--------------------------------------------------------------------------
|--------------------------------------------------------------------------
...
@@ -84,9 +84,9 @@ return [
...
@@ -84,9 +84,9 @@ return [
|
|
*/
*/
'username'
=>
env
(
'MAIL_USERNAME'
,
'
16631150870@163
.com'
),
'username'
=>
env
(
'MAIL_USERNAME'
,
'
2758505256@qq
.com'
),
'password'
=>
env
(
'MAIL_PASSWORD'
,
'
KXFOEZZRXPFNMKHK
'
),
'password'
=>
env
(
'MAIL_PASSWORD'
,
'
qekjtybbeswsdhec
'
),
/*
/*
|--------------------------------------------------------------------------
|--------------------------------------------------------------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment