mailSender

The class mailSender provides an easy-to-use mail delivering layer. It enables the developer to create and send mails adventure style like. To use this component it must be imported using the
PHP code
import('tools::mail','mailSender');
directive. The following code snippet shows an easy example:
PHP code
$MAIL = &$this->getAndInitServiceObject('tools::mail','mailSender','Standard'); $MAIL->setSubject('My Subject'); $MAIL->setContent('My Text'); $MAIL->setRecipient('test@example.com','Your Name'); $MAIL->sendMail();
In order to send an e-mail to more than one recipient the methode setRecipient() can be used several times. Another alternative is to utilize the setCCRecipient() method to add CC recipients to the mail. Adding BCC recipients is supported by the setBCCRecipient() method.
A detailed example can be found in the Contact form chapter.

To use this component it must be configured prior to use. Therefor a configuration file with the name
Code
{ENVIRONMENT}_mailsender.ini
must be stored in the folder
Code
/apps/config/tools/mail/{CONTEXT}/
The third parameter used in the function call of the getAndInitServiceObject() methode above specifies the configuration section to use. Each section must contain the following configuration keys:
APF configuration
[{section name}] Mail.SenderName = "" Mail.SenderEMail = "" Mail.ReturnPath = "" Mail.ContentType = "text/plain; charset=iso-8859-1"
Mail.ContentType can be filled with any valid MIME type definition. The configuration file can contain any amount of sections so that the mailSender can be used in various modules within one application in parallel.


Comments

Do you want to add a comment to the article above, or do you want to post additional hints? So please click here. Comments already posted can be found below.
There are no comments belonging to this article.