Class YiiMail

(line 45)

Description

CApplicationComponent
   |
   --YiiMail

Located in File: /YiiMail.php

YiiMail is an application component used for sending email.

You may configure it as below. Check the public attributes and setter methods of this class for more options.

 return array(
 	...
 	'import => array(
 		...
 		'ext.mail.YiiMailMessage',
 	),
 	'components' => array(
 		'mail' => array(
 			'class' => 'ext.yii-mail.YiiMail',
 			'transportType' => 'php',
 			'viewPath' => 'application.views.mail',
 			'logging' => true,
 			'dryRun' => false
 		),
 		...
 	)
 );

Example usage:

 $message = new YiiMailMessage;
 $message->setBody('Message content here with HTML', 'text/html');
 $message->subject = 'My Subject';
 $message->addTo('johnDoe@domain.com');
 $message->from = Yii::app()->params['adminEmail'];
 Yii::app()->mail->send($message);



Class Variables

Summary:
bool $dryRun
bool $logging
mixed $mailer
mixed $transport
string $viewPath

$dryRun = false (line 57)

Data type : bool

  • var: - whether to disable actually sending mail. Defaults to false.
  • access: - public

$logging = true (line 51)

Data type : bool

  • var: - whether to log messages using Yii::log(). Defaults to true.
  • access: - public

$mailer (line 98)

Data type : mixed

  • var: - Holds the SwiftMailer mailer
  • access: - protected

$transport (line 93)

Data type : mixed

  • var: - Holds the SwiftMailer transport
  • access: - protected

$transportOptions (line 88)

Data type : string

  • var: - options specific to the transport type being used. To set options for STMP, set this attribute to an array where the keys are the option names and the values are their values. Possible options for SMTP are:
    • host
    • username
    • password
    • port
    • encryption
    • timeout
    • extensionHandlers
    See the SwiftMailer documentaion for the option meanings.
  • access: - public

$transportType = 'php' (line 64)

Data type : string

  • var: - the delivery type. Can be either 'php' or 'smtp'. When using 'php', PHP's http://www.php.net/mail function will be used. Defaults to 'php'.
  • access: - public

$viewPath = 'application.views.mail' (line 70)

Data type : string

  • var: - the path to the location where mail views are stored. Defaults to 'application.views.mail'.
  • access: - public

Class Constants

Summary:

Method Detail

Summary:
static string log (YiiMailMessage $message)
int batchSend (YiiMailMessage $message, [ &$failedRecipients = null], [ $it = null], array &$failedRecipients,, Swift_Mailer_RecipientIterator $it,)
mixed getTransport ()
void init ()
void registerScripts ()
int send (YiiMailMessage $message, [ &$failedRecipients = null], array &$failedRecipients,)
void sendSimple (mixed $from, mixed $to, string $subject, string $body)

Static Method log (line 189)

string log( YiiMailMessage $message)

Logs a YiiMailMessage in a (hopefully) readable way using Yii::log (as long as $this->logging is set to true).

Parameters

Info

  • return - log message
  • access - public

Method batchSend (line 158)

int batchSend( YiiMailMessage $message, [ &$failedRecipients = null], [ $it = null], array &$failedRecipients,, Swift_Mailer_RecipientIterator $it,)

Send the given YiiMailMessage to all recipients individually.

This differs from send() in the way headers are presented to the recipient. The only recipient in the "To:" field will be the individual recipient it was sent to.

If an iterator is provided, recipients will be read from the iterator one-by-one, otherwise recipient data will be retreived from the YiiMailMessage object.

Sender information is always read from the YiiMailMessage object.

The return value is the number of recipients who were accepted for delivery.

Parameters

Info

Method getMailer (line 226)

Swift_Mailer getMailer( )

Gets the SwiftMailer Swift_Mailer class instance

Info

  • access - public

Method getTransport (line 203)

mixed getTransport( )

Gets the SwiftMailer transport class instance, initializing it if it has

not been created yet

Info

Method init (line 105)

void init( )

Calls the registerScripts() method.

Info

  • access - public

Method registerScripts (line 236)

void registerScripts( )

Registers swiftMailer autoloader and includes the required files

Info

  • access - public

Method send (line 130)

int send( YiiMailMessage $message, [ &$failedRecipients = null], array &$failedRecipients,)

Send a YiiMailMessage as it would be sent in a mail client.

All recipients (with the exception of Bcc) will be able to see the other recipients this message was sent to.

If you need to send to each recipient without disclosing details about the other recipients see batchSend().

Recipient/sender data will be retreived from the YiiMailMessage object.

The return value is the number of recipients who were accepted for delivery.

Parameters

  • YiiMailMessage $message:
  • array &$failedRecipients,: optional
  • &$failedRecipients:

Info

Method sendSimple (line 172)

void sendSimple( mixed $from, mixed $to, string $subject, string $body)

Sends a message in an extremly simple but less extensive way.

Parameters

  • mixed $from: from address, string or array of the form $address => $name
  • mixed $to: to address, string or array of the form $address => $name
  • string $subject: subject
  • string $body: body

Info

  • access - public

Inherited Variables

Inherited Class Variable Summary

Inherited Methods

Inherited Method Summary


Documentation generated on Fri, 12 Nov 2010 20:45:32 +0000 by phpDocumentor 1.4.3