1) Исправления в связи со сменой API MySQL
[openlib.git] / www / resources / PHPMailer / README.md
1 # PHPMailer - A full-featured email creation and transfer class for PHP
2
3 Build status: [![Build Status](https://travis-ci.org/Synchro/PHPMailer.png)](https://travis-ci.org/Synchro/PHPMailer)
4
5 ## Class Features
6
7 - Probably the world's most popular code for sending email from PHP!
8 - Used by many open-source projects: Drupal, SugarCRM, Yii, Joomla! and many more
9 - Integrated SMTP support - send without a local mail server
10 - Send emails with multiple TOs, CCs, BCCs and REPLY-TOs
11 - Multipart/alternative emails for mail clients that do not read HTML email
12 - Support for 8bit, base64, binary, and quoted-printable encoding
13 - SMTP authentication with LOGIN, PLAIN, NTLM and CRAM-MD5 mechanisms
14 - Native language support
15 - Compatible with PHP 5.0 and later
16 - Much more!
17
18 ## Why you might need it
19
20 Many PHP developers utilize email in their code. The only PHP function that supports this is the mail() function. However, it does not provide any assistance for making use of popular features such as HTML-based emails and attachments.
21
22 Formatting email correctly is surprisingly difficult. There are myriad overlapping RFCs, requiring tight adherence to horribly complicated formatting and encoding rules - the vast majority of code that you'll find online that uses the mail() function directly is just plain wrong!
23 *Please* don't be tempted to do it yourself - if you don't use PHPMailer, there are many other excellent libraries that you should look at before rolling your own - try SwiftMailer, Zend_Mail, eZcomponents etc.
24
25 The PHP mail() function usually sends via a local mail server, typically fronted by a `sendmail` binary on Linux, BSD and OS X platforms, however, Windows usually doesn't include a local mail server; PHPMailer's integrated SMTP implementation allows email sending on Windows platforms without a local mail server.
26
27 ## License
28
29 This software is licenced under the [LGPL 2.1](http://www.gnu.org/licenses/lgpl-2.1.html). Please read LICENSE for information on the
30 software availability and distribution.
31
32 ## Installation
33
34 PHPMailer is available via [Composer/Packagist](https://packagist.org/packages/phpmailer/phpmailer). Alternatively, just copy the contents of the PHPMailer folder into somewhere that's in your PHP `include_path` setting. If you don't speak git or just want a tarball, click the 'zip' button at the top of the page in GitHub.
35
36
37 ## A Simple Example
38
39 ```php
40 <?php
41 require 'class.phpmailer.php';
42
43 $mail = new PHPMailer;
44
45 $mail->IsSMTP();                                      // Set mailer to use SMTP
46 $mail->Host = 'smtp1.example.com;smtp2.example.com';  // Specify main and backup server
47 $mail->SMTPAuth = true;                               // Enable SMTP authentication
48 $mail->Username = 'jswan';                            // SMTP username
49 $mail->Password = 'secret';                           // SMTP password
50 $mail->SMTPSecure = 'tls';                            // Enable encryption, 'ssl' also accepted
51
52 $mail->From = 'from@example.com';
53 $mail->FromName = 'Mailer';
54 $mail->AddAddress('josh@example.net', 'Josh Adams');  // Add a recipient
55 $mail->AddAddress('ellen@example.com');               // Name is optional
56 $mail->AddReplyTo('info@example.com', 'Information');
57 $mail->AddCC('cc@example.com');
58 $mail->AddBCC('bcc@example.com');
59
60 $mail->WordWrap = 50;                                 // Set word wrap to 50 characters
61 $mail->AddAttachment('/var/tmp/file.tar.gz');         // Add attachments
62 $mail->AddAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
63 $mail->IsHTML(true);                                  // Set email format to HTML
64
65 $mail->Subject = 'Here is the subject';
66 $mail->Body    = 'This is the HTML message body <b>in bold!</b>';
67 $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
68
69 if(!$mail->Send()) {
70    echo 'Message could not be sent.';
71    echo 'Mailer Error: ' . $mail->ErrorInfo;
72    exit;
73 }
74
75 echo 'Message has been sent';
76 ```
77
78 You'll find plenty more to play with in the `examples` folder.
79
80 That's it. You should now be ready to use PHPMailer!
81
82 ## Localization
83 PHPMailer defaults to English, but in the `languages` folder you'll find numerous translations for PHPMailer error messages that you may encounter. Their filenames contain [ISO 639-1](http://en.wikipedia.org/wiki/ISO_639-1) language code for the translations, for example `fr` for French. To specify a language, you need to tell PHPMailer which one to use, like this:
84
85 ```php
86 // To load the French version
87 $mail->SetLanguage('fr', '/optional/path/to/language/directory/');
88 ```
89
90 ## Documentation
91
92 You'll find some basic user-level docs in the docs folder, and you can generate complete API-level documentation using the `generatedocs.sh` shell script in the docs folder, though you'll need to install [PHPDocumentor](http://www.phpdoc.org) first.
93
94 ## Tests
95
96 You'll find a PHPUnit test script in the `test` folder.
97
98 Build status: [![Build Status](https://travis-ci.org/PHPMailer/PHPMailer.png)](https://travis-ci.org/PHPMailer/PHPMailer)
99
100 If this isn't passing, is there something you can do to help?
101
102 ## Contributing
103
104 Please submit bug reports, suggestions and pull requests to the [GitHub issue tracker](https://github.com/PHPMailer/PHPMailer/issues).
105
106 We're particularly interested in fixing edge-cases, expanding test coverage and updating translations.
107
108 With the move to the PHPMailer GitHub organisation, you'll need to update any remote URLs referencing the old GitHub location with a command like this from within your clone:
109
110 git remote set-url upstream https://github.com/PHPMailer/PHPMailer.git
111
112 Please *don't* use the SourceForge or Google Code projects any more.
113
114 ## Changelog
115
116 See changelog.md
117
118 ## History
119 - PHPMailer was originally written in 2001 by Brent R. Matzelle as a [SourceForge project](http://sourceforge.net/projects/phpmailer/).
120 - Marcus Bointon (coolbru on SF) and Andy Prevost (codeworxtech) took over the project in 2004.
121 - Became an Apache incubator project on Google Code in 2010, managed by Jim Jagielski.
122 - Marcus created his fork on [GitHub](https://github.com/Synchro/PHPMailer).
123 - Jim and Marcus decide to join forces and use GitHub as the canonical and official repo for PHPMailer.
124 - PHPMailer moves to the [PHPMailer organisation](https://github.com/PHPMailer) on GitHub.
125
126 ### What's changed since moving from SourceForge?
127 - Official successor to the SourceForge and Google Code projects.
128 - Test suite.
129 - Continuous integration with Travis-CI.
130 - Composer support.
131 - Rolling releases.
132 - Additional languages and language strings.
133 - CRAM-MD5 authentication support.
134 - Preserves full repo history of authors, commits and branches from the original SourceForge project.