Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
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
PSDI Army
yii2
Commits
998cf7e6
Commit
998cf7e6
authored
Nov 07, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated apps to use the mail component.
parent
97630868
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
27 additions
and
14 deletions
+27
-14
main.php
apps/advanced/backend/config/main.php
+1
-0
params.php
apps/advanced/common/config/params.php
+4
-0
composer.json
apps/advanced/composer.json
+1
-0
main.php
apps/advanced/console/config/main.php
+1
-0
main.php
apps/advanced/frontend/config/main.php
+1
-0
SiteController.php
apps/advanced/frontend/controllers/SiteController.php
+1
-0
ContactForm.php
apps/advanced/frontend/models/ContactForm.php
+7
-7
composer.json
apps/basic/composer.json
+1
-0
web.php
apps/basic/config/web.php
+3
-0
ContactForm.php
apps/basic/models/ContactForm.php
+7
-7
No files found.
apps/advanced/backend/config/main.php
View file @
998cf7e6
...
...
@@ -22,6 +22,7 @@ return [
],
'db'
=>
$params
[
'components.db'
],
'cache'
=>
$params
[
'components.cache'
],
'mail'
=>
$params
[
'components.mail'
],
'user'
=>
[
'identityClass'
=>
'common\models\User'
,
],
...
...
apps/advanced/common/config/params.php
View file @
998cf7e6
...
...
@@ -12,6 +12,10 @@ return [
'class'
=>
'yii\caching\FileCache'
,
],
'components.mail'
=>
[
'class'
=>
'yii\swiftmailer\Mailer'
,
],
'components.db'
=>
[
'class'
=>
'yii\db\Connection'
,
'dsn'
=>
'mysql:host=localhost;dbname=yii2advanced'
,
...
...
apps/advanced/composer.json
View file @
998cf7e6
...
...
@@ -16,6 +16,7 @@
"require"
:
{
"php"
:
">=5.4.0"
,
"yiisoft/yii2"
:
"dev-master"
,
"yiisoft/yii2-swiftmailer"
:
"dev-master"
,
"yiisoft/yii2-bootstrap"
:
"dev-master"
,
"yiisoft/yii2-debug"
:
"dev-master"
,
"yiisoft/yii2-gii"
:
"dev-master"
...
...
apps/advanced/console/config/main.php
View file @
998cf7e6
...
...
@@ -19,6 +19,7 @@ return [
'components'
=>
[
'db'
=>
$params
[
'components.db'
],
'cache'
=>
$params
[
'components.cache'
],
'mail'
=>
$params
[
'components.mail'
],
'log'
=>
[
'targets'
=>
[
[
...
...
apps/advanced/frontend/config/main.php
View file @
998cf7e6
...
...
@@ -23,6 +23,7 @@ return [
],
'db'
=>
$params
[
'components.db'
],
'cache'
=>
$params
[
'components.cache'
],
'mail'
=>
$params
[
'components.mail'
],
'user'
=>
[
'identityClass'
=>
'common\models\User'
,
],
...
...
apps/advanced/frontend/controllers/SiteController.php
View file @
998cf7e6
...
...
@@ -159,6 +159,7 @@ class SiteController extends Controller
$user
->
password_reset_token
=
Security
::
generateRandomKey
();
if
(
$user
->
save
(
false
))
{
// todo: refactor it with mail component. pay attention to the arrangement of mail view files
$fromEmail
=
\Yii
::
$app
->
params
[
'supportEmail'
];
$name
=
'=?UTF-8?B?'
.
base64_encode
(
\Yii
::
$app
->
name
.
' robot'
)
.
'?='
;
$subject
=
'=?UTF-8?B?'
.
base64_encode
(
'Password reset for '
.
\Yii
::
$app
->
name
)
.
'?='
;
...
...
apps/advanced/frontend/models/ContactForm.php
View file @
998cf7e6
...
...
@@ -2,6 +2,7 @@
namespace
frontend\models
;
use
Yii
;
use
yii\base\Model
;
/**
...
...
@@ -48,13 +49,12 @@ class ContactForm extends Model
public
function
contact
(
$email
)
{
if
(
$this
->
validate
())
{
$name
=
'=?UTF-8?B?'
.
base64_encode
(
$this
->
name
)
.
'?='
;
$subject
=
'=?UTF-8?B?'
.
base64_encode
(
$this
->
subject
)
.
'?='
;
$headers
=
"From:
$name
<
{
$this
->
email
}
>
\r\n
"
.
"Reply-To:
{
$this
->
email
}
\r\n
"
.
"MIME-Version: 1.0
\r\n
"
.
"Content-type: text/plain; charset=UTF-8"
;
mail
(
$email
,
$subject
,
$this
->
body
,
$headers
);
Yii
::
$app
->
mail
->
compose
()
->
setTo
(
$email
)
->
setFrom
([
$this
->
email
=>
$this
->
name
])
->
setSubject
(
$this
->
subject
)
->
setTextBody
(
$this
->
body
)
->
send
();
return
true
;
}
else
{
return
false
;
...
...
apps/basic/composer.json
View file @
998cf7e6
...
...
@@ -16,6 +16,7 @@
"require"
:
{
"php"
:
">=5.4.0"
,
"yiisoft/yii2"
:
"dev-master"
,
"yiisoft/yii2-swiftmailer"
:
"dev-master"
,
"yiisoft/yii2-bootstrap"
:
"dev-master"
,
"yiisoft/yii2-debug"
:
"dev-master"
,
"yiisoft/yii2-gii"
:
"dev-master"
...
...
apps/basic/config/web.php
View file @
998cf7e6
...
...
@@ -17,6 +17,9 @@ $config = [
'errorHandler'
=>
[
'errorAction'
=>
'site/error'
,
],
'mail'
=>
[
'class'
=>
'yii\swiftmailer\Mailer'
,
],
'log'
=>
[
'traceLevel'
=>
YII_DEBUG
?
3
:
0
,
'targets'
=>
[
...
...
apps/basic/models/ContactForm.php
View file @
998cf7e6
...
...
@@ -2,6 +2,7 @@
namespace
app\models
;
use
Yii
;
use
yii\base\Model
;
/**
...
...
@@ -48,13 +49,12 @@ class ContactForm extends Model
public
function
contact
(
$email
)
{
if
(
$this
->
validate
())
{
$name
=
'=?UTF-8?B?'
.
base64_encode
(
$this
->
name
)
.
'?='
;
$subject
=
'=?UTF-8?B?'
.
base64_encode
(
$this
->
subject
)
.
'?='
;
$headers
=
"From:
$name
<
{
$this
->
email
}
>
\r\n
"
.
"Reply-To:
{
$this
->
email
}
\r\n
"
.
"MIME-Version: 1.0
\r\n
"
.
"Content-type: text/plain; charset=UTF-8"
;
mail
(
$email
,
$subject
,
$this
->
body
,
$headers
);
Yii
::
$app
->
mail
->
compose
()
->
setTo
(
$email
)
->
setFrom
([
$this
->
email
=>
$this
->
name
])
->
setSubject
(
$this
->
subject
)
->
setTextBody
(
$this
->
body
)
->
send
();
return
true
;
}
else
{
return
false
;
...
...
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