Is there any way to make a form so that it sends the information to my email with just xhtml and css when submit button is used. A colleague suggested using "mailto:" in the action attribute but that did not work.

Dani AI

Generated

Short answer for : you cannot reliably deliver form submissions to your inbox using only XHTML/CSS. Client-side tricks that open the user’s mail program are inconsistent, depend on the visitor having a configured mail client, and often produce malformed or missing data. and were pointing toward the same limitation and the need for something beyond purely client-side markup. See the HTML form docs for how submission works in general (MDN: form element).

Practical paths forward (pick one based on hosting and effort):

  • Self-host a small handler and send via authenticated SMTP or an email API. Use a maintained library such as PHPMailer, validate and sanitize all inputs, use TLS, and avoid allowing user-supplied headers (see OWASP on email header injection: ).
  • Use a third-party form endpoint (no server code): services like Formspree or platform features such as Netlify Forms accept POSTs and forward to email or an inbox.
  • If hosting is static but you want full control, use a serverless function (Netlify/AWS Lambda) to receive the form and relay via SMTP/API.

Quick tips: always validate on the server, add spam protection (CAPTCHA or honeypot), test deliveries across providers and check spam folders, and monitor logs or delivery webhooks so you know when messages fail.

Recommended Answers

All 2 Replies

that will only submit field name and data inserted into the filed, not what you asking for

No, you'll need a server side script for that. PHP has a mail function that's pretty easy to use. Here's a link to an easy to follow tutorial on how to do it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.