Commit 25832338 by Carsten Brandt

Merge pull request #6806 from softark/docs-guide-tutorial-mailing-fix

docs/guide/tutorial-mailing.md - corrections [ci skip]
parents 14463b27 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 out site home page by one click</h2> <h2>This message allows you to visit our 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 Embedding 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 use following code: Then inside the view file you can use the 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 browse actual message headers, content and so on. A mail message file can be opened by a regular text file editor, so you can browse the actual message headers, content and so on.
This mechanism amy prove itself, while debugging application or running unit test. This mechanism may 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 contains 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.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment