How to upload html email template data through ajax
up vote
0
down vote
favorite
I'm trying to edit the content of an email template from database and sending it to my users. Now whenever i click on send button only half of of the html email content is sent to the user email address.
Here is my code
$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
];
AppDeliveryLog::create($data);
Mail::to($request->to)->send(new DeliveryMail($datas));
Here is the screenshot of Request being sent to controller.
Check Screenshot !
Here is the Ajax code
$('.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);
});
});
I'm not receiving any error but only half email is being stored.
php html laravel email
add a comment |
up vote
0
down vote
favorite
I'm trying to edit the content of an email template from database and sending it to my users. Now whenever i click on send button only half of of the html email content is sent to the user email address.
Here is my code
$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
];
AppDeliveryLog::create($data);
Mail::to($request->to)->send(new DeliveryMail($datas));
Here is the screenshot of Request being sent to controller.
Check Screenshot !
Here is the Ajax code
$('.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);
});
});
I'm not receiving any error but only half email is being stored.
php html laravel email
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm trying to edit the content of an email template from database and sending it to my users. Now whenever i click on send button only half of of the html email content is sent to the user email address.
Here is my code
$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
];
AppDeliveryLog::create($data);
Mail::to($request->to)->send(new DeliveryMail($datas));
Here is the screenshot of Request being sent to controller.
Check Screenshot !
Here is the Ajax code
$('.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);
});
});
I'm not receiving any error but only half email is being stored.
php html laravel email
I'm trying to edit the content of an email template from database and sending it to my users. Now whenever i click on send button only half of of the html email content is sent to the user email address.
Here is my code
$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
];
AppDeliveryLog::create($data);
Mail::to($request->to)->send(new DeliveryMail($datas));
Here is the screenshot of Request being sent to controller.
Check Screenshot !
Here is the Ajax code
$('.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);
});
});
I'm not receiving any error but only half email is being stored.
php html laravel email
php html laravel email
asked Nov 5 at 19:38
user8740586
62
62
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
That's because your HTML content is being interpreted as many post fields, your screenshot shows a property called subject, other contents, and then one called <html>
, <head>
, and so on. A possible solution is to serialize your template before sending it via HTTP request and then unserialize it.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
That's because your HTML content is being interpreted as many post fields, your screenshot shows a property called subject, other contents, and then one called <html>
, <head>
, and so on. A possible solution is to serialize your template before sending it via HTTP request and then unserialize it.
add a comment |
up vote
1
down vote
That's because your HTML content is being interpreted as many post fields, your screenshot shows a property called subject, other contents, and then one called <html>
, <head>
, and so on. A possible solution is to serialize your template before sending it via HTTP request and then unserialize it.
add a comment |
up vote
1
down vote
up vote
1
down vote
That's because your HTML content is being interpreted as many post fields, your screenshot shows a property called subject, other contents, and then one called <html>
, <head>
, and so on. A possible solution is to serialize your template before sending it via HTTP request and then unserialize it.
That's because your HTML content is being interpreted as many post fields, your screenshot shows a property called subject, other contents, and then one called <html>
, <head>
, and so on. A possible solution is to serialize your template before sending it via HTTP request and then unserialize it.
answered Nov 5 at 21:16
Max Almonte
294
294
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53161080%2fhow-to-upload-html-email-template-data-through-ajax%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password