I created a trait in MailTrait.php, the following is my code
namespace App\Traits;
use Mail;
trait MailTrait
{
public function fn_send_mail($arr_recepients, $str_subject, $str_content)
{
Mail::send('mail.mailsample', ['content' => $str_content], function($message)
{
$message->to($arr_recepients);
$message->from('abc.org', 'abc');
$message->subject($str_subject);
});
if(Mail:: failures())
return false;
else
return true;
}
}
from my controller called the function fn_send_mail() and passed parameter as below
$status = $this->fn_send_mail(['123.gmail.com'],'hai', 'hai');
i am getting this error
ErrorException in MailTrait.php line 14: Undefined variable: arr_recepients
please help me!!