vendor/swiftmailer/doc/introduction.rst
author ymh <ymh.work@gmail.com>
Fri, 04 Nov 2011 11:52:47 +0100
changeset 24 57ff6d39f88c
parent 0 7f95f8617b0b
permissions -rwxr-xr-x
first full dynamic version of the bundle
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
Introduction
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
============
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
Swift Mailer is a component-based library for sending e-mails from PHP
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
applications.
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
Organization of this Book
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
-------------------------
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
This book has been written so that those who need information quickly are able
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
to find what they need, and those who wish to learn more advanced topics can
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
read deeper into each chapter.
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
The book begins with an overview of Swift Mailer, discussing what's included
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
in the package and preparing you for the remainder of the book.
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
It is possible to read this user guide just like any other book (from
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
beginning to end). Each chapter begins with a discussion of the contents it
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
contains, followed by a short code sample designed to give you a head start.
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
As you get further into a chapter you will learn more about Swift Mailer's
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
capabilities, but often you will be able to head directly to the topic you
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
wish to learn about.
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
Throughout this book you will be presented with code samples, which most
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
people should find ample to implement Swift Mailer appropriately in their own
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
projects. We will also use diagrams where appropriate, and where we believe
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
readers may find it helpful we will discuss some related theory, including
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
reference to certain documents you are able to find online.
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
Code Samples
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
------------
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
Code samples presented in this book will be displayed on a different colored
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
background in a monospaced font. Samples are not to be taken as copy & paste
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
code snippets.
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
Code examples are used through the book to clarify what is written in text.
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
They will sometimes be usable as-is, but they should always be taken as
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
outline/pseudo code only.
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
A code sample will look like this::
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
    class AClass
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
    {
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
      ...
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
    }
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
    //A Comment
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
    $obj = new AClass($arg1, $arg2, ... );
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
    /* A note about another way of doing something
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
    $obj = AClass::newInstance($arg1, $arg2, ... );
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
    */
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
The presence of 3 dots ``...`` in a code sample indicates that we have left
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
out a chunk of the code for brevity, they are not actually part of the code.
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
We will often place multi-line comments ``/* ... */`` in the code so that we
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
can show alternative ways of achieving the same result.
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
You should read the code examples given and try to understand them. They are
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
kept concise so that you are not overwhelmed with information.
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
History of Swift Mailer
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
-----------------------
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
Swift Mailer began back in 2005 as a one-class project for sending mail over
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
SMTP. It has since grown into the flexible component-based library that is in
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
development today.
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
Chris Corbyn first posted Swift Mailer on a web forum asking for comments from
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
other developers. It was never intended as a fully supported open source
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
project, but members of the forum began to adopt it and make use of it.
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
Very quickly feature requests were coming for the ability to add attachments
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
and use SMTP authentication, along with a number of other "obvious" missing
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
features. Considering the only alternative was PHPMailer it seemed like a good
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
time to bring some fresh tools to the table. Chris began working towards a
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
more component based, PHP5-like approach unlike the existing single-class,
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
legacy PHP4 approach taken by PHPMailer.
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
Members of the forum offered a lot of advice and critique on the code as he
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
worked through this project and released versions 2 and 3 of the library in
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
2005 and 2006, which by then had been broken down into smaller classes
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
offering more flexibility and supporting plugins. To this day the Swift Mailer
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
team still receive a lot of feature requests from users both on the forum and
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
in by email.
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
Until 2008 Chris was the sole developer of Swift Mailer, but entering 2009 he
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
gained the support of two experienced developers well-known to him: Paul
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
Annesley and Christopher Thompson. This has been an extremely welcome change.
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
As of September 2009, Chris handed over the maintenance of Swift Mailer to
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
Fabien Potencier.
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
Now 2009 and in its fourth major version Swift Mailer is more object-oriented
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
and flexible than ever, both from a usability standpoint and from a
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
development standpoint.
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
By no means is Swift Mailer ready to call "finished". There are still many
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
features that can be added to the library along with the constant refactoring
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
that happens behind the scenes.
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
It's a Library!
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
---------------
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
Swift Mailer is not an application - it's a library.
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
To most experienced developers this is probably an obvious point to make, but
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
it's certainly worth mentioning. Many people often contact us having gotten
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
the completely wrong end of the stick in terms of what Swift Mailer is
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
actually for.
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
It's not an application. It does not have a graphical user interface. It
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
cannot be opened in your web browser directly.
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
It's a library (or a framework if you like). It provides a whole lot of
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
classes that do some very complicated things, so that you don't have to. You
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
"use" Swift Mailer within an application so that your application can have the
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
ability to send emails.
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
The component-based structure of the library means that you are free to
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
implement it in a number of different ways and that you can pick and choose
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
what you want to use.
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
An application on the other hand (such as a blog or a forum) is already "put
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
together" in a particular way, (usually) provides a graphical user interface
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
and most likely doesn't offer a great deal of integration with your own
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
application.
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
Embrace the structure of the library and use the components it offers to your
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
advantage. Learning what the components do, rather than blindly copying and
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
pasting existing code will put you in a great position to build a powerful
7f95f8617b0b first commit
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
application!