0

I am having some trouble with Laravel 4's Mail function. What my application is doing is posting some user information to a route and that route is calling a function in the controller.

Post request (AngularJS):

$http.post('api/user/register', {username: username, email: email, password: password});

Route:

Route::post('api/user/register', 'UserController@registerUser');

Controller function (in UserController.php):

public function registerUser(){

        Mail::raw('TEST EMAIL', function($message) {
            $message->to('EmailOfUser', 'NameOfUser')->subject('Welcome!');
        });
}

While I was testing the registerUser() function, I would take the user information from the post request and put it into the database using DB::insert, and that worked perfectly. However, whenever I try to use the Mail::send or Mail::raw function it gives me a "MethodNotAllowedHttpException". After doing some research on this exception, it seemed like most people were making the mistake of using get on the route of a post request. As you can see above, I do not do that and I ams still having this problem. I have tested everything else, so I am certain that the Mail function is the issue. Please help, I have been struggling with this for quite some time now.

pnuts
  • 58,317
  • 11
  • 87
  • 139
camrymps
  • 327
  • 3
  • 11
  • Have you tried calling the route directly with something like PostMan or curl? – thepratt Mar 29 '15 at 17:13
  • After using search, I found: http://stackoverflow.com/questions/19254029/angularjs-http-post-does-not-send-data – thepratt Mar 29 '15 at 17:17
  • Ok I am going to try the post fix on angular, but I still do not think that is the issue. I posted this request using Postman and got the same error. – camrymps Mar 29 '15 at 17:30
  • 2
    I found the error. It turns out that on the template I was passing through, there was a syntax error which was causing this issue. I fixed that and it is working just fine now. Thanks for the help! – camrymps Mar 29 '15 at 17:59

0 Answers0