aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2015-05-26 12:21:01 +0200
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2015-05-26 12:29:14 +0200
commit1ac6e383b9b5ae8f77d4a6093c5308a2ec6fef89 (patch)
treebceff9b73ae6a357e8358da2553f15b222181da7
parent5b3b46d58fa9b1944dd45a3fb3ff21989b7ad44a (diff)
downloadMail-1ac6e383b9b5ae8f77d4a6093c5308a2ec6fef89.zip
Mail-1ac6e383b9b5ae8f77d4a6093c5308a2ec6fef89.tar.gz
Mail-1ac6e383b9b5ae8f77d4a6093c5308a2ec6fef89.tar.bz2
Add related contents example.
-rw-r--r--README.md55
1 files changed, 44 insertions, 11 deletions
diff --git a/README.md b/README.md
index 7fd6935..db040ca 100644
--- a/README.md
+++ b/README.md
@@ -76,17 +76,18 @@ content: either textual or HTML.
```php
$message->addContent(
- new Hoa\Mail\Content\Alternative(
- [
- new Hoa\Mail\Content\Text(
- 'Check this out: http://hoa-project.net/!'
- ),
- new Hoa\Mail\Content\Html(
- '<a href="http://hoa-project.net/">Check this ' .
- '<strong>out</strong>!</a>'
- )
- ]
- )
+ // We have either…
+ new Hoa\Mail\Content\Alternative([
+ // … a text content
+ new Hoa\Mail\Content\Text(
+ 'Check this out: http://hoa-project.net/!'
+ ),
+ // … or an HTML content.
+ new Hoa\Mail\Content\Html(
+ '<a href="http://hoa-project.net/">Check this ' .
+ '<strong>out</strong>!</a>'
+ )
+ ])
);
```
@@ -108,6 +109,38 @@ And finally, we send the email:
$message->send();
```
+### Complex email
+
+Now imagine we do not want the image to be only attached but appear in the HTML
+content. These contents are related. Here is how to construct the email (with
+more variables to clarify):
+
+```php
+// The image.
+$attachment = new Hoa\Mail\Content\Attachment(
+ new Hoa\File\Read('Attachment.jpg'),
+ 'Foobar.jpg'
+);
+// The text content.
+$text = new Hoa\Mail\Content\Text('Check this out: http://hoa-project.net/!');
+// The HTML content.
+$html = new Hoa\Mail\Content\Html(
+ '<img src="' .
+ // The HTML image URL is the attachment ID URL.
+ $attachment->getIdUrl() .
+ '" />'
+);
+
+$message->addContent(
+ // Alternative contents and attachment are related.
+ new Hoa\Mail\Content\Related([
+ // We still have 2 alternative contents: text or HTML.
+ new Hoa\Mail\Content\Alternative([$text, $html]),
+ $attachment
+ ])
+);
+```
+
## Documentation
Different documentations can be found on the website: