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.