CakePHP SwiftMailer 3 Component

I had some issues today using the cakephp swiftmailer component. It still relied on the older version (pre version 3) of swiftmailer. There are quite some changes between SwiftMailer 2 and 3, and I decided to adjust the SwiftMailer component so it works with SwiftMailer 3.

Please note that this is the PHP5 version. To get it working in PHP4, you need to change the constants in the connect_sendmail and connect_smtp…

Download CakePHP SwiftMailer 3 Component.

8 Responses to “CakePHP SwiftMailer 3 Component”


  1. 1 Jason Johnson

    Hi, found an error i think:

    Line 213:

    $message->attach should be $this->message->attach

  2. 2 wouter

    Jason,

    Thanks for the feedback. I have updated the swift_mailer script. It also supports SMTP authentication now…

  3. 3 Adam Alton

    Hi, there’s an error here, took me aaaaages to find this!

    Line 249:
    if($type == ‘html’){
    $this->message->attach(new Swift_Message_Part($msg, “text/plain”));
    }else{
    $this->message->attach(new Swift_Message_Part($msg, “text/html”));
    }

    The ‘text/html’ and ‘text/plain’ are the wrong way round!!

  4. 4 Aniq Rahman

    @Wouter: Thanks so much for a SwiftMailer3 port. You just saved me a ton of time.

    @Adam: Good call! Thanks – that was a big help.

  5. 5 mmm

    i’m trying to using this code with cake 1.2 stable, it sends a message but body is empty, any idea?

  6. 6 fabio m costa

    “i’m trying to using this code with cake 1.2 stable, it sends a message but body is empty, any idea?”

    I’m having the same issue…

  7. 7 wouter

    The component doesn’t support cake 1.2 for now. Cake itself comes with a good email component now: http://book.cakephp.org/view/176/Email

  8. 8 sokar

    wouter as I know cake emailComponent is using mailPHP so without SSL support :/

Leave a Reply