Just for Kicks!

Swift Mailer Version 4 is very streamlined and aims to make typing the code as pain-free as possible. One statement is less painful to write than 5 statements right? I really don’t expect anybody to do this, but just to show off how streamlined Swift can be, here’s sending a message with an attachment using a single statement.

<?php
 
Swift_Mailer::newInstance(new Swift_MailTransport())->send(
  Swift_Message::newInstance('My subject', 'Some message')
    ->attach(Swift_Attachment::fromPath('foo.pdf'))
    ->setFrom('your@address.tld')
    ->setTo('person@address.tld')
);
 
v4/examples/fluid_showoff.txt · Last modified: 2008/05/22 06:28 by d11wtq
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki