Documentation
How to use the SMTP configuration form:
- Enter the website domain (e.g. domain.com or sub.domain.com)
- Enter the SMTP host (e.g. smtp.gmail.com)
- Enter the SMTP port (e.g. 587)
- Enter the username (email address)
- Enter the password or app password
- Subject (name="subject"): Defines the email subject line that will be shown to the recipient
- To (name="to"): Recipient email address. If left empty, emails will be sent to the SMTP username
- Text (name="text"): Plain text version of the email content. Used when no HTML is provided
- HTML (name="html"): HTML formatted email content. If empty, the text version will be used instead
- Dynamic Fields (any name="..."): Any additional form inputs (e.g. name, phone, company) are automatically included in the email
Example Frontend Form Submit (HTML Form)
<form data-mailtree="true">
<input type="text" name="name" placeholder="Full Name" required>
<input type="email" name="email" placeholder="Email Address" required>
<input type="text" name="phone" placeholder="Phone (optional)">
<input type="text" name="subject" placeholder="Subject (optional)">
<input type="text" name="company" placeholder="Company (optional)">
<textarea name="message" placeholder="Message" required></textarea>
<button type="submit">Send</button>
</form>
<script src="https://mailtree.vercel.app/mailtree.js"></script>Example Frontend Form Submit (JavaScript)
document.getElementById("contactForm").addEventListener("submit", async (e) => {
e.preventDefault();
const formData = new FormData(e.target);
const data = {};
formData.forEach((value, key) => {
data[key] = value;
});
const res = await fetch("https://mailtree.vercel.app/send", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(data)
});
const result = await res.json();
alert(result.message || "Email sent successfully!");
});
Note: Form supports dynamic fields. Any input with a name attribute will be sent automatically to the Mailtree API endpoint.