Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Rafazion's avatar

Address in mailbox given [] does not comply with RFC 2822, 3.6.2.

My QuizzesController:

public function getQuiz($id) { $quiz = $this->quiz->getQuiz($id); if(!$quiz) { return Response::json(['response' => 'Item nao encontrado!'], 400); } return Response::json($quiz, 200); }

public function allQuiz()
{
    return Response::json($this->quiz->allQuiz(), 200);
}

public function saveQuiz()
{
    return Response::json($this->quiz->saveQuiz(), 200);
}

public function sendMail()  
{
    $input = Input::all();      

    $quiz = $this->quiz->getModel()->findOrFail($input['id']);

    $player = $quiz->player;

    Mail::send('emails.welcome', ['key' => 'value'], function($message) use ($player)
    {
        $message->to($player->email, $player->name)->subject('Parabéns você jogou o Quiz do Nutrição em Jogo! Nosso novo encontro será na semana que vem.');
    });
    
}

}

My Routes:

//Webservices Quiz Route::group(['prefix' => 'api2'], function() { Route::group(['prefix' => 'quiz'], function() {
Route::get('', ['uses' => 'Admin\QuizzesController@allQuiz']);

    Route::get('{id}', ['uses' => 'Admin\QuizzesController@getQuiz']);

    Route::post('', ['uses' => 'Admin\QuizzesController@saveQuiz']);

    Route::post('mail', ['uses' => 'Admin\QuizzesController@sendMail']);

});

I want to send an email to the player_id but when sending got this error

0 likes
3 replies
Rafazion's avatar

Swift_RfcComplianceException in MailboxHeader.php line 348: Address in mailbox given [] does not comply with RFC 2822, 3.6.2. when I send a message with postman

Snapey's avatar

it's because you are not setting the from address

check you have done this in the config/mail.php file

Please or to participate in this conversation.