installing.rst 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. Installing the Library
  2. ======================
  3. Installing Swift Mailer is trivial. Usually it's just a case of uploading the
  4. extracted source files to your web server.
  5. Installing from PEAR
  6. --------------------
  7. If you want to install Swift Mailer globally on your machine, the easiest
  8. installation method is using the PEAR channel.
  9. To install the Swift Mailer PEAR package:
  10. * Run the command ``pear channel-discover pear.swiftmailer.org``.
  11. * Then, run the command ``pear install swift/swift``.
  12. Installing from a Package
  13. -------------------------
  14. Most users will download a package from the Swift Mailer website and install
  15. Swift Mailer using this.
  16. If you downloaded Swift Mailer as a ``.tar.gz`` or
  17. ``.zip`` file installation is as simple as extracting the archive
  18. and uploading it to your web server.
  19. Extracting the Library
  20. ~~~~~~~~~~~~~~~~~~~~~~
  21. You extract the archive by using your favorite unarchiving tool such as
  22. ``tar`` or 7-Zip.
  23. You will need to have access to a program that can open uncompress the
  24. archive. On Windows computers, 7-Zip will work. On Mac and Linux systems you
  25. can use ``tar`` on the command line.
  26. To extract your downloaded package:
  27. * Use the "extract" facility of your archiving software.
  28. The source code will be placed into a directory with the same name as the
  29. archive (e.g. Swift-4.0.0-b1).
  30. The following example shows the process on Mac OS X and Linux systems using
  31. the ``tar`` command.
  32. .. code-block:: bash
  33. $ ls
  34. Swift-4.0.0-dev.tar.gz
  35. $ tar xvzf Swift-4.0.0-dev.tar.gz
  36. Swift-4.0.0-dev/
  37. Swift-4.0.0-dev/lib/
  38. Swift-4.0.0-dev/lib/classes/
  39. Swift-4.0.0-dev/lib/classes/Swift/
  40. Swift-4.0.0-dev/lib/classes/Swift/ByteStream/
  41. Swift-4.0.0-dev/lib/classes/Swift/CharacterReader/
  42. Swift-4.0.0-dev/lib/classes/Swift/CharacterReaderFactory/
  43. Swift-4.0.0-dev/lib/classes/Swift/CharacterStream/
  44. Swift-4.0.0-dev/lib/classes/Swift/Encoder/
  45. ... etc etc ...
  46. Swift-4.0.0-dev/tests/unit/Swift/Transport/LoadBalancedTransportTest.php
  47. Swift-4.0.0-dev/tests/unit/Swift/Transport/SendmailTransportTest.php
  48. Swift-4.0.0-dev/tests/unit/Swift/Transport/StreamBufferTest.php
  49. $ cd Swift-4.0.0-dev
  50. $ ls
  51. CHANGES LICENSE.GPL LICENSE.LGPL README VERSION examples lib test-suite tests
  52. $
  53. Installing from Git
  54. -------------------
  55. It's possible to download and install Swift Mailer directly from github.com if
  56. you want to keep up-to-date with ease.
  57. Swift Mailer's source code is kept in a git repository at github.com so you
  58. can get the source directly from the repository.
  59. .. note::
  60. You do not need to have git installed to use Swift Mailer from github. If
  61. you don't have git installed, go to `github`_ and click the "Download"
  62. button.
  63. Cloning the Repository
  64. ~~~~~~~~~~~~~~~~~~~~~~
  65. The repository can be cloned from git://github.com/swiftmailer/swiftmailer.git
  66. using the ``git clone`` command.
  67. You will need to have ``git`` installed before you can use the
  68. ``git clone`` command.
  69. To clone the repository:
  70. * Open your favorite terminal environment (command line).
  71. * Move to the directory you want to clone to.
  72. * Run the command ``git clone git://github.com/swiftmailer/swiftmailer.git
  73. swiftmailer``.
  74. The source code will be downloaded into a directory called "swiftmailer".
  75. The example shows the process on a UNIX-like system such as Linux, BSD or Mac
  76. OS X.
  77. .. code-block:: bash
  78. $ cd source_code/
  79. $ git clone git://github.com/swiftmailer/swiftmailer.git swiftmailer
  80. Initialized empty Git repository in /Users/chris/source_code/swiftmailer/.git/
  81. remote: Counting objects: 6815, done.
  82. remote: Compressing objects: 100% (2761/2761), done.
  83. remote: Total 6815 (delta 3641), reused 6326 (delta 3286)
  84. Receiving objects: 100% (6815/6815), 4.35 MiB | 162 KiB/s, done.
  85. Resolving deltas: 100% (3641/3641), done.
  86. Checking out files: 100% (1847/1847), done.
  87. $ cd swiftmailer/
  88. $ ls
  89. CHANGES LICENSE.LGPL README.git VERSION docs lib test-suite util
  90. LICENSE.GPL README TODO build.xml examples notes tests
  91. $
  92. Uploading to your Host
  93. ----------------------
  94. You only need to upload the "lib/" directory to your web host for production
  95. use. All other files and directories are support files not needed in
  96. production.
  97. You will need FTP, ``rsync`` or similar software installed in order to upload
  98. the "lib/" directory to your web host.
  99. To upload Swift Mailer:
  100. * Open your FTP program, or a command line if you prefer rsync/scp.
  101. * Upload the "lib/" directory to your hosting account.
  102. The files needed to use Swift Mailer should now be accessible to PHP on your
  103. host.
  104. The following example shows show you can upload the files using
  105. ``rsync`` on Linux or OS X.
  106. .. note::
  107. You do not need to place the files inside your web root. They only need to
  108. be in a place where your PHP scripts can "include" them.
  109. .. code-block:: bash
  110. $ rsync -rvz lib d11wtq@swiftmailer.org:swiftmailer
  111. building file list ... done
  112. created directory swiftmailer
  113. lib/
  114. lib/mime_types.php
  115. lib/preferences.php
  116. lib/swift_required.php
  117. lib/classes/
  118. lib/classes/Swift/
  119. lib/classes/Swift/Attachment.php
  120. lib/classes/Swift/CharacterReader.php
  121. ... etc etc ...
  122. lib/dependency_maps/
  123. lib/dependency_maps/cache_deps.php
  124. lib/dependency_maps/mime_deps.php
  125. lib/dependency_maps/transport_deps.php
  126. sent 151692 bytes received 2974 bytes 5836.45 bytes/sec
  127. total size is 401405 speedup is 2.60
  128. $
  129. .. _`github`: http://github.com/swiftmailer/swiftmailer
  130. Troubleshooting
  131. ---------------
  132. Swift Mailer does not work when used with function overloading as implemented
  133. by ``mbstring`` (``mbstring.func_overload`` set to ``2``). A workaround is to
  134. temporarily change the internal encoding to ``ASCII`` when sending an email:
  135. .. code-block:: php
  136. if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2)
  137. {
  138. $mbEncoding = mb_internal_encoding();
  139. mb_internal_encoding('ASCII');
  140. }
  141. // Create your message and send it with Swift Mailer
  142. if (isset($mbEncoding))
  143. {
  144. mb_internal_encoding($mbEncoding);
  145. }