コード例 #1
0
 /**
  * Entry point to send emails via Mailgun
  *
  * @param Request $request
  * @return JsonResponse
  */
 public function mail(Request $request)
 {
     try {
         $service = SendMail::create($request);
         $service->send();
     } catch (ProjectNotSupported $e) {
         return new JsonResponse(['success' => false, 'errors' => ["The project you've provided could not be found in our records"]], 400);
     } catch (ValidationException $e) {
         return new JsonResponse(['success' => false, 'errors' => $e->validator->errors()], 400);
     } catch (\Exception $e) {
         return new JsonResponse(['success' => false, 'errors' => [$e->getMessage()]], 400);
     }
     return new JsonResponse(['success' => true]);
 }
コード例 #2
0
ファイル: SendMailTest.php プロジェクト: bitsoflove/mailstats
 /**
  * @test
  * @expectedException \Illuminate\Validation\ValidationException
  */
 public function missing_messagedata_variables_parameter_should_throw_exception()
 {
     $request = new \Illuminate\Http\Request([], ['project' => 'testing', "to" => ["name" => "Stijn Tilleman", "email" => "*****@*****.**"], "from" => ["name" => "Stijn Tilleman", "email" => "*****@*****.**"], "subject" => "insert subject here", "messageData" => ["view" => "emails.test"]]);
     \BitsOfLove\MailStats\SendMail::create($request);
 }