1

The problem is the following: I have an Html::mailto() in my Datacolumn where I wanna give the value of the subject with it. I can't use swiftmailer or some other extensions because I don't want to generate an email, instead, I want to open outlook, by clicking the hyperlink, and have the subject pre-written there.

This is the function:

public static function mailto($text, $email = null, $options = [])

This is my code:

 [   
   'class'=>'\kartik\grid\DataColumn',
   'attribute' => 'email',
   'label' => 'E-Mail',
   'format' => 'raw', 
   'value' => function($model){ 
        $email =  SucheBiete::find()    
            ->select(['email'])
            ->join('INNER JOIN', 'user', 'user.user_id = suche_biete.user_user_id')
            ->scalar();

             return Html::mailto('Kontaktaufnahme mit: ' . $email,$email, ['subject' => 'Hi There']);
    }
]

It works but without getting the subject:

enter image description here

is the $option parameter the right one to give a subject,textbody or cc?

Muhammad Omer Aslam
  • 22,976
  • 9
  • 42
  • 68
  • 3
    Possible duplicate of [Can I set subject/content of email using mailto:?](https://stackoverflow.com/questions/4782068/can-i-set-subject-content-of-email-using-mailto) – Muhammad Omer Aslam Jan 24 '19 at 18:14
  • I saw a lof of code about mailto in my research, but still didnt know how to implement it in this specific situation. I tried a lot of things and was tired of it. So for me personally it is no duplicate :) Thank you anyway! – IshitYouNot Jan 25 '19 at 09:10

1 Answers1

1

Try to attach the subject to the second parameter:

return Html::mailto('...: ' . $email,"$email?subject=HiThere" ); 

Maybe you need to encode() the subject for preserving spaces.

WeSee
  • 3,158
  • 2
  • 30
  • 58