lundi 3 juillet 2017

Laravel Mail send even if cc and bcc is null

I have mail send function in laravel

public static function Compose($to,$cc,$bcc,$subject,$body)
    {

        // return $to;
        try
        {
            $data = [
                'body' => $body
            ];

            if(env('APP_ENV') == "local") 
            {
                $email["subject"] = $subject;
                $email["to"] = $to;
                $email["cc"] = $cc;
                $email["bcc"] = $bcc;
                Mail::send('email.composeMail', $data, function ($message) use ($email) {

                    $message
                        ->subject($email["subject"])
                        ->to($email["to"]);
                        ->cc($email["cc"]);
                        ->bcc($email["bcc"]);
                });
            }
            else
            {
                $email["subject"] = $subject;
                $email["to"] = $to;
                $email["cc"] = $cc;
                $email["bcc"] = $bcc;

                Mail::send('email.composeMail', $data, function ($message) use ($email) {

                    $message
                        ->subject($email["subject"])
                        ->to($email["to"]);
                        ->cc($email["cc"]);
                        ->bcc($email["bcc"]);
                });
            }
        } 
        catch (\Exception $e) 
        {
            Log::critical('Critical error occurred upon processing the transaction in Email.php -> Email class -> RevertPropertyToInbox method');
            throw new CustomErrorHandler($e->getMessage(),Constant::LogLevelCritical);
        }
    }

In many cases CC and BCC is Null. But mails aren't sent and I am getting error message

enter image description here

Here , I want to use code as it is without checking if CC or BCC is null, Is there any thing missed by me so that I can achieve what I am planning to .



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire