简体   繁体   中英

Sending mails via Gmail, 'bbc' not working - Laravel 5.2

I'm sending emails to many users and i want to add bbc, the sending itself is working but when I add bbc i'm getting this error

call_user_func_array() expects parameter 1 to be a valid callback, class 'Swift_Message' does not have a method 'bbc'

I'm posting the controller:

use Illuminate\Http\Request;

use App\User;
use Illuminate\Support\Facades\Mail;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class EmailController extends Controller
{
    public function sendEmail(){


        $users = User::where('type','student')->pluck('email');


            foreach ($users as $user) {
                Mail::send('emails.test', ['user' => $users], function ($message) use ($users, $user) {
                    $message->from('mg.kvelichkov@gmail.com', 'МГ "Константин Величков"');
                    $message->to($user);
                    $message->bbc($user);
            });

        }

        return "Your email has been sent successfully";
    }
}

The correct method is bcc not bbc

Just change it to:

$message->bcc($user);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM