Yii Framework Forum: Yii-Multimailer Extension - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii-Multimailer Extension Yii extension for sending or saving emails. Rate Topic: -----

#1 User is offline   Bizley 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 400
  • Joined: 29-July 14
  • Location:Wrocław

Posted 02 September 2014 - 01:50 PM

Yii-MultiMailer allows you to send email with the help of PHPMailer class or to store emails in database (to send them later using Java workers for example). You can use templates for email body if needed.

http://www.yiiframew...on/multimailer/

See Yii-MultiMailer on GitHub: https://github.com/b...Yii-MultiMailer

How to use it:

$mailer = Yii::app()->MultiMailer->to('example@server.com', 'Recipient');
$mailer->subject('Example email subject');
$mailer->body('<h1>Hello</h1><p>This is test.<br>MultiMailer test.</p>');

if ($mailer->send()) {
    // success
}
else {
    // error
}


You can chain the methods like:

Yii::app()->MultiMailer->to('example@server.com', 'Recipient')->subject('Example email subject')->body('<h1>Hello</h1><p>This is test.<br>MultiMailer test.</p>')->send();


Database emails storage:

You can use MultiMailer to save email in database instead of sending it immediately. Email will be prepared using the PHPMailer as well.

First the configuration:
return array(
    'components' => array(
        'MultiMailer' => array(
            'class' => 'ext.MultiMailer.MultiMailer',
            'setFromAddress' => 'from@yourwebsite.com',
            'setFromName' => 'Your Website',
            'setMethod' => 'DB',
            'setDbModel' => 'Email',
        ),
    ),
);


You need to prepare the database table for email storage with Active Record model class ('Email' in the example above). Default table columns are:

  • 'email'
  • 'name'
  • 'subject'
  • 'body'
  • 'alt'


See the documentation for information about adding or switching the columns off.

The usage in this case is the same as before but remember that method send() will not actually send the email but will save it in database.
0

#2 User is offline   Bizley 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 400
  • Joined: 29-July 14
  • Location:Wrocław

Posted 28 September 2014 - 03:44 PM

Changes in version 1.1:

  • added Gmail method
  • added Sendmail method
  • added qmail method
  • added POP before SMTP method
  • added CC and BCC methods
  • fixed error with saving multiple emails to database when adding multiple recipients with the same email address

0

#3 User is offline   Bizley 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 400
  • Joined: 29-July 14
  • Location:Wrocław

Posted 26 October 2014 - 07:23 AM

Please upgrade your version to 1.11 (available here or at GitHub).
Typo in code fixed.
1

#4 User is offline   Bizley 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 400
  • Joined: 29-July 14
  • Location:Wrocław

Posted 01 November 2014 - 02:15 PM

Version 1.2 is available:

  • New method db() for altering DB model columns
  • Messages are now translated with Yii::t() (can be switched off)
  • DB model validation errors can be tracked now with getMultiError(true)


About db() method.

Until v1.2 you could alter DB model parameters in config file like this:

return array(
    'components' => array(
        'MultiMailer' => array(
            'class'             => 'ext.MultiMailer.MultiMailer',
            'setFromAddress'    => 'example@example.com',
            'setFromName'       => 'Example',
            'setMethod'         => 'DB',
            'setDbModel'        => 'Email',
            'setDbModelColumns' => array(
                'alt'       => null,
                'email'     => 'address',
                'others'    => array(
                    'status' => 'pending',
                ),
            ),
        ),
        // ...
    ),
    // ...
);


This configuration means:
  • column 'alt' is not present in DB model, skip it
  • column for storing email address is named 'address' in DB model, not 'email'
  • additional column 'status' should be saved with value 'pending'


In v1.2 this still works but the problem is what to do if we want to set status 'sent' for one of the emails?
Before v1.2 you could only alter column for single instance by changing the $setDbModelColumns like:

$mailer = Yii::app()->MultiMailer;
$mailer->setDbModelColumns['others']['status'] = 'sent';


Now you can use db() method for this.

$mailer = Yii::app()->MultiMailer;
$mailer->db('status', 'sent');


You can alter single column with db($name, $value) parameters or set many of them using the array db(array($name1 => $value1, $name2 => $value2)).
0

#5 User is offline   Bizley 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 400
  • Joined: 29-July 14
  • Location:Wrocław

Posted 11 February 2015 - 03:31 AM

Version 1.3 is available with PHPMailer updated to 5.2.9.
0

#6 User is offline   Bizley 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 400
  • Joined: 29-July 14
  • Location:Wrocław

Posted 24 February 2015 - 04:13 AM

Version 1.4 is available now with attachments methods and helper methods for adding many recipients at once.
0

#7 User is offline   Bizley 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 400
  • Joined: 29-July 14
  • Location:Wrocław

Posted 11 May 2015 - 04:44 AM

Multimailer has been updated to v1.4.1 with PHPMailer 5.2.10.
0

#8 User is offline   Bizley 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 400
  • Joined: 29-July 14
  • Location:Wrocław

Posted 27 May 2015 - 02:10 AM

Version 1.5 released:

  • PHPMailer class is now extended with ProxyPHPMailer class.
  • Library files are included using Yii::import() now.
  • New property 'setPattern' allows to set validation pattern for PHPMailer in case of problems with PCRE8 regex (default 'auto').
  • New public method 'getPhpmailer()' allows to control PHPMailer directly.
  • New public method 'clearAllRecipients()' allows to remove all recipients (including CC and BCC recipients)
  • Method '_processBody()' is using Yii::renderFile() instead of Yii::renderPartial() in case of command line action and properly throws exception instead of using 'setMultiError()'


http://www.yiiframew...on/multimailer/
https://github.com/b...Yii-MultiMailer
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users