Yii 1.1: wkd-swiftmailer

SwiftMailer wrapper http://swiftmailer.org/
20 followers

This is basically updated wrapper of SwiftMailer which can be used as application component.

Installation

  1. Unzip extension contents to protected/extensions/ folder
  2. Set up yii component via config:
...
'mailer' => array(
    'class' => 'ext.swiftMailer.SwiftMailer',
    // For SMTP
    'mailer' => 'smtp',
    'host'=>'localhost',
    'From'=>'admin@localhost',
    'username'=>'smptusername',
    'password'=>'123456',
    // For sendmail:
    'mailer'=>'sendmail',
),
...

Usage

Yii::app()->mailer->AddAddress($email);
Yii::app()->mailer->Subject = "Let's do this!";
Yii::app()->mailer->MsgHTML("<a href='http://site.com'>test</a>");
Yii::app()->mailer->Send();

Please, take a look a SwiftMailer::Send() function

Resources

Total 20 comments

#13613 report it
ajaxian at 2013/06/11 10:29am
auth mode is not present

Hi, In the smtp, you may have to auth: "The authentication mode to use when using smtp as the transport. Valid values are plain, login, cram-md5, or null."

I can't see in the param, a auth param...

Do I misunderstand something or there is something to add to the plugin ?

Thx

#12773 report it
realtebo at 2013/04/11 07:48am
Update available

Swiftmailer has been update at 4.3.1

See: http://swiftmailer.org/download

Can, please, update the extension ? Yor work is usefull and excellent ! Thank you again

#12424 report it
Tsunami at 2013/03/19 10:54pm
goto

A few other tips:

I would remove the goto and just use an else, it's limiting the extension to PHP 5.3. And maybe add support for CC, BCC, Reply To etc.

#12300 report it
realtebo at 2013/03/12 05:11am
Thank you !

Thanks for autoload fix !!

And for versioning of file. It's usefull !!!

#12291 report it
b3atb0x at 2013/03/11 03:28pm
Update

Sorry mate, I was in a bit of a hurry - I added secured SMTP support just as you suggested, and also fixed autoload issue

#12282 report it
Tsunami at 2013/03/11 09:21am
Secure SMTP

I said secure SMTP, there's no support for SSL or TLS. I even linked to the page that describes it and wrote the code for you to copy and paste into your class.

#12280 report it
b3atb0x at 2013/03/11 08:04am
Github

Hey guys, thank you all for comments & email — I've moved this project to Github so it is easily maintained - https://github.com/Webkadabra/Yii-SwiftMailer

PS Tsunami, SMTP support has been there foe a while - just set 'username', 'password', 'host' & 'port' parameters for extension component

#12190 report it
realtebo at 2013/03/05 03:34am
Thanks for upgrade !

Thank you developer for updating ! Thank you a lot !

Just a 'little thing': add versioning to extension zip file name, so we can easily check out extension version (It's usefull while maintaining a very large project with a lot of extension), and a changelog with dates on the post test

#12184 report it
Tsunami at 2013/03/04 05:09pm
Secure SMTP support?

Can you add support for secure SMTP? Thanks!

/**
 * SMTP security
 */
public $security;
 
public function smtpTransport($host = null, $port = null, $security = null)
{
    return Swift_SmtpTransport::newInstance($host, $port, $security);
}
 
protected function loadTransport()
{
    if ($this->mailer == 'smtp') {
        $transport = self::smtpTransport($this->host, $this->port, $this->security);
#12183 report it
b3atb0x at 2013/03/04 04:17pm
Extension Updated

Hey guys, thank you for using this extension! I'm happy to tell you that is just has been updated: * Updated SwiftMailer to 4.3.0 (latest) + added feature to quickly attach files + added fluid calls support

Example:

app()->mailer
    ->AddAddress($email)
    ->MsgHTML('<p>You received an invoice!</p>')
    ->AddFile($filepath)
    ->Send();
#12072 report it
realtebo at 2013/02/26 05:19am
Is this upgradable to swiftmailer 4.3 ?

What if I need to update SwiftMailer to latest version !?

#10654 report it
MaxLord at 2012/11/11 08:44pm
How to add attachment to letter?

plz show example

#10072 report it
seb7 at 2012/10/03 09:10am
can't update

Hi, extension is good but unfortunatly, it's not just possible to update the lib to the lastest version (4.2.1)

#8925 report it
paskuale at 2012/07/08 04:46am
Swift_TransportException

Return me error "Process could not be started Impossibile trovare il percorso specificato."

thanks

#7554 report it
luckymancvp at 2012/03/29 03:23pm
Need a help

How can I use your extension with gmail ?

gmail use port 465 with ssl

#7264 report it
Rochdi at 2012/03/08 05:36am
Cool

Nice wrapper. I like it.

#6183 report it
b3atb0x at 2011/12/17 08:27am
Why I did this

Guys, the main purpose of me writing this extension is because my app used available "mailer" extension which used PHPMailer, but I had problems with sending mail by SMTP via PHPmailer, so i did this extension that does not change the way my app sends emails:

Yii::app()->mailer->AddAddress($email);
Yii::app()->mailer->Subject = $newslettersOne['name'];
Yii::app()->mailer->MsgHTML($template['content']);
Yii::app()->mailer->Send();

But it changes how the mail gets sent. Available SwiftMailer extensions did not allow me just to change extension I use for "mailer" component -- they all suggest a lot (more then 1 byte is a lot) of code to alter in my controllers and other places - I did bot need that, I just needed to change the mailer itself, so I wrote this extension, and shared it here mainly because I believe I might be not the only one with the same issues.

Thank you, love and peace to all!

#6180 report it
jacmoe at 2011/12/16 07:08pm
I like this!

I am a big fan of the 'other' extension, but I appreciate that this is trying to be as lean as possible. I might switch to this one instead. :)

You can still use templates: Just render to a string, and pass it in. Easy as that.

#6173 report it
b3atb0x at 2011/12/16 09:22am
extension

I'd say it's different in a way of being different. The example code is all you need to send email. No templates, though no extra code to write. It is just a sender, it's not supposed to support templates.

#6146 report it
wisp at 2011/12/15 01:39pm
extension

In what way is this different from this extension? http://www.yiiframework.com/extension/mail/

Leave a comment

Please to leave your comment.

Create extension