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
72bcd228
Commit
72bcd228
authored
Jan 09, 2015
by
Nobuo Kihara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
docs/guide/tutorial-mailing.md - corrections [ci skip]
parent
14463b27
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
13 deletions
+13
-13
tutorial-mailing.md
docs/guide/tutorial-mailing.md
+13
-13
No files found.
docs/guide/tutorial-mailing.md
View file @
72bcd228
...
@@ -97,14 +97,14 @@ use yii\helpers\Url;
...
@@ -97,14 +97,14 @@ use yii\helpers\Url;
/* @var $message \yii\mail\BaseMessage instance of newly created mail message */
/* @var $message \yii\mail\BaseMessage instance of newly created mail message */
?>
?>
<h2>
This message allows you to visit ou
t
site home page by one click
</h2>
<h2>
This message allows you to visit ou
r
site home page by one click
</h2>
<?=
Html
::
a
(
'Go to home page'
,
Url
::
home
(
'http'
))
?>
<?=
Html
::
a
(
'Go to home page'
,
Url
::
home
(
'http'
))
?>
```
```
In order to compose message content via view file simply pass view name to the
`compose()`
method:
In order to compose message content via view file simply pass view name to the
`compose()`
method:
```
php
```
php
Yii
::
$app
->
mailer
->
compose
(
'home-link'
)
//
message body becomes a view rendering result
here
Yii
::
$app
->
mailer
->
compose
(
'home-link'
)
//
a view rendering result becomes the message body
here
->
setFrom
(
'from@domain.com'
)
->
setFrom
(
'from@domain.com'
)
->
setTo
(
'to@domain.com'
)
->
setTo
(
'to@domain.com'
)
->
setSubject
(
'Message subject'
)
->
setSubject
(
'Message subject'
)
...
@@ -183,8 +183,8 @@ $message->attachContent('Attachment content', ['fileName' => 'attach.txt', 'cont
...
@@ -183,8 +183,8 @@ $message->attachContent('Attachment content', ['fileName' => 'attach.txt', 'cont
```
```
Embed images
Embed
ding
images
------------
------------
----
You can embed images into the message content using
`embed()`
method. This method returns the attachment id,
You can embed images into the message content using
`embed()`
method. This method returns the attachment id,
which should be then used at 'img' tag.
which should be then used at 'img' tag.
...
@@ -196,7 +196,7 @@ Yii::$app->mailer->compose('embed-email', ['imageFileName' => '/path/to/image.jp
...
@@ -196,7 +196,7 @@ Yii::$app->mailer->compose('embed-email', ['imageFileName' => '/path/to/image.jp
->
send
();
->
send
();
```
```
Then inside
view file you can us
e following code:
Then inside
the view file you can use th
e following code:
```
php
```
php
<img
src=
"
<?=
$message
->
embed
(
$imageFileName
);
?>
"
>
<img
src=
"
<?=
$message
->
embed
(
$imageFileName
);
?>
"
>
...
@@ -206,17 +206,17 @@ Then inside view file you can use following code:
...
@@ -206,17 +206,17 @@ Then inside view file you can use following code:
Testing and debugging
Testing and debugging
---------------------
---------------------
Developer often a to check, what actual emails are sent by
application, what was their content and so on.
A developer often has to check, what actual emails are sent by the
application, what was their content and so on.
Such ability is granted by Yii via
`yii\mail\BaseMailer::useFileTransport`
. If enabled, this option enforces
Such ability is granted by Yii via
`yii\mail\BaseMailer::useFileTransport`
. If enabled, this option enforces
saving mail message data into the local files instead of regular sending. These files will be saved under
saving mail message data into the local files instead of regular sending. These files will be saved under
`yii\mail\BaseMailer::fileTransportPath`
, which is '@runtime/mail' by default.
`yii\mail\BaseMailer::fileTransportPath`
, which is '@runtime/mail' by default.
> Note: you can either save
messages to the file or send them to
actual recipients, but can not do both simultaneously.
> Note: you can either save
the messages to the files or send them to the
actual recipients, but can not do both simultaneously.
Mail message file can be opened by regular text file editor, so you can brows
e actual message headers, content and so on.
A mail message file can be opened by a regular text file editor, so you can browse th
e actual message headers, content and so on.
This mechanism
am
y prove itself, while debugging application or running unit test.
This mechanism
ma
y prove itself, while debugging application or running unit test.
> Note:
mail message file content is composed via `\yii\mail\MessageInterface::toString()`, so it depends on
actual
> Note:
the mail message file content is composed via `\yii\mail\MessageInterface::toString()`, so it depends on the
actual
mail extension you are using in your application.
mail extension you are using in your application.
...
@@ -225,7 +225,7 @@ Creating your own mail solution
...
@@ -225,7 +225,7 @@ Creating your own mail solution
In order to create your own custom mail solution, you need to create 2 classes: one for the 'Mailer' and
In order to create your own custom mail solution, you need to create 2 classes: one for the 'Mailer' and
another one for the 'Message'.
another one for the 'Message'.
You can use
`yii\mail\BaseMailer`
and
`yii\mail\BaseMessage`
as
a
base classes for your solution. These classes
You can use
`yii\mail\BaseMailer`
and
`yii\mail\BaseMessage`
as
the
base classes for your solution. These classes
already contain
s
basic logic, which is described in this guide. However, their usage is not mandatory, it is enough
already contain
the
basic logic, which is described in this guide. However, their usage is not mandatory, it is enough
to implement
`yii\mail\MailerInterface`
and
`yii\mail\MessageInterface`
interfaces.
to implement
`yii\mail\MailerInterface`
and
`yii\mail\MessageInterface`
interfaces.
Then you need to implement all
abstract methods to build you
solution.
Then you need to implement all
the abstract methods to build your
solution.
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