Hi,
I want to create a form that a user can fill in his information and send the form to his friends via email.
Anybody have ideas or examples they know of.
A practical, safe way to implement a "send to friends" feature, building on 's request and ’s valid concern about abuse: require the sender to be a logged-in or otherwise verified user, limit recipients per submit (for example 3–5), add a CAPTCHA and per-IP/user rate limits, and keep an audit log of every send. Do not allow arbitrary From headers — use a domain-controlled From and place the sender name/address in the message or a Reply-To you control. That reduces spoofing and improves deliverability.
Server-side checks that should run on every submission: validate each email with filter_var, strip CR/LF characters to prevent header injection, and queue messages for background sending so web requests return quickly. Example sanitization:
$addr = trim($_POST['friend']);
$addr = str_replace(array("\r","\n"), '', $addr);
if (!filter_var($addr, FILTER_VALIDATE_EMAIL)) { /* skip */ } For reliable sending, use authenticated SMTP or a transactional email service rather than raw mail() from an unconfigured host. Libraries like PHPMailer make SMTP straightforward. Also configure SPF/DKIM/DMARC for your sending domain, include a clear reason why the recipient got the email plus an opt-out, and test deliverability during development. For reference on PHP sending and libraries see the PHP mail() manual and PHPMailer on GitHub; for production delivery consider a provider such as SendGrid.
What would be the best way to do this. Even if it's not the form itself just the data.
I want to add code to my e-commerce web-site that allows a visitor to send out a "Here is my new info" message to their friends.
I've looked at several different FORM-based code examples, but none I have found really fits what I want to do - and I've seen web-sites that can do this without the user popping up their default mail program to do the task.
Any pointers - either way - I'm just looking for a simple solution...
There is an inherent risk of real high SPAM abuse in what you are trying to acheive as well as trojans, etc. Do you have your own email server? If not, you may not want to do this.
In order to have your server send the email, its IP Address usually has to be registered with the email server. Even if you have your own email server, the risks are enormous.
I can assure you that doing what you are requesting help with is likely to make your web site hated and banned by many large companies. That is how great the risk.
I do what you are referring to but it is very controlled. Only people within the company are allowed access to the web pages that accomplish it and I log every event associated with it. That enables me to monitor for abuse.
My advice is "DON'T DO IT!" At least, not until you understand the risks and can control them.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.