Part of the EllisLab Network
   
1 of 2
1
Swift mailer library
Posted: 25 January 2007 05:18 AM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  515
Joined  12-05-2006

Hey guys,

I was jut wondering if some of you thought to implement a Swift mailer library for CI.

It could be a coll addition to manage efficiently newsletters, given the great performance of Swift Maler with many e-mail recipients.

Let me know!

Dan

-> how they did with CAKE

 Signature 

FreakAuth_light: pluggable & extendable authentication library that works on CI 1.5.X

CI SWIFT MAILER: 44% less memory than PHPMailer at double speed

Using Zend Framework components in Code Igniter

Profile
 
 
Posted: 25 January 2007 10:25 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  515
Joined  12-05-2006

Swift mailer has a main class that can be turned in a custom library.

That class requires some additional files stored in a subfolder.

Any idea/suggestion on how to handle this?

smile

 Signature 

FreakAuth_light: pluggable & extendable authentication library that works on CI 1.5.X

CI SWIFT MAILER: 44% less memory than PHPMailer at double speed

Using Zend Framework components in Code Igniter

Profile
 
 
Posted: 06 February 2007 09:13 AM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  515
Joined  12-05-2006

I managed to make it to work inside CI 1.5.1!

I’ll release the solution after some more testing!

It will really be a great addition expecially as a base for managing newsletters!

 Signature 

FreakAuth_light: pluggable & extendable authentication library that works on CI 1.5.X

CI SWIFT MAILER: 44% less memory than PHPMailer at double speed

Using Zend Framework components in Code Igniter

