Я пытаюсь отредактировать содержимое шаблона электронной почты из базы данных и отправить его своим пользователям. Теперь всякий раз, когда я нажимаю кнопку «Отправить», только половина содержимого html-почты отправляется на электронный адрес пользователя.
Вот мой код
$this->validate($request, [
'to' => 'required|email',
'contents' => 'required',
'subject'=> 'required'
]);
$data = [
'to_user' => $request->to,
'content' => $request->contents,
'type' => 'email'
];
$unique = str_random(6) . '-'.str_random(5);
File::put("/var/www/resources/views/mails/" . $unique.".blade.php", $request->contents);
$datas = [
'from' => 'support@example.com',
'from_name' => 'Example',
'reply_to' => 'support@example.com',
'reply_to_name'=> 'Example Support Team',
'subject'=> $request->subject,
'type' => 'email',
'code' => $unique
];
\App\DeliveryLog::create($data);
Mail::to($request->to)->send(new DeliveryMail($datas));
Вот скриншот запроса, отправляемого контроллеру.
Проверить скриншот !
Вот код Ajax
$('.sendEmail').on('click', function () {
email = $('#semail').val();
subject = $('#subject').val();
content = CKEDITOR.instances.CustomerEmailTemplate_content.getData();
$(".sendEmail").text("Sending... Please wait.");
$('.sendEmail').prop('disabled', true);
request = $.ajax({
url: "/ajax/send/email",
type: "post",
data: "to=" + email + "&subject=" + subject + "&contents=" + content + "&_token=" + $('meta[name="csrf-token"]').attr('content')
});
// Callback handler that will be called on success
request.done(function (response, textStatus, jqXHR) {
// Log a message to the console
if (response.result === "success") {
iziToast.success({
title: 'Success',
message: 'Email Sent Successfully.',
position: 'topRight',
timeout: '10000',
pauseOnHover: true,
});
} else {
iziToast.warning({
title: 'Success',
message: response.message,
position: 'topRight',
timeout: '10000',
pauseOnHover: true,
});
}
});
// Callback handler that will be called on failure
request.fail(function (jqXHR, textStatus, errorThrown) {
// Log the error to the console
console.error(
"The following error occurred: " +
textStatus, errorThrown
);
});
// Callback handler that will be called regardless
// if the request failed or succeeded
request.always(function () {
$(".sendEmail").text("Send Email");
$('.sendEmail').prop('disabled', false);
});
});
Я не получаю никакой ошибки, но хранится только половина электронного письма.