# emailjs.sendForm
If you are using EmailJS to send form details, sendForm will automatically collect the values of the form and pass them to the specified template. The form should have a distinct ID, and the name attribute of each field should correspond to the variable name used in the template.
# Syntax
emailjs.sendForm(serviceID, templateID, templateParams, publicKey);
# Rate Limit
1 request per second
# Parameters
NAME | TYPE | DESCRIPTION |
---|---|---|
serviceID | String | Service ID of the service through which the email should be sent. Reserved keyword default_service is supported, and should be used to use the default service, which can be set and changed via EmailJS dashboard |
templateID | String | Template ID of the email |
form | String, HTMLFormElement | It can be HTMLFormElement or query selector |
publicKey | String | (optional) Public Key of the account. It’s not required if you used the init method |
# Result
The method returns the Promise. Where response is object what contains
the status
and the text
properties.
# Code Example
emailjs.sendForm('YOUR_SERVICE_ID', 'YOUR_TEMPLATE_ID', '#myForm')
.then(function(response) {
console.log('SUCCESS!', response.status, response.text);
}, function(error) {
console.log('FAILED...', error);
});
← emailjs.send /send →