Yii Framework Forum: Sending mails to mutliple recipients - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Sending mails to mutliple recipients [solved]

#1 User is offline   tklustig 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 400
  • Joined: 20-April 17
  • Location:Hannover

Posted 03 January 2018 - 01:11 PM

Hi guys, I know how to program method in order to send mail to multiple recipients in Controller, but I don't know where to get information about mail adresses. In my database,there is just one attribute, so I code like this in order to get one single adress of recipient:
<?= $form->field($model, 'mail_antwortadresse')->textInput(['value' => $zieladresse])->label('Zieladresse') ?>



I intend to set one more field called bb:
Multiple recipients should be provided by this field seperated by semicolon. Unfortunately, i don't know how to integrate field bb: in my application. Following code throws out error
      <?= yii\widgets\ActiveField::textInput()->label('bb:') ?>



Any ideas, how to implement informations of multiple recipients given by formular?
0

#2 User is offline   alrazi 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,546
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 04 January 2018 - 12:20 AM

right way do it is to add a virtual attribute in your model class

class EmailModel extend FormModel
{
    // add this property to you model like so
    public $bb;
    // ...
}

// and create a field for bb 
<?= $form->field($model, 'bb')->textInput()->label('bb:') ?>


don't forget to mark bb as safe in your validation rules

[['bb'], 'safe']

1

#3 User is offline   tklustig 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 400
  • Joined: 20-April 17
  • Location:Hannover

Posted 04 January 2018 - 04:53 AM

View Postalrazi, on 04 January 2018 - 12:20 AM, said:

right way do it is to add a virtual attribute in your model class

class EmailModel extend FormModel
{
    // add this property to you model like so
    public $bb;
    // ...
}

// and create a field for bb 
<?= $form->field($model, 'bb')->textInput()->label('bb:') ?>


don't forget to mark bb as safe in your validation rules

[['bb'], 'safe']


Thx for this,but:
If I gonna marking bb as safe, I am not able to read in multiple recipients,which I intend to treat as an array, similar to this:

$extract_outer = explode("'", $model->bb);
$extract_inner = explode(";", $extract_outer[0]);

as soon I changed informations about recipients to an array, I intend sending mail in Controller itering about $extract_inner
Hope,my intention will do its job as planned. What do U think? I know, it's to me validating informations transformed to an array using string functions of php...
0

#4 User is offline   alrazi 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,546
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 04 January 2018 - 06:04 AM

by marking bb as safe should not change the value of it, it tells yii to let the value be set by mass assignment with method calls like

$model->load($_POST['model']);

I don't think its the validation maybe you can dump your $this->bb and see if the values match your input
0

#5 User is offline   tklustig 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 400
  • Joined: 20-April 17
  • Location:Hannover

Posted 05 January 2018 - 04:47 PM

View Postalrazi, on 04 January 2018 - 06:04 AM, said:

by marking bb as safe should not change the value of it, it tells yii to let the value be set by mass assignment with method calls like

$model->load($_POST['model']);

I don't think its the validation maybe you can dump your $this->bb and see if the values match your input

Okay. So, I'll do!
Thx for ur help....
P.S.: This thread can be closed as succesfully solved!




0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users