aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2014-02-24 15:49:03 +0100
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2014-02-24 15:49:03 +0100
commit9157f328e5896f6ea7c0150c600b088a3dcf32dc (patch)
tree9484f7b6371eca44527d0169b2e56f8d5f0a2033 /README.md
parent4c771c84f1e8d513097c0a36b49079b83a079716 (diff)
downloadMail-9157f328e5896f6ea7c0150c600b088a3dcf32dc.zip
Mail-9157f328e5896f6ea7c0150c600b088a3dcf32dc.tar.gz
Mail-9157f328e5896f6ea7c0150c600b088a3dcf32dc.tar.bz2
Add syntax highlighting.
Diffstat (limited to 'README.md')
-rw-r--r--README.md76
1 files changed, 43 insertions, 33 deletions
diff --git a/README.md b/README.md
index 4f4bef0..b491f7b 100644
--- a/README.md
+++ b/README.md
@@ -23,27 +23,31 @@ Before all, just like any messaging softwares, we have to setup the transport.
We will send our email by using SMTP as the default transport. We will specify a
socket to the SMTP server, a login and a password:
- Hoa\Mail\Message::setDefaultTransport(
- new Hoa\Mail\Transport\Smtp(
- new Hoa\Socket\Client('tcp://mail.domain.tld:587'),
- 'gordon_freeman',
- '*********'
- )
- );
+```php
+Hoa\Mail\Message::setDefaultTransport(
+ new Hoa\Mail\Transport\Smtp(
+ new Hoa\Socket\Client('tcp://mail.domain.tld:587'),
+ 'gordon_freeman',
+ '*********'
+ )
+);
+```
Then, we will get an instance of a message and set all the headers, such as
`From`, `To` and `Subject`, we will add a textual content and we will send it:
- $message = new Hoa\Mail\Message();
- $message['From'] = 'Gordon Freeman <gordon@freeman.hf>';
- $message['To'] = 'Alyx Vance <alyx@vance.hf>';
- $message['Subject'] = 'Hoa is awesome!';
+```php
+$message = new Hoa\Mail\Message();
+$message['From'] = 'Gordon Freeman <gordon@freeman.hf>';
+$message['To'] = 'Alyx Vance <alyx@vance.hf>';
+$message['Subject'] = 'Hoa is awesome!';
- $message->addContent(
- new Hoa\Mail\Content\Text('Check this out: http://hoa-project.net/!')
- );
+$message->addContent(
+ new Hoa\Mail\Content\Text('Check this out: http://hoa-project.net/!')
+);
- $message->send();
+$message->send();
+```
Notice that we can use any view or template library to produce the content of
the mail!
@@ -53,33 +57,39 @@ the mail!
Now, instead of having only one textual content, we will have an alternative
content: either textual or HTML.
- $message->addContent(
- new Hoa\Mail\Content\Alternative(
- array(
- 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>'
- )
+```php
+$message->addContent(
+ new Hoa\Mail\Content\Alternative(
+ array(
+ 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>'
)
)
- );
+ )
+);
+```
Then, to add an attachment, we will add a new kind of content. The attachment is
an image that will be named `Foobar.jpg`. Thus:
- $message->addContent(
- new Hoa\Mail\Content\Attachment(
- new Hoa\File\Read('Attachment.jpg'),
- 'Foobar.jpg'
- )
- );
+```php
+$message->addContent(
+ new Hoa\Mail\Content\Attachment(
+ new Hoa\File\Read('Attachment.jpg'),
+ 'Foobar.jpg'
+ )
+);
+```
And finally, we send the email:
- $message->send();
+```php
+$message->send();
+```
## Documentation