tags:

views:

823

answers:

3

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?

A: 

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

NTulip
+4  A: 

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
Sam
I usually throw a CAPTCHA on tell-a-friend forms and I've never had any problems.
Paolo Bergantino
+1  A: 

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.

dylanfm