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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
25832338
Commit
25832338
authored
Jan 09, 2015
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6806 from softark/docs-guide-tutorial-mailing-fix
docs/guide/tutorial-mailing.md - corrections [ci skip]
parents
14463b27
72bcd228
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 @
25832338
...
...
@@ -97,14 +97,14 @@ use yii\helpers\Url;
/* @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'
))
?>
```
In order to compose message content via view file simply pass view name to the
`compose()`
method:
```
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'
)
->
setTo
(
'to@domain.com'
)
->
setSubject
(
'Message subject'
)
...
...
@@ -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,
which should be then used at 'img' tag.
...
...
@@ -196,7 +196,7 @@ Yii::$app->mailer->compose('embed-email', ['imageFileName' => '/path/to/image.jp
->
send
();
```
Then inside
view file you can us
e following code:
Then inside
the view file you can use th
e following code:
```
php
<img
src=
"
<?=
$message
->
embed
(
$imageFileName
);
?>
"
>
...
...
@@ -206,17 +206,17 @@ Then inside view file you can use following code:
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
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.
> 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.
This mechanism
am
y prove itself, while debugging application or running unit test.
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
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.
...
...
@@ -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
another one for the 'Message'.
You can use
`yii\mail\BaseMailer`
and
`yii\mail\BaseMessage`
as
a
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
You can use
`yii\mail\BaseMailer`
and
`yii\mail\BaseMessage`
as
the
base classes for your solution. These classes
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.
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