Profile
 
 
Posted: 11 February 2007 02:29 PM   [ Ignore ]   [ # 3 ]  
Grad Student
Avatar
Rank
Total Posts:  63
Joined  03-02-2006

very interesting, I’m waiting for your release instead of working on it reinventing etc…

thanks!

facci sapere wink

Profile
 
 
Posted: 11 February 2007 03:01 PM   [ Ignore ]   [ # 4 ]  
Lab Assistant
RankRank
Total Posts:  248
Joined  02-10-2007

Sounds great, danfreak. I used to do all my mail stuff through Swift mailer. Haven’t had a good look at CI native mailer class though.

 Signature 

Kohana rocks!

Profile
 
 
Posted: 11 February 2007 04:18 PM   [ Ignore ]   [ # 5 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  515
Joined  12-05-2006

Hey guys,

I think I’ll able to release it this week!

I’ll keep you posted!

Dan

 Signature 

FreakAuth_light: pluggable & extendable authentication library that works on CI 1.5.X

CI SWIFT MAILER: 44% less memory than PHPMailer at double speed

Using Zend Framework components in Code Igniter

Profile
 
 
Posted: 12 February 2007 01:55 AM   [ Ignore ]   [ # 6 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  420
Joined  05-29-2006

Thank you… i wait… ciao

 Signature 

CI Js_calendar plugin click

WYSIWYG with CI

Profile
 
 
Posted: 12 February 2007 08:55 AM   [ Ignore ]   [ # 7 ]  
Grad Student
Avatar
Rank
Total Posts:  63
Joined  03-02-2006

Geert the email library is very useful to send one or relatively few emails, while swift is optimized for mass mailing.
Native mailer library has the clean and elegant style of CI, and it’s very powerful for every “standard” sending (I use it most for user registrations, contact forms etc..) in both simple text and html; it also has many nice features.

hope this helps

Profile
 
 
Posted: 27 February 2007 10:24 AM   [ Ignore ]   [ # 8 ]  
Grad Student
Rank
Total Posts:  37
Joined  02-27-2007

Any news the Swift library? smile

Profile
 
 
Posted: 27 February 2007 10:25 AM   [ Ignore ]   [ # 9 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  515
Joined  12-05-2006

I managed,

I’ll try to post the code between tonight and tomorrow!

Dan

 Signature 

FreakAuth_light: pluggable & extendable authentication library that works on CI 1.5.X

CI SWIFT MAILER: 44% less memory than PHPMailer at double speed

Using Zend Framework components in Code Igniter

Profile
 
 
Posted: 27 February 2007 10:34 AM   [ Ignore ]   [ # 10 ]  
Grad Student
Rank
Total Posts:  37
Joined  02-27-2007

Thank you. Hope to check it soon

Profile
 
 
Posted: 27 February 2007 11:12 AM   [ Ignore ]   [ # 11 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  515
Joined  12-05-2006

I released it.

It USES SWIFT MAILER_PHP5 version 2.1.17

I’ll upgrade it to 3.0.1 asap

=> CI SWIFT MAILER

Enjoy!

Dan

grin

 Signature 

FreakAuth_light: pluggable & extendable authentication library that works on CI 1.5.X

CI SWIFT MAILER: 44% less memory than PHPMailer at double speed

Using Zend Framework components in Code Igniter

Profile
 
 
Posted: 28 February 2007 04:05 AM   [ Ignore ]   [ # 12 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  515
Joined  12-05-2006

I just updated the WIKI page with what follows:

#################################################################

Well I wanted to call this library/plugin Freak_Swift_Mailer, but then… somebody killed my creativity…

Anyway, this is my solution for using SWIFT MAILER library with CI.

———————————————————————————————————————————————————————————————-

RESOURCES:

=> FORUM

=> official SWIFT MAILER WEBSITE

=> 4webby.com for tutorials


Author: Daniel Vecchiato (danfreak)
website: http://www.4webby.com
The original Swift Mailer package has been released by Chris Corbyn http://www.swiftmailer.org/

#
* @license GNU Lesser General Public License
# */


———————————————————————————————————————-
REQUIREMENTS:
———————————————————————————————————————-

- CodeIgniter 1.5.1/1.5.2 (http://codeigniter.com/download.php)

 


———————————————————————————————————————-
INSTALLATION:           
———————————————————————————————————————-

1) download SWIFT MAILER from SWIFT MAILER website
  (choose PHP4 or PHP5 version according to your needs)

2) unzip Swift-X.0.X-phpX.zip in a local folder

3) create a folder called my_classes in your system/application directory

4) copy the files INSIDE the folder Swift-X.0.X-phpX/lib/ in your system/application/my_classes/ directory

5) enable hooks in your application/config/config.php file

/*
|--------------------------------------------------------------------------
| Enable/Disable System Hooks
|--------------------------------------------------------------------------
|
| If you would like to use the "hooks" feature you must enable it by
| setting this variable to TRUE (boolean).  See the user guide for details.
|
*/
$config['enable_hooks'] = TRUE;

6) add the following lines in application/config/hooks.php

$hook['pre_controller'][] = array(
                                
'class'    => 'MyClasses',
                                
'function' => 'index',
                                
'filename' => 'MyClasses.php',
                                
'filepath' => 'hooks'
                                
);

7) in your system/application/hooks/ create a new file called MyClasses.php with the following inside

<?php

if (!defined('BASEPATH')) exit('No direct script access allowed');

class
Myclasses
{    
    
/**
     * includes the directory applicationmy_classes in your includes directory
     *
     */
    
function index()
    
{
        
//includes the directory applicationmy_classes
       //for windows tests change the ':' before BASEPATH to ';'
        
ini_set('include_path', ini_get('include_path').':'.BASEPATH.'application/my_classes/');
    
}
}

?>

8) build a controller to test that everything works fine (example taken here)

<?php
class Mail extends Controller
{
    
function Mail()
    
{
        parent
::Controller();
        
    
}
    
    
function index()
    
{
        
//Load in the files we'll need
        
require_once "Swift.php";
        require_once
"Swift/Connection/SMTP.php";
         
        
//Start Swift
        
$swift =& new Swift(new Swift_Connection_SMTP("your.smtp.com"));
         
        
//Create the message
        
$message =& new Swift_Message("My subject", "My body");
         
        
//Now check if Swift actually sends it
        
if ($swift->send($message, "recipient@email.com", "sender@email.com")) echo "Sent";
        else echo
"Failed";
    
}
}

?>

9) now build other controllers/methods to suit your needs. Check out the SWIFT MAILER DOCUMENTATION

IMPORTANT NOTICE:
use the examples in the documentation, but change

//Load in the files we'll need
require_once "lib/Swift.php";
require_once
"lib/Swift/Connection/SMTP.php";

to

//Load in the files we'll need
require_once "Swift.php";
require_once
"Swift/Connection/SMTP.php";

10) HAPPY CODING!

 Signature 

FreakAuth_light: pluggable & extendable authentication library that works on CI 1.5.X

CI SWIFT MAILER: 44% less memory than PHPMailer at double speed

Using Zend Framework components in Code Igniter

Profile
 
 
Posted: 28 February 2007 10:43 AM   [ Ignore ]   [ # 13 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  208
Joined  06-12-2006

good coding. thanks for sharing it, dan.

question: is swift mailer suited only for massive emails or for a single message too. In other words, in what cases is it recommended?

Profile
 
 
Posted: 28 February 2007 12:04 PM   [ Ignore ]   [ # 14 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  515
Joined  12-05-2006

Hey ztinger,

I’m glad you liked this addition.

Well personally I’ll suggest to use it for big batch emailing: for example I’ll use it to manage my newsletter.

Other good reasons are:

- the less resources used when compared with mail() php native function
- the increase in performance (time) when sending e-mails
- good documentation and maintainance
- PHP4 compliance
- ease of use

You can find more reasons for using it in the feature list:

The current list of features includes:

  * Send uses one single connection to the SMTP server or MTA
  * Doesn’t rely on mail()
  * Custom Headers
  * Multiple encoding options
  * Unlimited redundant connections (can use mixed types too)
  * Connection rotating/load balancing
  * TLS Support - for Gmail servers
  * Embedded Images or other file types
  * Builds and sends Multipart messages
  * Sends single-part emails as usual
  * Fast Cc and Bcc handling
  * Unicode UTF-8 support, with auto-detection
  * Handles denied recipients in batch mailing whilst still delivering to the others
  * Smart runtime caching (in small, self-maintained packets)
  * Send attachments of ANY size even with PHP’s 8MB Memory Limit
  * Optional auto-detection of SMTP or Sendmail settings
  * Batch emailing with multiple To’s or without
  * Send to hundreds of thousands of addresses without cron
  * Support for multiple attachments
  * Protection against header injection
  * Set message priority
  * Request Read Receipts
  * Sendmail (or other binary) support
  * Pluggable SMTP Authentication (LOGIN, PLAIN, MD5-CRAM, POP Before SMTP)
  * Anti-Flooding support (reconnect every X emails) via plugin
  * Secure Socket Layer connections (SSL)
  * Loadable plugin support with event handling features

And in the Benchmarking comparison

Dan

grin

PS: did you test it? did you find my mini-tutorial easy and complete?

 Signature 

FreakAuth_light: pluggable & extendable authentication library that works on CI 1.5.X

CI SWIFT MAILER: 44% less memory than PHPMailer at double speed

Using Zend Framework components in Code Igniter

Profile
 
 
Posted: 28 February 2007 12:26 PM   [ Ignore ]   [ # 15 ]  
Grad Student
Rank
Total Posts:  37
Joined  02-27-2007

I dind’t install this library yet, I’m using PHP4 and, as you mention in the wiki when posted, it was for PHP5. I didn’t had the time to make it php4 compatible, but, now checking the instructions here in the forum, I don’t see nothing that aren’t incompatible with php4, or am I wrong?

Anyway, and about the swift version, think it will work with the latest one?

Thanks

Profile
 
 
   
1 of 2
1
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 721, on January 06, 2010 09:38 AM
Total Registered Members: 114897 Total Logged-in Users: 36
Total Topics: 122389 Total Anonymous Users: 3
Total Replies: 647053 Total Guests: 368
Total Posts: 769442    
Members ( View Memberlist )