swiftmailer / swiftmailer

Comprehensive mailing tools for PHP 5

This URL has Read+Write access

name age message
file .gitignore Sun Jan 04 00:38:28 -0800 2009 Added build dir [d11wtq]
file CHANGES Sat Feb 23 23:46:46 -0800 2008 Abstracted the factory classes [d11wtq]
file LICENSE.GPL Sat Feb 23 17:41:01 -0800 2008 Updated build.xml to clean up a little better. [d11wtq]
file LICENSE.LGPL Sun Sep 13 15:40:17 -0700 2009 changed all file headers to point to the LGPL l... [fabpot]
file README Sun Jan 04 00:57:23 -0800 2009 Updated README ready for beta-1 [d11wtq]
file README.git Mon Dec 15 22:31:36 -0800 2008 Fixed tpyo in README.git [githib -> github] [d11wtq]
file VERSION Fri Jan 30 21:28:00 -0800 2009 Changed version to beta 4 [d11wtq]
file build.xml Tue Dec 16 05:35:11 -0800 2008 Fixed build.xml after moving simpletest [d11wtq]
directory docs/ Fri Feb 22 19:54:01 -0800 2008 Completed Sendmail Transport Added acceptance t... [d11wtq]
directory examples/ Sun Jan 04 00:52:46 -0800 2009 Fixed up the examples [d11wtq]
directory lib/ Thu Feb 05 14:24:09 -0800 2009 Various changes (i know, should be in small com... [xdecock]
directory notes/ Fri Jan 30 12:29:04 -0800 2009 Next Time, i'll learn to <ctrl>+s [xdecock]
directory test-suite/ Sat Jan 24 19:47:24 -0800 2009 Resolved an issue where HTML and Text parts wer... [d11wtq]
directory tests/ Thu Feb 05 14:24:09 -0800 2009 Various changes (i know, should be in small com... [xdecock]
directory util/ Sun Feb 24 00:37:55 -0800 2008 Not sure how that happened [d11wtq]
README
Swift Mailer, by Chris Corbyn
-----------------------------

Swift Mailer is a component based mailing solution for PHP 5.

Documentation: http://swifmailer.org/betas/docs/v4-working-draft/
Mailing List:  http://groups.google.com/group/swiftmailer
Bugs:          http://swiftmailer.lighthouseapp.com/
Repository:    http://github.com/swiftmailer/swiftmailer


FOR THE IMPATIENT, WAITING FOR VERSION 4.0.0:
---------------------------------------------

ADDENDUM: Working Draft Docs @ http://swifmailer.org/betas/docs/v4-working-draft/

At the time of writing (16th December 2008), the code is not yet ready for a
full-release.   However, it is extremely close to becoming version 4.0.0.

You can probably use the code now if you are developing an application you
do not expect to release until early 2009, or if you simply wish to play
around.  However, there is no documentation as yet so you'll have to use your
intuition and read the doc comments in the code.  To give you a head start
here's a complex example showing how to send an email to three recipients,
with an alternative body, two attachments and an embedded image, over SMTP
with a username and password.

<?php

require_once 'swift/lib/swift_required.php';

$smtp = Swift_SmtpTransport::newInstance('smtp.host.tld', 25)
  ->setUsername(' ... ')
  ->setPassword(' ... ');

$mailer = Swift_Mailer::newInstance($smtp);

$message = Swift_Message::newInstance('Your subject');
$message
  ->setTo(array(
    'user1@example.org',
    'user2@example.org' => 'User Two',
    'user3@exmaple.org' => 'Another User Name'
  ))
  ->setFrom(array('your@address.com' => 'Your Name'))
  ->attach(Swift_Attachment::fromPath('/path/to/doc1.pdf'))
  ->attach(Swift_Attachment::fromPath('/path/to/doc2.pdf'))
  ->setBody(
    'Here is an image <img src="' . $message->embed(Swift_Image::fromPath('/path/to/image.jpg')) . '" />',
    'text/html'
  )
  ->addPart('This is the alternative part', 'text/plain')
  ;

if ($mailer->send($message))
{
  echo "Message sent!";
}
else
{
  echo "Message could not be sent.";
}