Class cMailer
Mailer class for all mail sending purposes.
The class cMailer is a facade for the SwiftMailer library that simplifies the process of sending mails by providing some convenience methods.
<strong>Simple example</strong>
$mailer = new cMailer(); $mailer->sendMail(null, 'recipient@contenido.org', 'subject', 'body');
<strong>Default sender of mails</strong> When sending a mail using the sendMail() method of the cMailer class you can give a mail sender as first parameter. This can either be an email address as string or an array with the email address as key and the senders name as value. If you pass an empty value instead the default mail sender is used. This default mail sender can be configured with the system properties system/mail_sender and system/mail_sender_name. If no default mail sender is configured it defaults to "noreply@contenido.org" and "CONTENIDO Backend".
<strong>User defined mail sender example</strong>
$mailer->sendMail('sender@contenido.org', 'recipient@contenido.org', 'subject'); $mailer->sendMail(array('sender@contenido.org' => 'sender name'), 'recipient@contenido.org', 'subject');
<strong>Logging mails</strong>
- Swift_Mailer
- cMailer
Copyright: four for business AG <www.4fb.de>
License: http://www.contenido.org/license/LIZENZ.txt
Author: Rusmir Jusufovic
Author: Simon Sprankel
Todo: explain logging of mails via _logMail() <strong>Resending mails</strong>
Todo: explain resending of mails via resendMail() <strong>Sending user created messages</strong> Creating your own message is e.g. necessary in order to send mails with attachments as the simplified interface the cMailer class offers does not yet provide means to do so.
Todo: explain sending of user created messages via send() <strong>Default transport</strong> By default the cMailer tries to use an SMTP transport with optional authentication. If starting the SMTP transport fails, a simple MAIL transport will be used (using PHP's mail() function). <strong>User defined transport</strong> When creating a cMailer instance an arbitrary transport can be given to override the afore mentioned behaviour. <strong>User defined transport example</strong> <code>
Todo: add example </code> <strong>User defined character set</strong>
Todo: explain setCharset()
Located at classes/class.mailer.php
public
|
|
public static
Swift_Transport
|
#
constructTransport( string $mailHost, string $mailPort, string $mailEncryption = NULL, string $mailUser = NULL, string $mailPass = NULL )
This factory method tries to establish an SMTP connection to the given mail host. If an optional mail host user is given it is used to authenticate at the mail host. On success a SMTP transport instance is returned. On failure a simple MAIL transport instance is created and returned which will use PHP's mail() function to send mails. |
public
|
#
setCharset( string $charset )
Sets the charset of the messages which are sent by this mailer. If you want to use UTF-8, you do not need to call this method. |
public
integer
|
|
public
integer
|
|
public
|
|
private
string|array
|
#
encodeField( string|array $value, string $charset )
Encodes the given value / array of values using conHtmlEntities(). |
private
string|array
|
#
decodeField( string|array $value, string $charset )
Decodes the given value / array of values using conHtmlEntityDecode(). |
private
string|boolean
|
private
string
|
$_mailSender | 'noreply@contenido.org' |
#
Mail address of the default mail sender. This will be read from system property system/mail_sender. Can be overriden by giving a sender when sending a mail. |
private
string
|
$_mailSenderName | 'CONTENIDO Backend' |
#
Name of the default mail sender. This will be read from system property system/mail_sender_name. Can be overriden by giving a sender when sending a mail. |
private
string
|
$_mailHost | 'localhost' |
#
Name of the mail host. This will be read from system property system/mail_host. |
private
integer
|
$_mailPort | 25 |
#
Port of the mail host. This will be read from system property system/mail_port. |
private
string
|
$_mailEncryption | NULL |
#
The mail encryption method (ssl/tls). This will be read from system property system/mail_encryption. |
private
string
|
$_mailUser | '' |
#
Name of the mail host user. This will be read from system property system/mail_user. Used for authentication at the mail host. |
private
string
|
$_mailPass | '' |
#
Password of the mail host user. This will be read from system property system/mail_pass. Used for authentication at the mail host. |