Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit 3ed406f

Browse files
committed
Merge pull request #54 from GeeH/hotfix/added-docs
Added base documentation
2 parents 7a75bb0 + 828e640 commit 3ed406f

File tree

6 files changed

+1010
-0
lines changed

6 files changed

+1010
-0
lines changed

doc/book/zend.mail.file.options.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Zend\\Mail\\Transport\\FileOptions
2+
3+
## Overview
4+
5+
This document details the various options available to the `Zend\Mail\Transport\File` mail
6+
transport.
7+
8+
## Quick Start
9+
10+
```php
11+
use Zend\Mail\Transport\File as FileTransport;
12+
use Zend\Mail\Transport\FileOptions;
13+
14+
// Setup File transport
15+
$transport = new FileTransport();
16+
$options = new FileOptions(array(
17+
'path' => 'data/mail/',
18+
'callback' => function (FileTransport $transport) {
19+
return 'Message_' . microtime(true) . '_' . mt_rand() . '.txt';
20+
},
21+
));
22+
$transport->setOptions($options);
23+
```
24+
25+
## Configuration Options
26+
27+
**path**
28+
The path under which mail files will be written.
29+
30+
<!-- -->
31+
32+
**callback**
33+
A PHP callable to be invoked in order to generate a unique name for a message file. By default, the
34+
following is used:
35+
36+
```php
37+
function (Zend\Mail\FileTransport $transport) {
38+
return 'ZendMail_' . time() . '_' . mt_rand() . '.tmp';
39+
}
40+
```
41+
42+
## Available Methods
43+
44+
`Zend\Mail\Transport\FileOptions` extends `Zend\Stdlib\AbstractOptions`, and inherits all
45+
functionality from that class; this includes property overloading. Additionally, the following
46+
explicit setters and getters are provided.
47+
48+
**setPath**
49+
`setPath(string $path)`
50+
51+
Set the path under which mail files will be written.
52+
53+
Implements fluent interface.
54+
55+
<!-- -->
56+
57+
**getPath**
58+
`getPath()`
59+
60+
Get the path under which mail files will be written.
61+
62+
Returns string
63+
64+
<!-- -->
65+
66+
**setCallback**
67+
`setCallback(Callable $callback)`
68+
69+
Set the callback used to generate unique filenames for messages.
70+
71+
Implements fluent interface.
72+
73+
<!-- -->
74+
75+
**getCallback**
76+
`getCallback()`
77+
78+
Get the callback used to generate unique filenames for messages.
79+
80+
Returns PHP callable argument.
81+
82+
<!-- -->
83+
84+
**\_\_construct**
85+
`__construct(null|array|Traversable $config)`
86+
87+
Initialize the object. Allows passing a PHP array or `Traversable` object with which to populate the
88+
instance.
89+
90+
## Examples
91+
92+
Please see the \[Quick Start\](zend.mail.file-options.quick-start) for examples.

doc/book/zend.mail.introduction.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Introduction to Zend\\Mail
2+
3+
## Getting started
4+
5+
`Zend\Mail` provides generalized functionality to compose and send both text and *MIME*-compliant
6+
multipart email messages. Mail can be sent with `Zend\Mail` via the `Mail\Transport\Sendmail`,
7+
`Mail\Transport\Smtp` or the `Mail\Transport\File` transport. Of course, you can also implement your
8+
own transport by implementing the `Mail\Transport\TransportInterface`.
9+
10+
### Simple email with Zend\\Mail
11+
12+
A simple email consists of one or more recipients, a subject, a body and a sender. To send such a
13+
mail using `Zend\Mail\Transport\Sendmail`, do the following:
14+
15+
```php
16+
use Zend\Mail;
17+
18+
$mail = new Mail\Message();
19+
$mail->setBody('This is the text of the email.');
20+
$mail->setFrom('[email protected]', 'Sender\'s name');
21+
$mail->addTo('[email protected]', 'Name of recipient');
22+
$mail->setSubject('TestSubject');
23+
24+
$transport = new Mail\Transport\Sendmail();
25+
$transport->send($mail);
26+
```
27+
28+
> ## Note
29+
#### Minimum definitions
30+
In order to send an email using `Zend\Mail` you have to specify at least one recipient as well as a
31+
message body. Please note that each Transport may require additional parameters to be set.
32+
33+
For most mail attributes there are "get" methods to read the information stored in the message
34+
object. for further details, please refer to the *API* documentation.
35+
36+
You also can use most methods of the `Mail\Message` object with a convenient fluent interface.
37+
38+
```php
39+
use Zend\Mail;
40+
41+
$mail = new Mail\Message();
42+
$mail->setBody('This is the text of the mail.')
43+
->setFrom('[email protected]', 'Some Sender')
44+
->addTo('[email protected]', 'Some Recipient')
45+
->setSubject('TestSubject');
46+
```
47+
48+
## Configuring the default sendmail transport
49+
50+
The most simple to use transport is the `Mail\Transport\Sendmail` transport class. It is essentially
51+
a wrapper to the *PHP* [mail()](http://php.net/mail) function. If you wish to pass additional
52+
parameters to the [mail()](http://php.net/mail) function, simply create a new transport instance and
53+
pass your parameters to the constructor.
54+
55+
### Passing additional parameters
56+
57+
This example shows how to change the Return-Path of the [mail()](http://php.net/mail) function.
58+
59+
```php
60+
use Zend\Mail;
61+
62+
$mail = new Mail\Message();
63+
$mail->setBody('This is the text of the email.');
64+
$mail->setFrom('[email protected]', 'Dolf');
65+
$mail->addTo('[email protected]', 'Matthew');
66+
$mail->setSubject('TestSubject');
67+
68+
$transport = new Mail\Transport\Sendmail('[email protected]');
69+
$transport->send($mail);
70+
```
71+
72+
> ## Note
73+
#### Safe mode restrictions
74+
Supplying additional parameters to the transport will cause the [mail()](http://php.net/mail)
75+
function to fail if *PHP* is running in safe mode.
76+
77+
> ## Note
78+
#### Choosing your transport wisely
79+
Although the sendmail transport is the transport that requires only minimal configuration, it may
80+
not be suitable for your production environment. This is because emails sent using the sendmail
81+
transport will be more often delivered to SPAM-boxes. This can partly be remedied by using the
82+
\[SMTP Transport\](zend.mail.transport.quick-start.smtp-usage) combined with an SMTP server that has
83+
an overall good reputation. Additionally, techniques such as SPF and DKIM may be employed to ensure
84+
even more email messages are delivered as should.
85+
86+
> ## Warning
87+
#### Sendmail Transport and Windows
88+
As the *PHP* manual states the `mail()` function has different behaviour on Windows and on \*nix
89+
based systems. Using the Sendmail Transport on Windows will not work in combination with `addBcc()`.
90+
The `mail()` function will sent to the BCC recipient such that all the other recipients can see him
91+
as recipient!
92+
Therefore if you want to use BCC on a windows server, use the SMTP transport for sending!

0 commit comments

Comments
 (0)