Mail

Send E-Mails with Redspark

Redspark_Mail is a feature-extension of Zend_Mail. It extends the Zend_Mail not only for preconfigured options from Redspark ini files, but also adds support for loggin, disabling the mailsystem, send mails to developer only and mail caching.

Redspark_Mail

Redspark_Mail is a feature-extension of Zend_Mail. It extends the Zend_Mail not only for preconfigured options from Redspark ini files, but also adds support for loggin, disabling the mailsystem, send mails to developer only and mail caching.

Configuration

The available configuration options cann all be found inside Redspark/RsApplication/Config/Default/Mail.ini. The most useful setting to enable the mailing are as follows:


        [Mail]
        enabled                = true;
        log                    = false;
        mailer_name            = "RedSpark Framework";
        mailer_address        = "noreply@redsparkframework.de"
    
TODO: There should be a module inside RedSparkCore to help you with the mail configuration.

Usage

Sending an email is zend-like, but a bit easier:

<?php

        
/* Prepare mail */
        
$m = new Redspark_Mail();
        
$m->addTo('noreply@redsparkframework.de');
        
$m->setSubject('Mail Subject');
        
$m->setBodyText('Mail Body');

        
/* Send mail */
        
try {
            
$m->send();
        } catch(
Exception $e) {} 
    
?>

Mail caching

The mail caching is done by an extra Mail_Transport agent. This is brought in place, every time the cache option is set to true. If you intend to send cached mails in your action, you have to disable the cache option inside the config an re-enable it afterwards.

<?php

        
/* Disable cache */
        
$cached Broker::getConfig()->getSection('Mail')->get('cache',false);
        
$num_mails 20;
        
$mails $mailcache->popMails($num_mails);
        
        
/* Send all mails */
        
foreach($mails AS $mail) {
            try {
                
$mail->send();
            } catch(
Exception $e) {} 
        }
        
        
/* Re-Enable cache */
        
Broker::getConfig()->getSection('Mail')->cache $cached;
    
?>


Tutorials

Die eigene App

Kuborgh GmbH

Hamburg 040 819 773 770 Köln 0221 276 66 96 xxx@xxx.xx www.kuborgh.de

RedSpark Community

RedSpark Community

Community Website
RedSpark Apps

RedSpark Apps

Zur Übersicht
RedSpark Download

RedSpark Basispaket

Zum Download
Key facts