Zum Inhalt springen

Powermail with multiple receivers based on checkboxes

Erstellt am 16. Oktober 2012 · Noch keine Antworten

Tags: Frage, English

tomitzel ·

Hello,

I have a form with a checkbox, to each checkbox the value is an email address. I want to send the form to all email addresses that were checked before.
I am using Powermail 2.0 and for that I've used the method with userFunc & typocript.

I've added in the field Receiver email:

{f:cObject(typoscriptObjectPath:'lib.powermail_receiver')}

The typoscript:

includeLibs.manipulatePowermailReceiver = fileadmin/templates/ext/powermail/manipulateReceiver.php
lib.powermail_receiver = USER
lib.powermail_receiver.userFunc = user_manipulatePowermailReceiver->getEmail

The script:

class user_manipulatePowermailReceiver {

    public function getEmail($content = '', $conf = array()) {
        $variables = t3lib_div::_GP('tx_powermail_pi1');
        $receiversArr = $variables['field']['1'];

        foreach ($receiversArr as $rec) {
            if (!empty($rec) && $rec != '') {
                $receiversArrFiltered[] = $rec;
            }
        }
        
        $receivers = implode(',', $receiversArrFiltered);
        
        return $receivers;
    }

}

My problem is that if there is checked more than one email address, the form is not send and in FE I only see
Error: The mail wasn't sent.

I've noticed during debuging that if I have email1@test.com,email2@test.com coming out of the script it doesn;t work, but if the same values are inserted in the plugin settings at Receiver email then it works and it sends to both email address.

Any suggestions?