I am having an issue with Laravel 5.1 and summernote. I am using summernote to compose an email which I am sending via angular.js to a laravel 5.1 API.
I have debugged as much as I can but I cannot seem to get the email sending in HTML code that renders correctly.
The message source correctly shows that the email is being sent in HTML but somehow the body of the email keeps being converted to htmlentities and the then HTML code is showing in the email body when received.
My mail send command in Laravel is as follows.
$params = json_decode(file_get_contents('php://input'),true);
$body = $params['body'];
$to_address = $params['to'];
$subject = $params['subject'];
Mail::send(['html' => 'emails.send_email'], ['body'=>$body], function ($message) use ($to_address, $subject){
$message->from($to_address);
$message->subject($subject);
$message->to($to_address);
});
The text body text I have tried in summernote is simply,
Test
Test
Which is coming through as
test<br>test
Message source has this in it which is leading me to the htmlentities issue.
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 7bit
<body>
test<br><br>test<br>
</body>
The Angular.js code to gather the summernote details
sendEmail($scope.to, $scope.subject, $scope.body).then(function(){
// Clear out the compose
$scope.subject = '';
$scope.body = '';
$scope.success_message_sent = true;
});
Then the sending function
$scope.sendEmail = function(to, subject, body) {
var deferred = $q.defer();
var data = {
'to': to,
'subject': subject,
'body': body
};
$http.post('http://'+ remoteServer +'/api/send_email', data)
.success(function() { deferred.resolve(); })
.error(function() { deferred.reject("Failed to send message");
});
return deferred.promise;
I am using Mandrill to send the email.
Any assistance would be greatly appreciated.
Thanks
I believe this issue is coming from your template:
In your emails.send_email.blade.php
use {!! $body !!}
to prevent htmlentities issue