i want to send a mail to a friend with my one-page compose mail site, i dont know how to implement the to: field, know a little of

Dani AI

Generated

Practical, modern tips to make a safe and usable "To:" field that build on 's question and the replies from and .

Keep the UX simple but explicit: use the HTML5 input with type="email" so browsers give basic validation and mobile keyboards show the right layout (MDN docs). Support multiple recipients with a chip/tag UI and clear separators (commas/semicolons), plus autocomplete from the user’s contacts so names map to addresses rather than relying on raw typing.

Server-side is where correctness and safety happen. Always re-validate and normalize every address on the server, enforce a sensible recipient limit, and block CR/LF characters that enable header injection. For sending, prefer a maintained mail library that supports authenticated SMTP and TLS instead of hand-rolling mail() calls — it improves reliability and avoids common pitfalls (example: PHPMailer). Also plan for deliverability: use authenticated SMTP, set SPF/DKIM, and consider a transactional provider if volume matters.

Operational tips: add rate limits, CAPTCHA or sender verification to prevent abuse, log send attempts with error details for troubleshooting, and show clear user-facing errors. When posting code or examples here, format them with the forum code tags as suggested so others can read and test safely.

Recommended Answers

All 3 Replies

Member Avatar for Member #114696

You need to use server side scripts such as ASP, PHP etc.

Is it that you want to send an email to this person...if so this is the script...... (put this where you want the user to type in the content and all that:


<form action="sending.php" method="POST">
Your email address: <input type="text" size="25" maxlength="40 "name="mailer" ><br><br>
Your Name <input type="text" style="margin-left:50px;" size="25" maxlength="40 "name="from" ><br><br>
Message :
<input type="message" class="content" height="150px" name="message">
<br>
<br>
<input type="submit" style="margin-left:20px;"" "value="Send">

</form>

*****and then put this on a page entitled "sending.php"..................:

<?php
$to = ";
$subject = "Your site's message from $from";
$mail = "$from, whos email is $mailer, would like to say : $message";
$body = "$mail";
if (mail($to, $subject, $body)) {
echo("<p>Your message has been sent to the Administrator of this site</p>");
} else {
echo("<p>Message delivery failed...Please try again, and remember to fill in all the forms!</p>");
}
?>

.... and that will be your email form.... on your site your users will be able to send you emails directly from the page! --- oh and all you need to change really is the email.

any help?

Member Avatar for Member #114696

Well Designer_101, I am actually surprised that even after 25 posts you dont use [ code ] tags. There are actually [ code ] tags in which you could wrap your code, it would colourise(more precisely Syntax Highlight) and indent your code properly. Read This.

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.