mailSender

Please note that this component has been marked as deprecated in version 2.0. Please use another solution (e.g. PHPM@iler) since the code is removed in version 2.1.

The class mailSender provides an easy-to-use mail delivering layer. It enables the developer to create and send mails adventure style like.

The following code snippet shows an easy example:

PHP code
$sender = &$this->getAndInitServiceObject('APF\tools\mail\mailSender', 'Standard'); $sender->setSubject('My Subject'); $sender->setContent('My Text'); $sender->setRecipient('test@example.com', 'Your Name'); $sender->sendMail();

In order to send an e-mail to more than one recipient the method 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
/APF/config/tools/mail/{CONTEXT}/

The second 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=utf-8"

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.