I am using laravle 5.3 to send emails. I want to pass data for viewing through a method.
I created a mail MytestMail.php
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class MytestMail extends Mailable {
public $dataArray;
use Queueable,
SerializesModels;
public function __construct($dataArray) {
$this->dataArray= $dataArray;
}
public function build() {
$address = 'test@gmail.com';
$name = 'asasa';
$subject = 'sasasasub';
return $this->view('emails.myTestMail')
->from($address, $name)
->cc($address, $name)
->bcc($address, $name)
->replyTo($address, $name)
->subject($subject)
->with([
'name' => $this->dataArray->name,
'password' => $this->dataArray->password,
'E_id' => $this->dataArray->E_id,
'email' => $this->dataArray->email,
]);
;
}
}
Now i get an error
Trying to get a non-object property
When I print_r $ this-> dataArray , I got an array with values
Array ( [name] => sdsdsds [E_id] => 0123 [password] => sdsd [username]
=> sdsdsdsds@sgxcxcxmail.com )
Please help me ... Why am I getting this error message?
source
share