For a locally hosted HTML page, I need to email a bit of user input (name, email, comments).
This is done on a touchscreen display, where visitors can leave their information and comments.
So I was thinking of using a virtual keyboard such as here.
<form action="post" id="emails" onsubmit="return false;">
<input type="text" id="keyboard" placeholder="Enter name..."></input>
<input type="text" id="keyboard2" placeholder="Enter email..."></input>
<input type='submit' id='send' value='Submit' />
</form>
I used this to be able to send the email link.
And with the correct details, the following code works and I get emails in my inbox.
$('#send').click(function() {
$.ajax({
type: 'POST',
url: 'https://mandrillapp.com/api/1.0/messages/send.json',
data: {
'key': "xxxxxxxx",
'message': {
'from_email': "[email protected]",
'to': [
{
'email': "[email protected]",
'name': 'xxxxxx',
'type': 'to'
}
],
'autotext': 'true',
'subject': 'TEST! TEST!',
'html': 'test'
}
}
}).done(function(response) {
console.log(response);
alert("You send an email!"); // if you're into that sorta thing
});
});
So this works, as in it sends the email with the text put in here: 'html': 'test'
And instead of 'test', I would obviously like to get 'name + email'.
(Also it is probably for less then 50 emails per month, so just an email will suit my needs for now, nothing with databases and saving all this data. I would just like to get the email.)
So, is it possible and how should I do this?
Is the route I took now doable or would you suggest a completely different way?
// do everything inside after page load.
$(function() {
$('#send').click(function() {
// get values of inputs...
var name = $('#keyboard').val(),
email = $('#keyboard2').val();
$.ajax({
type: 'POST',
url: 'https://mandrillapp.com/api/1.0/messages/send.json',
data: {
'key': "xxxxxxxx",
'message': {
'from_email': "[email protected]",
'to': [
{
'email': "[email protected]",
'name': 'xxxxxx',
'type': 'to'
}
],
'autotext': 'true',
'subject': 'TEST! TEST!',
'html': 'Name: ' + name + '\nEmail: ' + email // and use it!
}
}
}).done(function(response) {
console.log(response);
alert("You send an email!"); // if you're into that sorta thing
});
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With