Hi. i have small problem with sending email.(he not send)

<FORM METHOD=POST ACTION="mailto:darguzas.sigitas@gmail.com" ENCTYPE="text/plain">
<label>Vartotojo vardas</label>
<INPUT TYPE="text" NAME="username">
<label>Jūsų electroninis paštas</label>
<INPUT TYPE="email" NAME="email">
<label>Kodėl norite prisijunkti prie mūsų sistemos ?</label>
<TEXTAREA NAME="COMMENTS" ROWS="10" WRAP="hard">
</TEXTAREA>
<INPUT NAME="redirect" TYPE="hidden" VALUE="index.html">
<INPUT NAME="NEXT_URL" TYPE="hidden" VALUE="index.html">
<BR>
<button TYPE="submit" VALUE="submit" class="btn btn-success">Dėti užklausą</button>
</FORM>

Dani AI

Generated

— the mailto-based form in the first post will behave differently across browsers and devices and often fails silently. was correct to call the approach unreliable. Relying on the visitor’s mail client prevents server-side validation, logging, templating, TLS-authenticated delivery, and makes spam control impossible. For a production site, server-side handling is the reliable path.

Recommended workflow: submit the form with POST to a server endpoint, validate and sanitize inputs on the server, and send mail via an authenticated SMTP connection (or a trusted mail library). Use a fixed sender address (for deliverability) and put the user address into Reply-To. Add rate limits and a CAPTCHA or other anti‑spam checks. If no server code is possible, a hosted form service (form-as-a-service) provides a managed alternative.

Minimal example (PHP with PHPMailer) showing validation, Reply‑To usage and a redirect on success:

<?php
require 'vendor/autoload.php';
use PHPMailer\PHPMailer\PHPMailer;

$name    = trim(strip_tags($_POST['name'] ?? ''));
$email   = filter_var($_POST['email'] ?? '', FILTER_VALIDATE_EMAIL);
$message = trim(strip_tags($_POST['message'] ?? ''));

if (!$email) { http_response_code(400); exit('Invalid email'); }

$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host       = 'smtp.example.com';
$mail->SMTPAuth   = true;
$mail->Username   = 'smtp-user';
$mail->Password   = 'smtp-pass';
$mail->SMTPSecure = 'tls';
$mail->Port       = 587;

$mail->setFrom('no-reply@yourdomain.com','Website');
$mail->addReplyTo($email, $name);
$mail->addAddress('contact@yourdomain.com');
$mail->Subject = 'Contact form';
$mail->Body    = $message;

if ($mail->send()) { header('Location: thanks.html'); exit; }
http_response_code(500);

Troubleshooting notes: enable SMTP debug output when testing, check webserver and mail logs, confirm SPF/DKIM for the sending domain, and avoid placing user-supplied addresses in the From header (use Reply‑To instead). These steps produce consistent delivery and give operators the logs and error handling that a mailto form cannot provide.

Recommended Answers

All 2 Replies

This method is unreliable. You must use method="get" in your <form> tag for this method to work at all. Many browsers will just open a new window in the user's Email program to allow him to enter his message and send it.

You should install a "formmail" script on the server to send Emails. You can find them by searching on "formmail script".

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.