email

An email extensions with view/layout support, debug mode, and html support
9 followers

This is an email extension. Allows fields such as BCC, CC, Reply-to addresses, and others. Also has an excellent debug mode, in which the extension does not actually send emails, but instead outputs it to the screen.

I have written a new mail extension for yii, which I believe to be superior to this one. Here it is

Documentation

Requirements

  • Yii 1.0.2 or above

Installation

  • Extract the release file under protected/extensions

Usage

You can configure the extension as follows:

'components'=>array(
    'email'=>array(
        'class'=>'application.extensions.email.Email',
        'delivery'=>'php', //Will use the php mailing function.  
        //May also be set to 'debug' to instead dump the contents of the email into the view
    ),
...

You need to put the debug widget somewhere in the view or layout, if you wish to use debug mode

<?php $this->widget('application.extensions.email.debug'); ?>

Example code:

$email = Yii::app()->email;
$email->to = 'admin@example.com';
$email->subject = 'Hello';
$email->message = 'Hello brother';
$email->send();

Instead of defining the message with $email->message, you could instead define a view (and layout if you wish) to use as the email content. This is much more flexible and maintains MVC better.

Change Log

January 12, 2009

  • Initial release 1.0

January 23, 2009

  • Updated to support multi-byte and different languages.

January 24, 2009

  • 2nd attempt to support multi-byte.

Total 17 comments

#4079 report it
rahulraj at 2011/06/04 05:36am
I have a problem in sending email !

The email extension is working fine. But whenever I try to send email through gmail ids, I get an error -

mb_send_mail() [function.mb-send-mail]: SMTP server response: 530 SMTP authentication is required.

Please help me out. :((

#3827 report it
ppravin88 at 2011/05/12 04:56am
Sending email takes much time!!

hi there,

The extension works great! The only problem that i faced when i hosted my app online for testing is that once the email function is invoked in the controller , i receive the email after a couple of hours rather than instantly, i have tried it many times , but no changes at all, not even once get an instant email.

I have hosted my app in my sub-domain. Will it be a cause for this issue or is it something to do with the extension?

Lemme know if anybody else have this problem or anyways to get around it..!

Thanks..!

#3072 report it
tarakarama at 2011/03/14 02:36am
Views are not working

Hi,

I installed email extension. Normal mail its working fine. But I tried to create a view in email/views/myview.php . When I run the app, I am getting error saying controller can't find the view.

And one more query, Can I add images to this view?

Could you please help me with this?

#2540 report it
nacesprin at 2011/01/15 11:52am
Using views when send mail

Studying a bit the file /protected/extensions/email/Email.php, I get the method to manage views in body messages:

First of all, we call the mail method from your controller or model:

$email = Yii::app()->email;
$email->to = 'to@mail.com';
$email->subject = 'Subject text';
$email->view = 'myview';
$email->viewVars = array('var1'=>$var1,'var2'=>$var2);
$email->send();

Next, you need to create the view in /protected/views/email/myview.php

File /protected/views/email/myview.php:

Some email vars:<br>
Email:<?php echo $email->subject ?>
<br>
From:<?php echo $email->from ?>
<br>
Now, my own vars:<br>
Var1:<?php echo $var1 ?>
<br>
Var2:<?php echo $var2 ?>

Just only that.

#2509 report it
iprathik at 2011/01/12 12:05am
How do i use a view

can u please tell me how can i use a view

#429 report it
nacesprin at 2010/06/03 05:10pm
send a view into $email->message

You said in your documentation: "Instead of defining the message with $email->message, you could instead define a view (and layout if you wish) to use as the email content. This is much more flexible and maintains MVC better."

Please, could you be kind to write a little strip code to get it?

Thanks.

#563 report it
Alex Muir at 2010/04/25 06:57am
Really good

I've realised I use this extension in every project now. Excellent work.

#751 report it
zillabyte at 2010/03/05 08:52pm
Still getting Error with encoding

I get an error of call to undefined function. I also tried the suggestion from above:

"if you have error with encoding -> after line 139 mb_language($this->language); insert mb_internal_encoding($this->contentType);"

It looks like I may not have something installed on my machine. I have Windows 7 x64 with standard install of php. Could I be missing something?

#858 report it
kylian at 2010/02/17 10:44am
Error with encoding - thank you r0n9.GOL

Thank you lot. Your tip is perfect.

#1126 report it
christian at 2009/12/02 08:30am
Headers with problems

I have some problems with headers, because the separator is \r\n and it should be just \n.

Some email clients separate \r\n in two lines, so they email get it like this, and it doesn't work!:

Content-Type: text/html; charset=utf-8

MIME-Version: 1.0

Mime-Version: 1.0

Content-Transfer-Encoding: BASE64

...

#1293 report it
r0n9.GOL at 2009/09/26 02:38am
Error with encoding

if you have error with encoding -> after line 139 mb_language($this->language); insert
mb_internal_encoding($this->contentType);

#1612 report it
lithrel at 2009/06/03 09:49am
Works very well :)

Thank you for this plugin !

Just a typo in the documentation for the debug widget, it's 'application.extensions.email.Debug' (debug will fail on linux)

#1651 report it
raphael at 2009/05/24 01:33pm
Very good but can be improved ;-)

The plugin works great but you can improve it by allowing user to give two different view, one for HTML and one for plain text. Then you should update the content type of the email according to the given view.

I also have problem with the content encoding. I'll look into this issue and give a feedback ASAP.

#1750 report it
jonah at 2009/04/18 01:36am
.

you mean replyTo?

$email->replyTo = 'namename@email.com';

#1754 report it
arsitek at 2009/04/17 10:37pm
Debug sender data

How to add sender data in debug?

<?php $email->from = 'namename@email.com'; $email->to = 'adminNameadmin@example.com'; $email->subject = 'Hello'; $email->message = 'Hello brother';

#1886 report it
jonah at 2009/01/23 11:46pm
sure

I can do that. I am uploading the new version.

Not sure if I did it correctly though! I had no prior experience with mb_send_mail(). Comments?

#1887 report it
junamai2000 at 2009/01/23 02:40am
Please Support Multi-Byte Language

This extension does not support multi-byte language. So, I use mb_send_mail function instead of mail function. we have to change charset on 'Content-Type' too.

please add delivery mode for multi-byte languages.

Leave a comment

Please to leave your comment.

Create extension
Downloads
  • License: New BSD License
  • Developed by: jonah
  • Category: Mail
  • Votes: +20 / -2
  • Downloaded: 3,731 times
  • Created on: Jan 12, 2009
  • Last updated: May 21, 2010