Take the 2-minute tour ×

Can anyone suggest a way, or a link to an example, of building a function in PHP that allows users to send a link via e-mail to multiple friends?

share|improve this question

3 Answers 3

up vote 0 down vote accepted

not sure what you mean by secure but I would expect that you would post the form to a server side script which would email the link/page/etc to your list of friends. Take that script and run play around with it.

Example Code

share|improve this answer
link is offline –  takeshin Nov 9 '12 at 11:46

By "secure" do you mean not allowing your form to be used to send spam?

There are a few ways to combat this:

  • Don't allow the sender to enter any information. You'll just send to that list of e-mails: "such and such" suggested you check out this link. This removes the incentive from spammers.
  • Captcha, force the user to fill out things to make sure it's not a robot sending spam
  • Limit number of e-mails sent from the same IP
share|improve this answer
I usually throw a CAPTCHA on tell-a-friend forms and I've never had any problems. –  Paolo Bergantino Dec 9 '08 at 3:39

The most recent send to a friend form I've done keeps track of the sender's IP, "from" email address, "to" email address and makes sure there are no more than five of any one of those within 24 hours.

Make sure you validate any email addresses with regular expressions, put character limits on any text areas, sanitise anything going into a database (you should use pdo).

With regards to functionality, I modelled it off Amazon's tell-a-friend. They've got a big budget for usability and so on, so I expect modelling it off them is a good idea.

share|improve this answer

Your Answer

